Core

Core module.

The main algorithm functions and classes are included in this module.

  • ilp_solvers:

    Module with the structure of the integer linear programming (ILP) solvers.

  • frag_classes:

    Module with the classes that define the fragmentation models.

  • check_atoms_fragments_presence:

    Check function to corroborate if ILP algorithm is necessary to solve a molecule.

  • instantiate_mol_object:

    Function to instantiate a RDKit molecule object from a SMILES string, name or rdkit mol object.

check_atoms_fragments_presence(molecule: Mol, fragments: dict) tuple[bool, ndarray][source]

Find overlapped atoms and free atoms.

Check the detected fragments to find the atoms that appears in more than one fragment (overlapping), and the atoms that are not present in any fragment (free atoms). Returning two np.ndarray with the indexes of the overlapping and free atoms.

Example of a fragments dictionary that not presents overlapping atoms. For example N-hexane:

{
    'CH3_0': (0,),
    'CH3_1': (5,),
    'CH2_0': (1,),
    'CH2_1': (2,),
    'CH2_2': (3,),
    'CH2_3': (4,)
}

Example of a fragments dictionary that presents overlapping atoms. For example toluene:

{
    'CH3_0': (0,),
    'ACH_0': (2,),
    'ACH_1': (3,),
    'ACH_2': (4,),
    'ACH_3': (5,),
    'ACH_4': (6,),
    'AC_0': (1,),
    'ACCH3_0': (1, 0)
}
Parameters:
  • molecule (Chem.rdchem.Mol) – RDKit molecule object.

  • fragments (dict) – Dictionary containing the fragments detected in the molecule. The keys are the group names and the values are the indexes of the atoms in the group.

Returns:

Overlapping atoms indexes and free atoms indexes.

Return type:

tuple[np.ndarray, np.ndarray]

instantiate_mol_object(identifier: str | Mol, identifier_type: str = 'name') Mol[source]

Instantiate a RDKit Mol object from molecule’s name, SMILES or mol.

In case that the input its already a RDKit Mol object, the function will return the input object.

Parameters:
  • identifier (str or rdkit.Chem.rdchem.Mol) – Identifier of a molecule (name, SMILES or rdkit.Chem.rdchem.Mol). Example: hexane or CCCCCC for name or SMILES respectively.

  • identifier_type (str, optional) – Use ‘name’ to search a molecule by name, ‘smiles’ to provide the molecule SMILES representation or ‘mol’ to provide a rdkit.Chem.rdchem.Mol object, by default “name”.

Returns:

RDKit Mol object.

Return type:

rdkit.Chem.rdchem.Mol