A connection to the ASE AtomsDatabase
- class madas.backend.ASE_backend.ASEBackend(filename='materials_database.db', filepath='data', make_dirs=True, key_name='mid', log=None)
Database backend that connects to a ASEAtomsDatabase object.
- add_many(materials: List[Material]) None
Add many materials to the database.
Arguments:
- materials: List[madas.Material]
List of material objects to be added to the database
Return:
None
- add_single(material: Material) None
Add a single material to the database.
Arguments:
- material: madas.Material
Material object to be added to the database
Return:
None
- get_by_id(db_id)
Get a single entry by the integer valued database id, i.e. the count of when the material was added.
WARNING: Different than the ase.AtomsDatabase, this index starts with entry 0.
Arguments
- db_id: int
Index of material in database
Returns
- material: madas.Material
Material object associated with the database entry
- KeyError
If no material has the specified index, this error is raised.
- get_length()
Return the length of the database, i.e. the number of entries.
- get_many(mids: List[str] | None = None, **kwargs) List[Material]
Retrieve many entries from the database.
Keyword arguments
- mids: List[str]
default: None
List of material identifiers used in the database and madas.Material objects
Additional kwargs are used to retrieve entries from the database, e.g. if several Material objects have a specific property value.
Returns:
- materials: List[madas.Material]
List of Material objects of the selected database entries
Raises:
- ValueError
If neither a mid nor a keyword argument is given, this error is raised.
- KeyError
If no material has the specified mid or property values, this error is raised.
- get_single(mid: str | None = None, **kwargs) Material
Retrieve a single entry from the database.
Keyword arguments
- mid: str
default: None
Material identifier used in the database and madas.Material objects
Additional kwargs are used to retrieve entries from the database, e.g. if a single Material object has a specific property value.
Returns:
- material: madas.Material
Material object of the selected database entry
Raises:
- ValueError
If neither a mid nor a keyword argument is given, this error is raised.
- AssertionError
If more than one row matches the keyword arguments, the ASE AtomsDatabase raises this error.
- KeyError
If no material has the specified mid or property values, this error is raised.
- has_entry(entry_id: str) bool
Test if an entry with given id exists in the database.
Arguments:
- entry_id: str
Material identifier of the expected entry.
Returns:
- has_entry: bool
True if an entry with this key exists, False else
- update_many(mids: List[str] | None = None, kwargs_list: List[dict] = []) None
Update a set of entries from the database.
Keyword arguments
- mids: List[str]
default: None
List of material identifiers used in the database and madas.Material objects
- kwargs_list: List[dict]
default: []
List of dictionaries that contain the data that should be written as properties to the database.
Returns:
None
Raises:
- ValueError
If neither a mid nor a keyword argument is given, this error is raised.
- AssertionError
If more than one row matches the keyword arguments, the ASE AtomsDatabase raises this error.
- KeyError
If no material has the specified mid or property values, this error is raised.
- update_metadata(**kwargs) None
Update database metadata.
Keyword arguments are directly written to database metadata.
Returns:
None
- update_single(mid: str | None = None, **kwargs) None
Update a single entry from the database.
Keyword arguments
- mid: str
default: None
Material identifier used in the database and madas.Material objects
Additional kwargs are used to identify entries from the database, e.g. if a single Material object has a specific property value.
Returns:
None
Raises:
- ValueError
If neither a mid nor a keyword argument is given, this error is raised.
- AssertionError
If more than one row matches the keyword arguments, the ASE AtomsDatabase raises this error.
- KeyError
If no material has the specified mid or property values, this error is raised.