Module for plugins to import data from external databases into an AiiDA database.
“Implementation of DbImporter for the COD database.
aiida.tools.dbimporters.plugins.cod.
CodDbImporter
Bases: aiida.tools.dbimporters.baseclasses.DbImporter
aiida.tools.dbimporters.baseclasses.DbImporter
Database importer for Crystallography Open Database.
__init__
Initialize self. See help(type(self)) for accurate signature.
__module__
_angle_clause
Returns SQL query predicate for querying lattice angles.
_composition_clause
Returns SQL query predicate for querying elements in formula fields.
_connect_db
Connects to the MySQL database for performing searches.
_disconnect_db
Closes connection to the MySQL database.
_double_clause
Returns SQL query predicate for querying double-valued fields.
_formula_clause
Returns SQL query predicate for querying formula fields.
_int_clause
Returns SQL query predicate for querying integer fields.
_keywords
_length_clause
Returns SQL query predicate for querying lattice vector lengths.
_pressure_clause
Returns SQL query predicate for querying pressure.
_str_exact_clause
Returns SQL query predicate for querying string fields.
_str_exact_or_none_clause
Returns SQL query predicate for querying string fields, allowing to use Python’s “None” in addition.
_str_fuzzy_clause
Returns SQL query predicate for fuzzy querying of string fields.
_temperature_clause
Returns SQL query predicate for querying temperature.
_volume_clause
Returns SQL query predicate for querying unit cell volume.
angle_precision
get_supported_keywords
Returns the list of all supported query keywords.
list of strings
length_precision
pressure_precision
query
Performs a query on the COD database using keyword = value pairs, specified in kwargs.
keyword = value
kwargs
an instance of aiida.tools.dbimporters.plugins.cod.CodSearchResults.
aiida.tools.dbimporters.plugins.cod.CodSearchResults
query_sql
Forms a SQL query for querying the COD database using keyword = value pairs, specified in kwargs.
string containing a SQL statement.
setup_db
Changes the database connection details.
temperature_precision
volume_precision
CodEntry
Bases: aiida.tools.dbimporters.baseclasses.CifEntry
aiida.tools.dbimporters.baseclasses.CifEntry
Represents an entry from COD.
Creates an instance of aiida.tools.dbimporters.plugins.cod.CodEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.cod.CodEntry
_license
CodSearchResults
Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults
aiida.tools.dbimporters.baseclasses.DbSearchResults
Results of the search, performed on COD.
__len__
_base_url
_get_source_dict
Returns a dictionary, which is passed as kwargs to the created DbEntry instance, describing the source of the entry.
result_dict – dictionary, describing an entry in the results.
_get_url
Returns an URL of an entry CIF file.
“Implementation of DbImporter for the CISD database.
aiida.tools.dbimporters.plugins.icsd.
CifFileErrorExp
Bases: aiida.tools.dbimporters.plugins.icsd.IcsdImporterExp
aiida.tools.dbimporters.plugins.icsd.IcsdImporterExp
Raised when the author loop is missing in a CIF file.
IcsdDbImporter
Importer for the Inorganic Crystal Structure Database, short ICSD, provided by FIZ Karlsruhe. It allows to run queries and analyse all the results.
server –
Server URL, the web page of the database. It is required in order to have access to the full database. I t should contain both the protocol and the domain name and end with a slash, as in:
server = "http://ICSDSERVER.com/"
urladd – part of URL which is added between query and and the server URL (default: index.php?). only needed for web page query
index.php?
querydb – boolean, decides whether the mysql database is queried (default: True). If False, the query results are obtained through the web page query, which is restricted to a maximum of 1000 results per query.
dl_db – icsd comes with a full (default: icsd) and a demo database (icsdd). This parameter allows the user to switch to the demo database for testing purposes, if the access rights to the full database are not granted.
icsd
icsdd
host –
MySQL database host. If the MySQL database is hosted on a different machine, use “127.0.0.1” as host, and open a SSH tunnel to the host using:
ssh -L 3306:localhost:3306 username@hostname.com
or (if e.g. you get an URLError with Errno 111 (Connection refused) upon querying):
ssh -L 3306:localhost:3306 -L 8010:localhost:80 username@hostname.com
user – mysql database username (default: dba)
passwd – mysql database password (default: sql)
db – name of the database (default: icsd)
port – Port to access the mysql database (default: 3306)
Return SQL query predicate for querying lattice angles.
Return SQL query predicate for querying elements in formula fields.
_crystal_system_clause
Return SQL query predicate for querying crystal_system.
_density_clause
Return SQL query predicate for querying density.
Return SQL query predicate for querying double-valued fields.
Return SQL query predicate for querying formula fields.
Return SQL query predicate for querying integer fields :param key: Database keyword :param alias: Query parameter name :param values: Corresponding values from query :return: SQL query predicate
Return SQL query predicate for querying lattice vector lengths.
_parse_all
Convert numbers, strings, lists into strings. :param key: query parameter :param values: corresponding values :return retval: string
_parse_mineral
Convert mineral_name and chemical_name into right format. :param key: query parameter :param values: corresponding values :return retval: string
_parse_number
Convert int into string. :param key: query parameter :param values: corresponding values :return retval: string
_parse_system
Return crystal system in the right format. :param key: query parameter :param values: corresponding values :return retval: string
_parse_volume
Convert volume, cell parameter and angle queries into right format. :param key: query parameter :param values: corresponding values :return retval: string
Return SQL query predicate for querying pressure.
_query_sql_db
Perform a query on Icsd mysql database using keyword = value pairs, specified in kwargs. Returns an instance of IcsdSearchResults. :param kwargs: A list of keyword = [values] pairs :return: IcsdSearchResults
keyword = [values]
_queryweb
Perform a query on the Icsd web database using keyword = value pairs, specified in kwargs. Returns an instance of IcsdSearchResults. :note: Web search has a maximum result number fixed at 1000. :param kwargs: A list of keyword = [values] pairs :return: IcsdSearchResults
Return SQL query predicate for querying string fields.
Return SQL query predicate for fuzzy querying of string fields.
Return SQL query predicate for querying temperature.
Return SQL query predicate for querying unit cell volume.
density_precision
List of all supported query keywords.
keywords
keywords_db
Depending on the db_parameters, the mysql database or the web page are queried. Valid parameters are found using IcsdDbImporter.get_supported_keywords().
kwargs – A list of ‘’keyword = [values]’’ pairs.
Change the database connection details. At least the host server has to be defined.
kwargs – db_parameters for the mysql database connection (host, user, passwd, db, port)
IcsdEntry
Represent an entry from Icsd.
Before July 2nd 2015, source[‘id’] contained icsd.IDNUM (internal icsd id number) and source[‘extras’][‘cif_nr’] the cif number (icsd.COLL_CODE).
After July 2nd 2015, source[‘id’] has been replaced by the cif number and source[‘extras’][‘idnum’] is icsd.IDNUM .
Create an instance of IcsdEntry, related to the supplied URI.
contents
Returns raw contents of a file as string. This overrides the DbEntry implementation because the ICSD php backend returns the contents of the CIF in ISO-8859-1 encoding. However, the PyCifRW library (and most other sensible applications), expects UTF-8. Therefore, we decode the original CIF data to unicode and encode it in the UTF-8 format
get_ase_structure
ASE structure corresponding to the cif file.
IcsdImporterExp
Bases: Exception
Exception
Base class for ICSD exceptions.
__weakref__
list of weak references to the object (if defined)
IcsdSearchResults
Result manager for the query performed on ICSD.
query – mysql query or webpage query
db_parameters – database parameter setup during the initialisation of the IcsdDbImporter.
Connect to the MySQL database for performing searches.
Close connection to the MySQL database.
at
Return position-th result as IcsdEntry.
position
cif_url
db_name
next
Return next result as IcsdEntry.
query_db_version
Query the version of the icsd database (last row of RELEASE_TAGS).
query_page
Query the mysql or web page database, depending on the db_parameters. Store the number_of_results, cif file number and the corresponding icsd number.
Icsd uses its own number system, different from the CIF file numbers.
results
Return the list of results
NoResultsWebExp
Raised when a webpage query returns no results.
correct_cif
Correct the format of the CIF files. At the moment, it only fixes missing quotes in the authors field (ase.read.io only works if the author names are quoted, if not an AssertionError is raised).
ase.read.io
cif – A string containing the content of the CIF file.
a string containing the corrected CIF file.
“Implementation of DbImporter for the Materials Project database.
aiida.tools.dbimporters.plugins.materialsproject.
MaterialsProjectCifEntry
A Materials Project entry class which extends the DbEntry class with a CifEntry class.
The DbSearchResults base class instantiates a new DbEntry by explicitly passing the url of the entry as an argument. In this case it is the same as the ‘uri’ value that is already contained in the source dictionary so we just copy it
MaterialsProjectImporter
Database importer for the Materials Project.
Instantiate the MaterialsProjectImporter by setting up the Materials API (MAPI) connection details.
_find
Query the database with a given dictionary of query parameters
query – a dictionary with the query parameters
_properties
_supported_keywords
_verify_api_key
Verify the supplied API key by issuing a request to Materials Project.
api_key
Return the API key configured for the importer
Returns the list of all supported query keywords
properties
Return the properties that will be queried
Query the database with a given dictionary of query parameters for a given properties
properties – the properties to query
Setup the required parameters to the REST API
MaterialsProjectSearchResults
A collection of MaterialsProjectEntry query result entries.
results – query result entry dictionary
the class associated with each
_db_name
_db_uri
Return the source information dictionary of an Materials Project query result entry
result_dict – query result entry dictionary
Return the permanent URI of the result entry
_material_base_url
_version
“Implementation of DbImporter for the MPDS database.
aiida.tools.dbimporters.plugins.mpds.
ApiFormat
Bases: enum.Enum
enum.Enum
An enumeration.
CIF
JSON
MpdsCifEntry
Bases: aiida.tools.dbimporters.baseclasses.CifEntry, aiida.tools.dbimporters.plugins.mpds.MpdsEntry
aiida.tools.dbimporters.plugins.mpds.MpdsEntry
An extension of the MpdsEntry class with the CifEntry class, which will treat the contents property through the URI as a cif file
MpdsDbImporter
Database importer for the Materials Platform for Data Science (MPDS)
Instantiate the MpdsDbImporter by setting up the API connection details
url – the full base url of the REST API endpoint
api_key – the API key to be used for HTTP requests
_api_key
_collection
_pagesize
_url
collection
Return the collection that will be queried
find
get
Perform a GET request to the REST API using the kwargs as request parameters The url and API key will be used that were set upon construction
fmt – the format of the response, ‘cif’ or json’ (default)
kwargs – parameters for the GET request
get_id_from_cif
Extract the entry id from the string formatted cif response of the MPDS API
cif – string representation of the cif file
entry id of the cif file or None if could not be found
get_response_content
Analyze the response of an HTTP GET request, verify that the response code is OK and return the json loaded response text
response – HTTP response
RuntimeError – HTTP response is not 200
ValueError – HTTP response 200 contained non zero error message
pagesize
Return the pagesize set for the importer
Query the database with a given dictionary of query parameters for a given collection
collection – the collection to query
Setup the required parameters for HTTP requests to the REST API
structures
Access the structures collection in the MPDS
url
Return the base url configured for the importer
MpdsEntry
Bases: aiida.tools.dbimporters.baseclasses.DbEntry
aiida.tools.dbimporters.baseclasses.DbEntry
Represents an MPDS database entry
Set the class license from the source dictionary
MpdsSearchResults
Collection of MpdsEntry query result entries.
Return the source information dictionary of an MPDS query result entry
_return_class
alias of MpdsEntry
StructuresCollection
Bases: object
object
Collection of structures.
__dict__
engine
Return the query engine
Query the structures collection with a given dictionary of query parameters
“Implementation of DbImporter for the MPOD database.
aiida.tools.dbimporters.plugins.mpod.
MpodDbImporter
Database importer for Material Properties Open Database.
_str_clause
Returns part of HTTP GET query for querying string fields.
Performs a query on the MPOD database using keyword = value pairs, specified in kwargs.
an instance of aiida.tools.dbimporters.plugins.mpod.MpodSearchResults.
aiida.tools.dbimporters.plugins.mpod.MpodSearchResults
query_get
Forms a HTTP GET query for querying the MPOD database. May return more than one query in case an intersection is needed.
a list containing strings for HTTP GET statement.
MpodEntry
Represents an entry from MPOD.
Creates an instance of aiida.tools.dbimporters.plugins.mpod.MpodEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.mpod.MpodEntry
MpodSearchResults
Results of the search, performed on MPOD.
“Implementation of DbImporter for the NNIN/C database.
aiida.tools.dbimporters.plugins.nninc.
NnincDbImporter
Database importer for NNIN/C Pseudopotential Virtual Vault.
Performs a query on the NNIN/C Pseudopotential Virtual Vault using keyword = value pairs, specified in kwargs.
an instance of aiida.tools.dbimporters.plugins.nninc.NnincSearchResults.
aiida.tools.dbimporters.plugins.nninc.NnincSearchResults
Forms a HTTP GET query for querying the NNIN/C Pseudopotential Virtual Vault.
a string with HTTP GET statement.
NnincEntry
Bases: aiida.tools.dbimporters.baseclasses.UpfEntry
aiida.tools.dbimporters.baseclasses.UpfEntry
Represents an entry from NNIN/C Pseudopotential Virtual Vault.
Creates an instance of aiida.tools.dbimporters.plugins.nninc.NnincEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.nninc.NnincEntry
NnincSearchResults
Results of the search, performed on NNIN/C Pseudopotential Virtual Vault.
“Implementation of DbImporter for the OQMD database.
aiida.tools.dbimporters.plugins.oqmd.
OqmdDbImporter
Database importer for Open Quantum Materials Database.
Performs a query on the OQMD database using keyword = value pairs, specified in kwargs.
an instance of aiida.tools.dbimporters.plugins.oqmd.OqmdSearchResults.
aiida.tools.dbimporters.plugins.oqmd.OqmdSearchResults
Forms a HTTP GET query for querying the OQMD database.
a strings for HTTP GET statement.
OqmdEntry
Represents an entry from OQMD.
Creates an instance of aiida.tools.dbimporters.plugins.oqmd.OqmdEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.oqmd.OqmdEntry
OqmdSearchResults
Results of the search, performed on OQMD.
“Implementation of DbImporter for the PCOD database.
aiida.tools.dbimporters.plugins.pcod.
PcodDbImporter
Bases: aiida.tools.dbimporters.plugins.cod.CodDbImporter
aiida.tools.dbimporters.plugins.cod.CodDbImporter
Database importer for Predicted Crystallography Open Database.
Performs a query on the PCOD database using keyword = value pairs, specified in kwargs.
an instance of aiida.tools.dbimporters.plugins.pcod.PcodSearchResults.
aiida.tools.dbimporters.plugins.pcod.PcodSearchResults
Forms a SQL query for querying the PCOD database using keyword = value pairs, specified in kwargs.
PcodEntry
Bases: aiida.tools.dbimporters.plugins.cod.CodEntry
Represents an entry from PCOD.
Creates an instance of aiida.tools.dbimporters.plugins.pcod.PcodEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.pcod.PcodEntry
PcodSearchResults
Bases: aiida.tools.dbimporters.plugins.cod.CodSearchResults
Results of the search, performed on PCOD.
“Implementation of DbImporter for the TCOD database.
aiida.tools.dbimporters.plugins.tcod.
TcodDbImporter
Database importer for Theoretical Crystallography Open Database.
Performs a query on the TCOD database using keyword = value pairs, specified in kwargs.
an instance of aiida.tools.dbimporters.plugins.tcod.TcodSearchResults.
aiida.tools.dbimporters.plugins.tcod.TcodSearchResults
TcodEntry
Represents an entry from TCOD.
Creates an instance of aiida.tools.dbimporters.plugins.tcod.TcodEntry, related to the supplied URI.
aiida.tools.dbimporters.plugins.tcod.TcodEntry
TcodSearchResults
Results of the search, performed on TCOD.