Python Submodules#
app.modules.npscorer module#
- app.modules.npscorer.get_np_model(model_path)[source]#
Load the NP model from a pickle file.
- Return type:
dict
- Parameters:
model_path (str): Path to the pickled model file.
- Returns:
dict: The NP model.
- app.modules.npscorer.get_np_score(molecule)[source]#
Convert SMILES string to RDKit molecule object and generate the NP Score.
- Return type:
str
- Parameters:
molecule (Chem.Mol): RDKit molecule object.
- Returns:
str: NP Score as a formatted string or “invalid” if conversion fails.
- app.modules.npscorer.score_mol(molecule)[source]#
Calculate the Natural Product Likeness score for a given molecule.
- Return type:
float
- Parameters:
molecule (rdkit.Chem.Mol): RDKit molecule object.
- Returns:
float: NP-Likeness score in the range -5 to 5.
- app.modules.npscorer.score_mol_with_confidence(molecule)[source]#
Calculate NP-likeness score and confidence for a molecule.
- Return type:
dict
- Args:
molecule (rdkit.Chem.rdchem.Mol): The input molecule.
- Returns:
- dict: A dictionary containing NP-likeness score and confidence.
‘nplikeness’ (float): The NP-likeness score.
‘confidence’ (float): The confidence in the score.
app.modules.depiction module#
app.modules.decimer module#
- app.modules.decimer.convert_image(path)[source]#
Convert a GIF image to PNG format, resize, and place on a white background.
- Return type:
str
- Args:
path (str): The path to the GIF image file.
- Returns:
str: The path of the converted and processed PNG image file.
- app.modules.decimer.get_predicted_segments(path)[source]#
Get predicted SMILES representations for segments within an image.
This function takes an image path, extracts segments, predicts SMILES representations for each segment, and returns a concatenated string of predicted SMILES.
- Return type:
str
- Args:
path (str): Path to the input image file.
- Returns:
- str: Predicted SMILES representations joined by ‘.’ if segments are detected,
otherwise returns a single predicted SMILES for the whole image.
- app.modules.decimer.get_predicted_segments_from_file(content, filename)[source]#
Takes an image file path and returns a set of paths and image names of segmented images.
- Return type:
tuple
- Args:
input_path (str): the path of an image.
- Returns:
image_name (str): image file name. segments (list): a set of segmented images.
app.modules.classyfire module#
- async app.modules.classyfire.classify(smiles)[source]#
This function queries the ClassyFire API to classify a chemical compound represented by a SMILES string.
- Return type:
dict
- Args:
smiles (str): A SMILES string representing the chemical compound.
- Returns:
dict: A dictionary containing the response from the ClassyFire API.
- Raises:
requests.RequestException: If there’s an issue with the API request.
- async app.modules.classyfire.result(id)[source]#
Fetches JSON response from the ClassyFire API for a given ID.
This function takes an ID and retrieves the corresponding chemical classification information from the ClassyFire API in JSON format.
- Return type:
dict
- Args:
id (int): The ID associated with the chemical compound.
- Returns:
- dict: A dictionary containing ClassyFire classification results.
The structure of the dictionary includes various classification details of the chemical compound, such as class, superclass, direct parent, etc.
- Raises:
- requests.exceptions.RequestException: If there is an issue with the HTTP request
to the ClassyFire API.