d3tales_api.D3database package
Submodules
d3tales_api.D3database.d3database module
- class d3tales_api.D3database.d3database.BackDB(collection_name=None, instance=None, create_hash=False, last_updated=False)[source]
Bases:
D3Database
Class for accessing the backend D3TaLES database Copyright 2021, University of Kentucky
- __init__(collection_name=None, instance=None, create_hash=False, last_updated=False)[source]
- Parameters
collection_name – str, name of collection
instance – dict, instance to insert or validate
create_hash – bool, generate new instance hash id if True
last_updated – bool, insert attribute last_updated to instance with the current date and time if True
- class d3tales_api.D3database.d3database.D3Database(database=None, collection_name=None, instance=None, schema_layer='', schema_directory=None, public=None, schema_db=None, default_id=None, validate_schema=True)[source]
Bases:
object
Base class for connecting to a database Copyright 2021, University of Kentucky
- __init__(database=None, collection_name=None, instance=None, schema_layer='', schema_directory=None, public=None, schema_db=None, default_id=None, validate_schema=True)[source]
- Parameters
database – str, name of database (should be a key in the DB_INFO_FILE)
collection_name – str, name of collection
instance – dict, instance to insert or validate
schema_layer – str, schema layer
schema_directory – str, schema directory
public – bool, instance is marked as public if True
schema_db – str, database containing schema
default_id – str, default instance ID
validate_schema – bool, validate schema if True
- array_checker(field_path, _id)[source]
Create empty array in filed if this field does not already exists. Prepare for set insertion (avoid duplicates)
- Parameters
field_path – str, path to check
_id – str, instance ID
- static dot2dict(dot_dict)[source]
Convert a dotted dictionary to a nested dictionary
- Parameters
dot_dict – dotted dictionary
- Returns
nested final dictionary
- field_checker(entry, field)[source]
Check if field exists and return result or {}
- Parameters
entry – value
field – field name
- Returns
{} or the match
- insert(_id, nested=False, update_public=True, instance=None, override_lists=False)[source]
Upserts a dictionary into a collection
- Parameters
_id – str, _id for insertion
nested – bool, insert nested attributes if True
update_public – bool, update the public status if true
instance – dict, instance to be inserted
override_lists – bool, override existing lists in insertion if True
- make_query(query: Optional[dict] = None, projection: Optional[dict] = None, output='pandas', multi=True, limit=200)[source]
Make MongoDB database query
- Parameters
query – dict, query
projection – dict, projection
output – str, output type
multi – bool, return multiple query responses if True
limit – int, limit to the number of responses the query will return
- Returns
A dataframe if output=”pandas”
A list if multi=False and a pymongo dursor if multi=True; output != “pandas
- class d3tales_api.D3database.d3database.DBconnector(db_information: dict)[source]
Bases:
object
Class to retrieve a collection from a database and insert new entry. Requires a db_infos.json file with credentials Copyright 2021, University of Kentucky
- class d3tales_api.D3database.d3database.Expflow(collection_name='experimentation', instance=None, create_hash=False)[source]
Bases:
D3Database
Class for accessing the ExpFlow experimental database Copyright 2021, University of Kentucky
- class d3tales_api.D3database.d3database.FrontDB(schema_layer=None, instance=None, _id=None, smiles=None, group=None, collection_name='base', generate_mol=False, public=None)[source]
Bases:
D3Database
Class for accessing the frontend D3TaLES database Copyright 2021, University of Kentucky
- __init__(schema_layer=None, instance=None, _id=None, smiles=None, group=None, collection_name='base', generate_mol=False, public=None)[source]
- Parameters
schema_layer – str, schema layer
instance – dict, instance to insert or validate
_id – str, default instance ID
collection_name – str, name of collection
public – bool, instance is marked as public if True
smiles – str, SMILES string for a new molecule
group – str, origin group for instance
generate_mol – bool, generate new molecule instance if True
- class d3tales_api.D3database.d3database.ParamsDB(database='frontend', collection_name=None, instance=None, schema_directory=None, _id=None, update=False)[source]
Bases:
D3Database
Class for accessing the parameters D3TaLES database Copyright 2021, University of Kentucky
- __init__(database='frontend', collection_name=None, instance=None, schema_directory=None, _id=None, update=False)[source]
- Parameters
database – str, name of database (should be a key in the DB_INFO_FILE)
collection_name – str, name of collection
instance – dict, instance to insert or validate
schema_directory – str, schema directory
_id – str, parameter ID
update – bool, create new parameter ID if False
- class d3tales_api.D3database.d3database.QueryDB(query: Optional[dict] = None, projection: Optional[dict] = None, collection_name=None, db_file=None, output='pandas', multi=True)[source]
Bases:
object
Class to query the database. Use mongoDB style query and projections. Copyright 2021, University of Kentucky
- __init__(query: Optional[dict] = None, projection: Optional[dict] = None, collection_name=None, db_file=None, output='pandas', multi=True)[source]
- Parameters
query – dict, query
projection – dict, projection
collection_name – str, name of collection
db_file – str, database info file
output – str, output type
- class d3tales_api.D3database.d3database.RobotStatusDB(apparatus_type: str, _id: Optional[str] = None, instance: Optional[dict] = None, override_lists: bool = True, wflow_name: Optional[str] = None)[source]
Bases:
D3Database
Class for accessing the Robot Status database Copyright 2021, University of Kentucky
- __init__(apparatus_type: str, _id: Optional[str] = None, instance: Optional[dict] = None, override_lists: bool = True, wflow_name: Optional[str] = None)[source]
Initiate class :param apparatus_type: str, name of apparatus :param _id: str, _id :param instance: dict, instance to insert or validate :param override_lists: bool, :param wflow_name: str, name of active workflow; checks if database instance has appropriate wflow_name if set
- property exists
d3tales_api.D3database.dft_calculation_list module
d3tales_api.D3database.info_from_smiles module
- class d3tales_api.D3database.info_from_smiles.GenerateMolInfo(smiles, origin_group='', names=[], extra_info=True, database='frontend', schema_name='mol_info', ground_spin=None, ground_charge=None)[source]
Bases:
object
Generate json object for insertion from smiles string Copyright 2021, University of Kentucky
- Parameters
names – list of names for molecule
smiles – smiles string
origin_group – which group the molecule comes from
- Returns
mol_info class object
- d3tales_api.D3database.info_from_smiles.base64_to_image(base64_str, image_path=None)[source]
Produce python Image object from base 64 string representation of image
- Parameters
base64_str – base64 string representing image
image_path – path for image to be saved (optional)
- Returns
python Image object
d3tales_api.D3database.restapi module
- class d3tales_api.D3database.restapi.D3talesData(username='', password='')[source]
Bases:
object
- __init__(username='', password='')[source]
This class pulls data from the D3Tales database and outputs plots or Pandas dataframes
- Parameters
username – D3TaLES website username (must have REST API permissions)
password – D3TaLES website password (must have REST API permissions)
- get_master_df(master_fn='d3tales_props.csv')[source]
Get all major properties from D3TaLES database.
- Parameters
master_fn – str, filepath to CSV file in which to save data
uses the D3database FrontDB module by default, which required the DB_INFO_FILE to be defined to work.
- Returns
pandas DataFrame with all data
- get_prop_data(query, max_cutoff=None, min_cutoff=None, database='molecules', limit=0)[source]
Get property data from D3TaLES database based on RESTAPI query
- Parameters
query – str, D3TaLES REST API query
max_cutoff – float, maximum value to return for specified property
min_cutoff – float, minimum value to return for specified property
database – str, name of database to query
limit – limit query items to return
- Returns
pandas DataFrame with query data
- hist_1d(query, **kwargs)[source]
Plot histogram data from D3TaLES database based on RESTAPI query
- Parameters
query – str, D3TaLES REST API query
- Returns
seaborn histogram plot
- hist_2d(query1, query2, db1='molecules', db2='molecules', **kwargs)[source]
Plot histogram data from D3TaLES database based on RESTAPI query
- Parameters
query1 – str, D3TaLES REST API query for x axis
query2 – str, D3TaLES REST API query for y axis
db1 – str, name of database for query1
db2 – str, name of database for query2
- Returns
seaborn 2D histogram plot
- class d3tales_api.D3database.restapi.RESTAPI(method=None, url='https://d3tales.as.uky.edu', endpoint=None, login_endpoint='login', username='', password='', upload_file=None, params=None, expected_endpoint=None, return_json=False)[source]
Bases:
object
- __init__(method=None, url='https://d3tales.as.uky.edu', endpoint=None, login_endpoint='login', username='', password='', upload_file=None, params=None, expected_endpoint=None, return_json=False)[source]
Upload a file to through d3tales.as.uky.edu file upload feature.
- Parameters
method – str, html method (such as post or get)
url – str, base url
endpoint – str, post or get endpoint url (not containing base url)
login_endpoint – str, login url (not containing base url)
username – str, user username
password – str, user password
upload_file – str, path to file to be uploaded
params – dict, form parameters for post
return_json – bool, get or post method returns json if true
Copyright 2021, University of Kentucky
- property cookies
- property csrftoken
d3tales_api.D3database.schema2class module
- class d3tales_api.D3database.schema2class.Schema2Class(database=None, schema_name=None, schema_directory=None, named_only=False)[source]
Bases:
object
Get D3TaLES schema from GitHub and load it to a class Copyright 2021, University of Kentucky
- __init__(database=None, schema_name=None, schema_directory=None, named_only=False)[source]
- Parameters
database – str, database name
schema_name – str, schema name
schema_directory – str, schema directory
named_only – If true, only properties with an actual title attribute will be included in the resulting namespace
d3tales_api.D3database.schema2model module
Json Schema to Django Model
- d3tales_api.D3database.schema2model.determine_model_name(model_id=None, filename=None)[source]
Get the model name
- Parameters
model_id – str, model id
filename – str, filename
- Returns
str, model name