stk.ValueDatabase
- class stk.ValueDatabase[source]
Bases:
object
Abstract base class for storing of molecular property values.
Examples
Subclass Implementation
The source of any of the subclasses, listed in
molecule_value_database
, can serve as good examples.Iterating Through Entries in the Database
The
MoleculeDatabase.get_all()
andConstructedMoleculeDatabase.get_all()
methods can be used to iterate through all of the database’s entries, which can then be used to access values in theValueDatabase
import pymongo client = pymongo.MongoClient() molecule_db = stk.MoleculeMongoDb(client) value_db = stk.ValueMongoDb( mongo_client=client, collection='atom_counts', ) molecule = stk.BuildingBlock('BrBr') molecule_db.put(molecule) value_db.put(molecule, molecule.get_num_atoms()) for molecule in molecule_db.get_all(): try: value = value_db.get(molecule) print(value) except KeyError: # In case molecule is not in value_db. pass
2
Methods
Get the stored value for molecule.
Put a value into the database.