aiida.tools.dbimporters.plugins package

Submodules

class aiida.tools.dbimporters.plugins.cod.CodDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for Crystallography Open Database.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.cod'
_angle_clause(key, alias, values)[source]

Returns SQL query predicate for querying lattice angles.

_composition_clause(key, alias, values)[source]

Returns SQL query predicate for querying elements in formula fields.

_connect_db()[source]

Connects to the MySQL database for performing searches.

_disconnect_db()[source]

Closes connection to the MySQL database.

_double_clause(key, alias, values, precision)[source]

Returns SQL query predicate for querying double-valued fields.

_formula_clause(key, alias, values)[source]

Returns SQL query predicate for querying formula fields.

_int_clause(key, alias, values)[source]

Returns SQL query predicate for querying integer fields.

_keywords = {'a': ['a', <function CodDbImporter._length_clause>], 'alpha': ['alpha', <function CodDbImporter._angle_clause>], 'authors': ['authors', <function CodDbImporter._str_fuzzy_clause>], 'b': ['b', <function CodDbImporter._length_clause>], 'beta': ['beta', <function CodDbImporter._angle_clause>], 'c': ['c', <function CodDbImporter._length_clause>], 'chemical_name': ['chemname', <function CodDbImporter._str_fuzzy_clause>], 'determination_method': ['method', <function CodDbImporter._str_exact_or_none_clause>], 'diffraction_pressure': ['diffrpressure', <function CodDbImporter._pressure_clause>], 'diffraction_temp': ['diffrtemp', <function CodDbImporter._temperature_clause>], 'doi': ['doi', <function CodDbImporter._str_exact_clause>], 'element': ['element', <function CodDbImporter._composition_clause>], 'first_page': ['firstpage', <function CodDbImporter._str_exact_clause>], 'formula': ['formula', <function CodDbImporter._formula_clause>], 'gamma': ['gamma', <function CodDbImporter._angle_clause>], 'id': ['file', <function CodDbImporter._int_clause>], 'journal': ['journal', <function CodDbImporter._str_fuzzy_clause>], 'journal_issue': ['issue', <function CodDbImporter._str_exact_clause>], 'journal_volume': ['volume', <function CodDbImporter._int_clause>], 'last_page': ['lastpage', <function CodDbImporter._str_exact_clause>], 'measurement_pressure': ['cellpressure', <function CodDbImporter._pressure_clause>], 'measurement_temp': ['celltemp', <function CodDbImporter._temperature_clause>], 'mineral_name': ['mineral', <function CodDbImporter._str_fuzzy_clause>], 'number_of_elements': ['nel', <function CodDbImporter._int_clause>], 'spacegroup': ['sg', <function CodDbImporter._str_exact_clause>], 'spacegroup_hall': ['sgHall', <function CodDbImporter._str_exact_clause>], 'title': ['title', <function CodDbImporter._str_fuzzy_clause>], 'volume': ['vol', <function CodDbImporter._volume_clause>], 'year': ['year', <function CodDbImporter._int_clause>], 'z': ['Z', <function CodDbImporter._int_clause>]}
_length_clause(key, alias, values)[source]

Returns SQL query predicate for querying lattice vector lengths.

_pressure_clause(key, alias, values)[source]

Returns SQL query predicate for querying pressure.

_str_exact_clause(key, alias, values)[source]

Returns SQL query predicate for querying string fields.

_str_exact_or_none_clause(key, alias, values)[source]

Returns SQL query predicate for querying string fields, allowing to use Python’s “None” in addition.

_str_fuzzy_clause(key, alias, values)[source]

Returns SQL query predicate for fuzzy querying of string fields.

_temperature_clause(key, alias, values)[source]

Returns SQL query predicate for querying temperature.

_volume_clause(key, alias, values)[source]

Returns SQL query predicate for querying unit cell volume.

angle_precision = 0.001
get_supported_keywords()[source]

Returns the list of all supported query keywords.

Returns

list of strings

length_precision = 0.001
pressure_precision = 1
query(**kwargs)[source]

Performs a query on the COD database using keyword = value pairs, specified in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.cod.CodSearchResults.

query_sql(**kwargs)[source]

Forms a SQL query for querying the COD database using keyword = value pairs, specified in kwargs.

Returns

string containing a SQL statement.

setup_db(**kwargs)[source]

Changes the database connection details.

temperature_precision = 0.001
volume_precision = 0.001
class aiida.tools.dbimporters.plugins.cod.CodEntry(uri, db_name='Crystallography Open Database', db_uri='http://www.crystallography.net/cod', **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry

Represents an entry from COD.

__init__(uri, db_name='Crystallography Open Database', db_uri='http://www.crystallography.net/cod', **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.cod.CodEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.cod'
_license = 'CC0'
class aiida.tools.dbimporters.plugins.cod.CodSearchResults(results)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

Results of the search, performed on COD.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__len__()[source]
__module__ = 'aiida.tools.dbimporters.plugins.cod'
_base_url = 'http://www.crystallography.net/cod/'
_get_source_dict(result_dict)[source]

Returns a dictionary, which is passed as kwargs to the created DbEntry instance, describing the source of the entry.

Parameters

result_dict – dictionary, describing an entry in the results.

_get_url(result_dict)[source]

Returns an URL of an entry CIF file.

Parameters

result_dict – dictionary, describing an entry in the results.

exception aiida.tools.dbimporters.plugins.icsd.CifFileErrorExp[source]

Bases: aiida.tools.dbimporters.plugins.icsd.IcsdImporterExp

Raised when the author loop is missing in a CIF file.

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
class aiida.tools.dbimporters.plugins.icsd.IcsdDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Importer for the Inorganic Crystal Structure Database, short ICSD, provided by FIZ Karlsruhe. It allows to run queries and analyse all the results. See the DbImporter documentation and tutorial page for more information.

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
    

    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)

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
_angle_clause(key, alias, values)[source]

Return SQL query predicate for querying lattice angles.

_composition_clause(key, alias, values)[source]

Return SQL query predicate for querying elements in formula fields.

_crystal_system_clause(key, alias, values)[source]

Return SQL query predicate for querying crystal_system.

_density_clause(key, alias, values)[source]

Return SQL query predicate for querying density.

_double_clause(key, alias, values, precision)[source]

Return SQL query predicate for querying double-valued fields.

_formula_clause(key, alias, values)[source]

Return SQL query predicate for querying formula fields.

_int_clause(key, alias, values)[source]

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

_length_clause(key, alias, values)[source]

Return SQL query predicate for querying lattice vector lengths.

_parse_all(v)[source]

Convert numbers, strings, lists into strings. :param k: query parameter :param v: corresponding values :return retval: string

_parse_mineral(v)[source]

Convert mineral_name and chemical_name into right format. :param k: query parameter :param v: corresponding values :return retval: string

_parse_number(v)[source]

Convert int into string. :param k: query parameter :param v: corresponding values :return retval: string

_parse_system(v)[source]

Return crystal system in the right format. :param k: query parameter :param v: corresponding values :return retval: string

_parse_volume(v)[source]

Convert volume, cell parameter and angle queries into right format. :param k: query parameter :param v: corresponding values :return retval: string

_pressure_clause(key, alias, values)[source]

Return SQL query predicate for querying pressure.

_query_sql_db(**kwargs)[source]

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

_queryweb(**kwargs)[source]

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

_str_exact_clause(key, alias, values)[source]

Return SQL query predicate for querying string fields.

_str_fuzzy_clause(key, alias, values)[source]

Return SQL query predicate for fuzzy querying of string fields.

_temperature_clause(key, alias, values)[source]

Return SQL query predicate for querying temperature.

_volume_clause(key, alias, values)[source]

Return SQL query predicate for querying unit cell volume.

angle_precision = 0.001
density_precision = 0.001
get_supported_keywords()[source]
Returns

List of all supported query keywords.

keywords = {'a': ('volume', <function IcsdDbImporter._parse_volume>), 'alpha': ('volume', <function IcsdDbImporter._parse_volume>), 'authors': ('authors', <function IcsdDbImporter._parse_all>), 'b': ('volume', <function IcsdDbImporter._parse_volume>), 'beta': ('volume', <function IcsdDbImporter._parse_volume>), 'c': ('volume', <function IcsdDbImporter._parse_volume>), 'chemical_name': ('mineral', <function IcsdDbImporter._parse_mineral>), 'crystal_system': ('system', <function IcsdDbImporter._parse_system>), 'element': ('elements', <function IcsdDbImporter._parse_all>), 'formula': ('formula', <function IcsdDbImporter._parse_all>), 'gamma': ('volume', <function IcsdDbImporter._parse_volume>), 'id': ('authors', <function IcsdDbImporter._parse_all>), 'journal': ('journal', <function IcsdDbImporter._parse_all>), 'mineral_name': ('mineral', <function IcsdDbImporter._parse_mineral>), 'number_of_elements': ('elementc', <function IcsdDbImporter._parse_all>), 'spacegroup': ('spaceg', <function IcsdDbImporter._parse_all>), 'title': ('title', <function IcsdDbImporter._parse_all>), 'volume': ('volume', <function IcsdDbImporter._parse_volume>), 'year': ('year', <function IcsdDbImporter._parse_all>)}
keywords_db = {'a': ['A_LEN', <function IcsdDbImporter._length_clause>], 'alpha': ['ALPHA', <function IcsdDbImporter._angle_clause>], 'authors': ['AUTHORS_TEXT', <function IcsdDbImporter._str_fuzzy_clause>], 'b': ['B_LEN', <function IcsdDbImporter._length_clause>], 'beta': ['BETA', <function IcsdDbImporter._angle_clause>], 'c': ['C_LEN', <function IcsdDbImporter._length_clause>], 'chemical_name': ['CHEM_NAME', <function IcsdDbImporter._str_fuzzy_clause>], 'crystal_system': ['CRYST_SYS_CODE', <function IcsdDbImporter._crystal_system_clause>], 'density': ['DENSITY_CALC', <function IcsdDbImporter._density_clause>], 'element': ['SUM_FORM;', <function IcsdDbImporter._composition_clause>], 'formula': ['SUM_FORM', <function IcsdDbImporter._formula_clause>], 'gamma': ['GAMMA', <function IcsdDbImporter._angle_clause>], 'id': ['COLL_CODE', <function IcsdDbImporter._int_clause>], 'journal': ['journal', <function IcsdDbImporter._str_fuzzy_clause>], 'measurement_temp': ['TEMPERATURE', <function IcsdDbImporter._temperature_clause>], 'molar_mass': ['MOL_MASS', <function IcsdDbImporter._density_clause>], 'number_of_elements': ['EL_COUNT', <function IcsdDbImporter._int_clause>], 'pdf_num': ['PDF_NUM', <function IcsdDbImporter._str_exact_clause>], 'spacegroup': ['SGR', <function IcsdDbImporter._str_exact_clause>], 'title': ['AU_TITLE', <function IcsdDbImporter._str_fuzzy_clause>], 'volume': ['C_VOL', <function IcsdDbImporter._volume_clause>], 'wyckoff': ['WYCK', <function IcsdDbImporter._str_exact_clause>], 'year': ['MPY', <function IcsdDbImporter._int_clause>], 'z': ['Z', <function IcsdDbImporter._int_clause>]}
length_precision = 0.001
pressure_precision = 1
query(**kwargs)[source]

Depending on the db_parameters, the mysql database or the web page are queried. Valid parameters are found using IcsdDbImporter.get_supported_keywords().

Parameters

kwargs – A list of ‘’keyword = [values]’’ pairs.

setup_db(**kwargs)[source]

Change the database connection details. At least the host server has to be defined.

Parameters

kwargs – db_parameters for the mysql database connection (host, user, passwd, db, port)

temperature_precision = 0.001
volume_precision = 0.001
class aiida.tools.dbimporters.plugins.icsd.IcsdEntry(uri, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry

Represent an entry from Icsd.

Note
  • 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 .

__init__(uri, **kwargs)[source]

Create an instance of IcsdEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
_license = 'ICSD'
property 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()[source]
Returns

ASE structure corresponding to the cif file.

exception aiida.tools.dbimporters.plugins.icsd.IcsdImporterExp[source]

Bases: Exception

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
__weakref__

list of weak references to the object (if defined)

class aiida.tools.dbimporters.plugins.icsd.IcsdSearchResults(query, db_parameters)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

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.

__init__(query, db_parameters)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
_connect_db()[source]

Connect to the MySQL database for performing searches.

_disconnect_db()[source]

Close connection to the MySQL database.

at(position)[source]

Return position-th result as IcsdEntry.

cif_url = '/index.php?format=cif&action=Export&id%5B%5D={}'
db_name = 'Icsd'
next()[source]

Return next result as IcsdEntry.

query_db_version()[source]

Query the version of the icsd database (last row of RELEASE_TAGS).

query_page()[source]

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.

Note

Icsd uses its own number system, different from the CIF file numbers.

property results

Return the list of results

exception aiida.tools.dbimporters.plugins.icsd.NoResultsWebExp[source]

Bases: aiida.tools.dbimporters.plugins.icsd.IcsdImporterExp

Raised when a webpage query returns no results.

__module__ = 'aiida.tools.dbimporters.plugins.icsd'
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.

Module that contains the class definitions necessary to offer support for queries to Materials Project.

class aiida.tools.dbimporters.plugins.materialsproject.MaterialsProjectCifEntry(url, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry

A Materials Project entry class which extends the DbEntry class with a CifEntry class.

__init__(url, **kwargs)[source]

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

__module__ = 'aiida.tools.dbimporters.plugins.materialsproject'
_license = 'Materials Project'
class aiida.tools.dbimporters.plugins.materialsproject.MaterialsProjectImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for the Materials Project.

__init__(**kwargs)[source]

Instantiate the MaterialsProjectImporter by setting up the Materials API (MAPI) connection details.

__module__ = 'aiida.tools.dbimporters.plugins.materialsproject'
_find(query, properties)[source]

Query the database with a given dictionary of query parameters

Parameters

query – a dictionary with the query parameters

_properties = 'structure'
_supported_keywords = None
_verify_api_key()[source]

Verify the supplied API key by issuing a request to Materials Project.

property api_key

Return the API key configured for the importer

property get_supported_keywords

Returns the list of all supported query keywords

Returns

list of strings

property properties

Return the properties that will be queried

query(**kwargs)[source]

Query the database with a given dictionary of query parameters for a given properties

Parameters
  • query – a dictionary with the query parameters

  • properties – the properties to query

setup_db(**kwargs)[source]

Setup the required parameters to the REST API

class aiida.tools.dbimporters.plugins.materialsproject.MaterialsProjectSearchResults(results, return_class)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

A collection of MaterialsProjectEntry query result entries.

Parameters

results – query result entry dictionary

Return_class

the class associated with each

__init__(results, return_class)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.materialsproject'
_db_name = 'Materials Project'
_db_uri = 'https://materialsproject.org'
_get_source_dict(result_dict)[source]

Return the source information dictionary of an Materials Project query result entry

Parameters

result_dict – query result entry dictionary

_get_url(result_dict)[source]

Return the permanent URI of the result entry

Parameters

result_dict – query result entry dictionary

_material_base_url = 'https://materialsproject.org/materials/'
_version = '2019-11-15 18:28:37.031731'
class aiida.tools.dbimporters.plugins.mpds.ApiFormat[source]

Bases: enum.Enum

An enumeration.

CIF = 'cif'
JSON = 'json'
__module__ = 'aiida.tools.dbimporters.plugins.mpds'
class aiida.tools.dbimporters.plugins.mpds.MpdsCifEntry(url, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry, 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

__init__(url, **kwargs)[source]

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

__module__ = 'aiida.tools.dbimporters.plugins.mpds'
class aiida.tools.dbimporters.plugins.mpds.MpdsDbImporter(url=None, api_key=None)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for the Materials Platform for Data Science (MPDS)

__init__(url=None, api_key=None)[source]

Instantiate the MpdsDbImporter by setting up the API connection details

Parameters
  • url – the full base url of the REST API endpoint

  • api_key – the API key to be used for HTTP requests

__module__ = 'aiida.tools.dbimporters.plugins.mpds'
_api_key = None
_collection = 'structures'
_pagesize = 1000
_supported_keywords = ['props', 'elements', 'classes', 'lattices', 'formulae', 'sgs', 'protos', 'aeatoms', 'aetype', 'authors', 'codens', 'years']
_url = 'https://api.mpds.io/v0/download/facet'
property api_key

Return the API key configured for the importer

property collection

Return the collection that will be queried

find(query, fmt=<ApiFormat.JSON: 'json'>)[source]

Query the database with a given dictionary of query parameters

Parameters

query – a dictionary with the query parameters

get(fmt=<ApiFormat.JSON: 'json'>, **kwargs)[source]

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

Parameters
  • fmt – the format of the response, ‘cif’ or json’ (default)

  • kwargs – parameters for the GET request

get_id_from_cif(cif)[source]

Extract the entry id from the string formatted cif response of the MPDS API

Parameters

cif – string representation of the cif file

Returns

entry id of the cif file or None if could not be found

get_response_content(response, fmt=<ApiFormat.JSON: 'json'>)[source]

Analyze the response of an HTTP GET request, verify that the response code is OK and return the json loaded response text

Parameters

response – HTTP response

Raises
  • RuntimeError – HTTP response is not 200

  • ValueError – HTTP response 200 contained non zero error message

property get_supported_keywords

Returns the list of all supported query keywords

Returns

list of strings

property pagesize

Return the pagesize set for the importer

query(query, collection=None)[source]

Query the database with a given dictionary of query parameters for a given collection

Parameters
  • query – a dictionary with the query parameters

  • collection – the collection to query

setup_db(url=None, api_key=None, collection=None)[source]

Setup the required parameters for HTTP requests to the REST API

Parameters
  • url – the full base url of the REST API endpoint

  • api_key – the API key to be used for HTTP requests

property structures

Access the structures collection in the MPDS

property url

Return the base url configured for the importer

class aiida.tools.dbimporters.plugins.mpds.MpdsEntry(url, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbEntry

Represents an MPDS database entry

__init__(url, **kwargs)[source]

Set the class license from the source dictionary

__module__ = 'aiida.tools.dbimporters.plugins.mpds'
class aiida.tools.dbimporters.plugins.mpds.MpdsSearchResults(results, return_class=None)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

A collection of MpdsEntry query result entries

__init__(results, return_class=None)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.mpds'
_db_name = 'Materials Platform for Data Science'
_db_uri = 'https://mpds.io/'
_get_source_dict(result_dict)[source]

Return the source information dictionary of an MPDS query result entry

Parameters

result_dict – query result entry dictionary

_get_url(result_dict)[source]

Return the permanent URI of the result entry

Parameters

result_dict – query result entry dictionary

_return_class

alias of MpdsEntry

class aiida.tools.dbimporters.plugins.mpds.StructuresCollection(engine)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'aiida.tools.dbimporters.plugins.mpds', '__init__': <function StructuresCollection.__init__>, 'engine': <property object>, 'find': <function StructuresCollection.find>, '__dict__': <attribute '__dict__' of 'StructuresCollection' objects>, '__weakref__': <attribute '__weakref__' of 'StructuresCollection' objects>, '__doc__': None})
__init__(engine)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.mpds'
__weakref__

list of weak references to the object (if defined)

property engine

Return the query engine

find(query, fmt=<ApiFormat.JSON: 'json'>)[source]

Query the structures collection with a given dictionary of query parameters

Parameters

query – a dictionary with the query parameters

class aiida.tools.dbimporters.plugins.mpod.MpodDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for Material Properties Open Database.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.mpod'
_keywords = {'authors': ['publ_author', <function MpodDbImporter._str_clause>], 'cod_id': ['cod_code', <function MpodDbImporter._str_clause>], 'element': ['element', None], 'formula': ['formula', <function MpodDbImporter._str_clause>], 'phase_name': ['phase_name', <function MpodDbImporter._str_clause>]}
_str_clause(key, alias, values)[source]

Returns part of HTTP GET query for querying string fields.

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 in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.mpod.MpodSearchResults.

query_get(**kwargs)[source]

Forms a HTTP GET query for querying the MPOD database. May return more than one query in case an intersection is needed.

Returns

a list containing strings for HTTP GET statement.

setup_db(query_url=None, **kwargs)[source]

Changes the database connection details.

class aiida.tools.dbimporters.plugins.mpod.MpodEntry(uri, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry

Represents an entry from MPOD.

__init__(uri, **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.mpod.MpodEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.mpod'
class aiida.tools.dbimporters.plugins.mpod.MpodSearchResults(results)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

Results of the search, performed on MPOD.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__len__()[source]
__module__ = 'aiida.tools.dbimporters.plugins.mpod'
_base_url = 'http://mpod.cimav.edu.mx/datafiles/'
_get_source_dict(result_dict)[source]

Returns a dictionary, which is passed as kwargs to the created DbEntry instance, describing the source of the entry.

Parameters

result_dict – dictionary, describing an entry in the results.

_get_url(result_dict)[source]

Returns an URL of an entry CIF file.

Parameters

result_dict – dictionary, describing an entry in the results.

class aiida.tools.dbimporters.plugins.nninc.NnincDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for NNIN/C Pseudopotential Virtual Vault.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.nninc'
_keywords = {'element': ['element', None], 'pseudopotential_class': ['frmspclass', <function NnincDbImporter._str_clause>], 'xc_approximation': ['frmxcprox', <function NnincDbImporter._str_clause>], 'xc_type': ['frmxctype', <function NnincDbImporter._str_clause>]}
_str_clause(key, alias, values)[source]

Returns part of HTTP GET query for querying string fields.

get_supported_keywords()[source]

Returns the list of all supported query keywords.

Returns

list of strings

query(**kwargs)[source]

Performs a query on the NNIN/C Pseudopotential Virtual Vault using keyword = value pairs, specified in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.nninc.NnincSearchResults.

query_get(**kwargs)[source]

Forms a HTTP GET query for querying the NNIN/C Pseudopotential Virtual Vault.

Returns

a string with HTTP GET statement.

setup_db(query_url=None, **kwargs)[source]

Changes the database connection details.

class aiida.tools.dbimporters.plugins.nninc.NnincEntry(uri, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.UpfEntry

Represents an entry from NNIN/C Pseudopotential Virtual Vault.

__init__(uri, **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.nninc.NnincEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.nninc'
class aiida.tools.dbimporters.plugins.nninc.NnincSearchResults(results)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

Results of the search, performed on NNIN/C Pseudopotential Virtual Vault.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__len__()[source]
__module__ = 'aiida.tools.dbimporters.plugins.nninc'
_base_url = 'http://nninc.cnf.cornell.edu/psp_files/'
_get_source_dict(result_dict)[source]

Returns a dictionary, which is passed as kwargs to the created DbEntry instance, describing the source of the entry.

Parameters

result_dict – dictionary, describing an entry in the results.

_get_url(result_dict)[source]

Returns an URL of an entry CIF file.

Parameters

result_dict – dictionary, describing an entry in the results.

class aiida.tools.dbimporters.plugins.oqmd.OqmdDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbImporter

Database importer for Open Quantum Materials Database.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.oqmd'
_keywords = {'element': ['element', None]}
_str_clause(key, alias, values)[source]

Returns part of HTTP GET query for querying string fields.

get_supported_keywords()[source]

Returns the list of all supported query keywords.

Returns

list of strings

query(**kwargs)[source]

Performs a query on the OQMD database using keyword = value pairs, specified in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.oqmd.OqmdSearchResults.

query_get(**kwargs)[source]

Forms a HTTP GET query for querying the OQMD database.

Returns

a strings for HTTP GET statement.

setup_db(query_url=None, **kwargs)[source]

Changes the database connection details.

class aiida.tools.dbimporters.plugins.oqmd.OqmdEntry(uri, **kwargs)[source]

Bases: aiida.tools.dbimporters.baseclasses.CifEntry

Represents an entry from OQMD.

__init__(uri, **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.oqmd.OqmdEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.oqmd'
class aiida.tools.dbimporters.plugins.oqmd.OqmdSearchResults(results)[source]

Bases: aiida.tools.dbimporters.baseclasses.DbSearchResults

Results of the search, performed on OQMD.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__len__()[source]
__module__ = 'aiida.tools.dbimporters.plugins.oqmd'
_base_url = 'http://oqmd.org/materials/export/conventional/cif/'
_get_source_dict(result_dict)[source]

Returns a dictionary, which is passed as kwargs to the created DbEntry instance, describing the source of the entry.

Parameters

result_dict – dictionary, describing an entry in the results.

_get_url(result_dict)[source]

Returns an URL of an entry CIF file.

Parameters

result_dict – dictionary, describing an entry in the results.

class aiida.tools.dbimporters.plugins.pcod.PcodDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodDbImporter

Database importer for Predicted Crystallography Open Database.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.pcod'
_angle_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying lattice angles.

_composition_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying elements in formula fields.

_formula_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying formula fields.

_int_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying integer fields.

_keywords = {'a': ['a', <function PcodDbImporter._length_clause>], 'alpha': ['alpha', <function PcodDbImporter._angle_clause>], 'b': ['b', <function PcodDbImporter._length_clause>], 'beta': ['beta', <function PcodDbImporter._angle_clause>], 'c': ['c', <function PcodDbImporter._length_clause>], 'element': ['element', <function PcodDbImporter._composition_clause>], 'formula': ['formula', <function PcodDbImporter._formula_clause>], 'gamma': ['gamma', <function PcodDbImporter._angle_clause>], 'id': ['file', <function PcodDbImporter._int_clause>], 'number_of_elements': ['nel', <function PcodDbImporter._int_clause>], 'spacegroup': ['sg', <function PcodDbImporter._str_exact_clause>], 'text': ['text', <function PcodDbImporter._str_fuzzy_clause>], 'volume': ['vol', <function PcodDbImporter._volume_clause>]}
_length_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying lattice vector lengths.

_str_exact_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying string fields.

_str_fuzzy_clause(*args, **kwargs)[source]

Returns SQL query predicate for fuzzy querying of string fields.

_volume_clause(*args, **kwargs)[source]

Returns SQL query predicate for querying unit cell volume.

query(**kwargs)[source]

Performs a query on the PCOD database using keyword = value pairs, specified in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.pcod.PcodSearchResults.

query_sql(**kwargs)[source]

Forms a SQL query for querying the PCOD database using keyword = value pairs, specified in kwargs.

Returns

string containing a SQL statement.

class aiida.tools.dbimporters.plugins.pcod.PcodEntry(uri, db_name='Predicted Crystallography Open Database', db_uri='http://www.crystallography.net/pcod', **kwargs)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodEntry

Represents an entry from PCOD.

__init__(uri, db_name='Predicted Crystallography Open Database', db_uri='http://www.crystallography.net/pcod', **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.pcod.PcodEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.pcod'
_license = 'CC0'
class aiida.tools.dbimporters.plugins.pcod.PcodSearchResults(results)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodSearchResults

Results of the search, performed on PCOD.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.pcod'
_base_url = 'http://www.crystallography.net/pcod/cif/'
_get_url(result_dict)[source]

Returns an URL of an entry CIF file.

Parameters

result_dict – dictionary, describing an entry in the results.

Importer implementation for the TCOD.

class aiida.tools.dbimporters.plugins.tcod.TcodDbImporter(**kwargs)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodDbImporter

Database importer for Theoretical Crystallography Open Database.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.tcod'
query(**kwargs)[source]

Performs a query on the TCOD database using keyword = value pairs, specified in kwargs.

Returns

an instance of aiida.tools.dbimporters.plugins.tcod.TcodSearchResults.

class aiida.tools.dbimporters.plugins.tcod.TcodEntry(uri, db_name='Theoretical Crystallography Open Database', db_uri='http://www.crystallography.net/tcod', **kwargs)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodEntry

Represents an entry from TCOD.

__init__(uri, db_name='Theoretical Crystallography Open Database', db_uri='http://www.crystallography.net/tcod', **kwargs)[source]

Creates an instance of aiida.tools.dbimporters.plugins.tcod.TcodEntry, related to the supplied URI.

__module__ = 'aiida.tools.dbimporters.plugins.tcod'
_license = 'CC0'
class aiida.tools.dbimporters.plugins.tcod.TcodSearchResults(results)[source]

Bases: aiida.tools.dbimporters.plugins.cod.CodSearchResults

Results of the search, performed on TCOD.

__init__(results)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.tools.dbimporters.plugins.tcod'
_base_url = 'http://www.crystallography.net/tcod/'

Tests for IcsdDbImporter

class aiida.tools.dbimporters.plugins.test_icsd.TestIcsd(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests for the ICSD importer

__module__ = 'aiida.tools.dbimporters.plugins.test_icsd'
__unittest_skip__ = True
__unittest_skip_why__ = 'ICSD configuration in profile required'
setUp()[source]

Set up IcsdDbImporter for web and mysql db query.

test_dbquery_zero_results()[source]

check handling a zero result case

test_mysqldb()[source]

Test connection to Icsd mysql database.

test_server()[source]

Test Icsd intranet webinterface

test_web_collcode_155006()[source]

Query for the CIF code 155006, should return 1 result.

test_web_zero_results()[source]

No results should be obtained from year 3000.

aiida.tools.dbimporters.plugins.test_icsd.has_icsd_config()[source]
Returns

True if the currently loaded profile has a ICSD configuration

aiida.tools.dbimporters.plugins.test_icsd.has_mysqldb()[source]
Returns

True if the ase module can be imported, False otherwise.

Module that contains the class definitions necessary to offer support for queries to Materials Project.

class aiida.tools.dbimporters.plugins.test_materialsproject.TestMaterialsProject(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Contains the tests to verify the functionality of the Materials Project importer functions.

__module__ = 'aiida.tools.dbimporters.plugins.test_materialsproject'
test_invalid_api_key()[source]

Test if Materials Project rejects an invalid API key and that we catch the error. Please enable the test in the profile configurator.

unittest = <module 'unittest' from '/home/docs/.pyenv/versions/3.7.3/lib/python3.7/unittest/__init__.py'>
aiida.tools.dbimporters.plugins.test_materialsproject.run_materialsproject_api_tests()[source]