DbImporter documentation¶
Generic database importer class¶
This section describes the base class for the import of crystal structures from external databases.
-
aiida.tools.dbimporters.
DbImporterFactory
(pluginname)[source]¶ This function loads the correct DbImporter plugin class
-
class
aiida.tools.dbimporters.baseclasses.
DbEntry
(db_source=None, db_url=None, db_id=None, db_version=None, extras={}, url=None)[source]¶ Represents an entry from the structure database (COD, ICSD, ...).
-
cif
¶ Returns raw contents of a CIF file as string.
-
get_aiida_structure
()[source]¶ Returns AiiDA-compatible structure, representing the crystal structure from the CIF file.
-
get_cif_node
()[source]¶ Creates a CIF node, that can be used in AiiDA workflow.
Returns: aiida.orm.data.cif.CifData
object
-
-
class
aiida.tools.dbimporters.baseclasses.
DbImporter
[source]¶ Base class for database importers.
-
get_supported_keywords
()[source]¶ Returns the list of all supported query keywords.
Returns: list of strings
-
query
(**kwargs)[source]¶ Method to query the database.
Parameters: - id – database-specific entry identificator
- element – element name from periodic table of elements
- number_of_elements – number of different elements
- mineral_name – name of mineral
- chemical_name – chemical name of substance
- formula – chemical formula
- volume – volume of the unit cell in cubic angstroms
- spacegroup – symmetry space group symbol in Hermann-Mauguin notation
- spacegroup_hall – symmetry space group symbol in Hall notation
- b, c (a,) – length of lattice vectors in angstroms
- beta, gamma (alpha,) – angles between lattice vectors in degrees
- z – number of the formula units in the unit cell
- measurement_temp – temperature in kelvins at which the unit-cell parameters were measured
- measurement_pressure – pressure in kPa at which the unit-cell parameters were measured
- diffraction_temp – mean temperature in kelvins at which the intensities were measured
- diffraction_pressure – mean pressure in kPa at which the intensities were measured
- authors – authors of the publication
- journal – name of the journal
- title – title of the publication
- year – year of the publication
- journal_volume – journal volume of the publication
- journal_issue – journal issue of the publication
- first_page – first page of the publication
- last_page – last page of the publication
- doi – digital object identifyer (DOI), refering to the publication
Raises NotImplementedError: if search using given keyword is not implemented.
-
-
class
aiida.tools.dbimporters.baseclasses.
DbSearchResults
[source]¶ Base class for database results.
All classes, inheriting this one and overriding
at()
, are able to benefit from having functions__iter__
,__len__
and__getitem__
.-
DbSearchResults.
__iter__
()[source]¶ Instances of
aiida.tools.dbimporters.baseclasses.DbSearchResults
can be used as iterators.
-
DbSearchResults.
at
(position)[source]¶ Returns
position
-th result asaiida.tools.dbimporters.baseclasses.DbEntry
.Parameters: position – zero-based index of a result. Raises IndexError: if position
is out of bounds.
-
DbSearchResults.
fetch_all
()[source]¶ Returns all query results as an array of
aiida.tools.dbimporters.baseclasses.DbEntry
.
-
DbSearchResults.
next
()[source]¶ Returns the next result of the query (instance of
aiida.tools.dbimporters.baseclasses.DbEntry
).Raises StopIteration: when the end of result array is reached.
-
COD database importer¶
-
class
aiida.tools.dbimporters.plugins.cod.
CodDbImporter
(**kwargs)[source]¶ Database importer for Crystallography Open Database.
-
get_supported_keywords
()[source]¶ Returns the list of all supported query keywords.
Returns: list of strings
-
query
(**kwargs)[source]¶ Performs a query on the COD database using
keyword = value
pairs, specified inkwargs
.Returns: an instance of aiida.tools.dbimporters.plugins.cod.CodSearchResults
.
-
-
class
aiida.tools.dbimporters.plugins.cod.
CodEntry
(url, db_source='Crystallography Open Database', db_url='http://www.crystallography.net', **kwargs)[source]¶ Represents an entry from COD.
-
get_ase_structure
()[source]¶ Returns ASE representation of the CIF.
Note: to be removed, as it is duplicated in aiida.orm.data.cif.CifData
.
-
-
class
aiida.tools.dbimporters.plugins.cod.
CodSearchResults
(results)[source]¶ Results of the search, performed on COD.
-
at
(position)[source]¶ Returns
position
-th result asaiida.tools.dbimporters.plugins.cod.CodEntry
.Parameters: position – zero-based index of a result. Raises IndexError: if position
is out of bounds.
-
TCOD database importer¶
-
class
aiida.tools.dbimporters.plugins.tcod.
TcodDbImporter
(**kwargs)[source]¶ Database importer for Theoretical Crystallography Open Database.
-
query
(**kwargs)[source]¶ Performs a query on the TCOD database using
keyword = value
pairs, specified inkwargs
.Returns: an instance of aiida.tools.dbimporters.plugins.tcod.TcodSearchResults
.
-
MPOD database importer¶
-
class
aiida.tools.dbimporters.plugins.mpod.
MpodDbImporter
(**kwargs)[source]¶ Database importer for Material Properties Open Database.
-
get_supported_keywords
()[source]¶ Returns the list of all supported query keywords.
Returns: list of strings
-
query
(**kwargs)[source]¶ Performs a query on the MPOD database using
keyword = value
pairs, specified inkwargs
.Returns: an instance of aiida.tools.dbimporters.plugins.mpod.MpodSearchResults
.
-
-
class
aiida.tools.dbimporters.plugins.mpod.
MpodEntry
(url, **kwargs)[source]¶ Represents an entry from MPOD.
-
class
aiida.tools.dbimporters.plugins.mpod.
MpodSearchResults
(results)[source]¶ Results of the search, performed on MPOD.
-
at
(position)[source]¶ Returns
position
-th result asaiida.tools.dbimporters.plugins.mpod.MpodEntry
.Parameters: position – zero-based index of a result. Raises IndexError: if position
is out of bounds.
-
ICSD database importer¶
-
exception
aiida.tools.dbimporters.plugins.icsd.
CifFileErrorExp
[source]¶ Raised when the author loop is missing in a CIF file.
-
class
aiida.tools.dbimporters.plugins.icsd.
IcsdDbImporter
(**kwargs)[source]¶ Importer for the Inorganic Crystal Structure Database, short ICSD, provided by FIZ Karlsruhe. It allows to run queries and analyse all the results.
Parameters: - 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 - 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. - 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
See the DbImporter documentation and tutorial page for more information.
- 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)
- server –
-
class
aiida.tools.dbimporters.plugins.icsd.
IcsdEntry
(url, **kwargs)[source]¶ Represent an entry from Icsd.
-
cif
¶ Returns: cif file of Icsd entry.
-
get_cif_node
()[source]¶ Create a CIF node, that can be used in AiiDA workflow.
Returns: aiida.orm.data.cif.CifData
object
-
-
class
aiida.tools.dbimporters.plugins.icsd.
IcsdSearchResults
(query, db_parameters)[source]¶ Result manager for the query performed on ICSD.
Parameters: - query – mysql query or webpage query
- db_parameters – database parameter setup during the initialisation of the IcsdDbImporter.
-
exception
aiida.tools.dbimporters.plugins.icsd.
NoResultsWebExp
[source]¶ Raised when a webpage query returns no results.
-
aiida.tools.dbimporters.plugins.icsd.
correct_cif
(cif)[source]¶ 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).Parameters: cif – A string containing the content of the CIF file. Returns: a string containing the corrected CIF file.