1. DataBase
- class pharmaforge.database.DataBase[source]
Bases:
object
A class to represent a pymongo database of molecules
Methods
add_data
(filepath)Add data to the database
find_all_unique
([aslist])Find all unique keys in the entire database
Find all empty molecules in the database
find_molecule
(mol_key[, verbose])Find a molecule in the database
find_shared_molecules
(db_key1, db_key2)Find all shared molecules between two databases
find_unique
(db_key)Find all unique keys in an individual database
obtain_feature
(feature_key[, db_key])Obtain a feature from the database
- add_data(filepath)[source]
Add data to the database
- Parameters:
filepath (str or Path) – The name or path to the data file to add. The file must be in hdf5 format.
- Return type:
None
:raises ValueError : If the file type is not hdf5: :raises FileNotFoundError : If the file is not found, or the path does not exist:
- find_all_unique(aslist=False)[source]
Find all unique keys in the entire database
- Parameters:
aslist (bool) – Whether to return the unique keys as a list or a dictionary
- Returns:
unique – A dictionary of all unique keys in the database
- Return type:
dictionary of lists
- find_empty_molecules()[source]
Find all empty molecules in the database
- Returns:
empty – A dictionary of all empty molecules in the database
- Return type:
dictionary of lists
Find all shared molecules between two databases
- class pharmaforge.database.Loader(client_addr='mongodb://localhost:27017/', database_name=None, collection_name=None)[source]
Bases:
object
A class ot access the database, once it has been put into the mongoDB
- Parameters:
- client
The MongoDB client
- Type:
pymongo.MongoClient
- db
The database object
- collection
The collection object
Methods
list_collection_entry
([entry])List all the data in the selected entry of the collection
list_collections
([verbose])List all collections in the selected database
List all database names in the client
select_collection
(collection_name)Select a collection from the database
select_db
(db_name[, verbose])Select a database from the client
- list_collection_entry(entry=None)[source]
List all the data in the selected entry of the collection
- Parameters:
entry (str) – The name of the entry to list. If None, all entries will be listed
- Return type:
None
- list_db_names()[source]
List all database names in the client
- Parameters:
None
- Returns:
db_names – A list of all database names in the client
- Return type: