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.depiction.get_cdk_depiction(molecule, molSize=(512, 512), rotate=0, CIP=True, unicolor=False)[source]#

This function takes the user input SMILES and Depicts it.

using the CDK Depiction Generator.

Args:

molecule (any): CDK IAtomContainer parsed from SMILES string given by the user.

Returns:

image (SVG): CDK Structure Depiction as an SVG image.

app.modules.depiction.get_rdkit_depiction(molecule, molSize=(512, 512), rotate=0, kekulize=True)[source]#

This function takes the user input SMILES and Canonicalize it using the.

RDKit.

Args:

molecule (Chem.Mol): RDKit molecule object.

Returns:

image (SVG): RDKit Structure Depiction as an SVG image.

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.decimer.get_segments(path)[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.

app.modules.alldescriptors module#

app.modules.all_descriptors.get_all_cdk_descriptors(molecule)[source]#

Calculate a set of molecular descriptors using the CDK.

This function takes a SMILES string as input and calculates various molecular descriptors using the CDK. The calculated descriptors are returned as a tuple.

Return type:

Union[tuple, str]

Args:

molecule (IAtomContainer): CDK molecule object.

Returns:

tuple: A tuple containing calculated molecular descriptors. If an error occurs during processing, an error message is returned.

app.modules.all_descriptors.get_all_rdkit_descriptors(molecule)[source]#

Calculate a selected set of molecular descriptors using RDKit.

This function takes an input SMILES string and calculates various molecular descriptors using RDKit.

Return type:

Union[tuple, str]

Args:

molecule (Chem.mol): RDKit molecule object.

Returns:

tuple: A tuple containing calculated molecular descriptors. If an error occurs during processing, an error message is returned.

app.modules.all_descriptors.get_cdk_rdkit_combined_descriptors(smiles)[source]#

Calculate a selected set of molecular descriptors using CDK and RDKit.

for a given SMILES string.

Return type:

Union[dict, str]

Args:

smiles (str): A SMILES string representing a chemical compound.

Returns:
Union[Dict[str, Tuple[float, float]], str]:
  • If successful, a dictionary containing calculated descriptors. Each descriptor is a key mapped to a tuple of its values calculated by RDKit and CDK.

  • If unsuccessful due to descriptor calculation errors, returns an error message as a string.

app.modules.all_descriptors.get_table(tanimoto_values)[source]#

Convert a list of Tanimoto similarity values into an HTML table.

Return type:

str

Args:

tanimoto_values (list): A list of lists containing Tanimoto similarity values.

Returns:

str: HTML representation of the table.

app.modules.all_descriptors.get_tanimoto_similarity(smileslist, toolkit='cdk')[source]#

Calculate the Tanimoto similarity index between pairs of SMILES strings.

This function takes a list of SMILES strings, splits them, and calculates the Tanimoto similarity index between every pair of SMILES strings.

Return type:

list

Args:

smileslist (str): A comma-separated list of SMILES strings. toolkit (str, optional): The toolkit to use for calculating similarity.Can be “cdk” (Chemistry Development Kit) or “rdkit” (RDKit). Defaults to “cdk”.

Returns:

list: A matrix containing Tanimoto similarity scores.Rows and columns correspond to SMILES strings in the input list.

Raises:

ValueError: If an unsupported toolkit is provided.