FPSim2.io package

Submodules

FPSim2.io.chem module

FPSim2.io.chem.get_bounds_range(query: numpy.ndarray, threshold: Optional[float], a: Optional[float], b: Optional[float], ranges: list, search_type: str) → Union[Tuple[int, int], Tuple]
FPSim2.io.chem.get_fp_length(fp_type: str, fp_params: Dict[str, Any]) → int

Returns the FP length given the name of the FP function and it’s parameters.

Parameters
  • fp_type (str) – Name of the function used to generate the fingerprints.

  • fp_params (dict) – Parameters used to generate the fingerprints.

Returns

fp_length – fp length of the fingerprint.

Return type

int

FPSim2.io.chem.get_mol_supplier(io_source: Any) → Optional[Callable[[…], Iterable[Tuple[int, rdkit.Chem.rdchem.Mol]]]]

Returns a mol supplier depending on the object type and file extension.

Parameters
  • mols_source (str or iterable) – .smi or .sdf filename or iterable.

  • fps_sort (bool) – Whether if the FPs should be sorted or not.

Returns

function that will read the molecules from the input.

Return type

callable

FPSim2.io.chem.it_mol_supplier(iterable: Iterable, gen_ids: bool, **kwargs) → Iterable[Tuple[int, rdkit.Chem.rdchem.Mol]]

Generator function that reads from iterables.

Parameters
  • iterable (iterable) – Python iterable storing molecules.

  • gen_ids (bool) – generate ids or not.

Yields

tuple – int id and rdkit mol.

FPSim2.io.chem.load_molecule(mol_string: str) → rdkit.Chem.rdchem.Mol

Reads SMILES, molblock or InChI and returns a RDKit mol.

Parameters

mol_string (str) – SMILES, molblock or InChI.

Returns

mol – RDKit molecule.

Return type

ROMol

FPSim2.io.chem.rdmol_to_efp(rdmol: rdkit.Chem.rdchem.Mol, fp_func: str, fp_params: Dict[str, Any]) → List[int]
FPSim2.io.chem.sdf_mol_supplier(filename: str, gen_ids: bool, **kwargs) → Iterable[Tuple[int, rdkit.Chem.rdchem.Mol]]

Generator function that reads from a .sdf file.

Parameters
  • filename (str) – .sdf filename.

  • gen_ids (bool) – generate ids or not.

Yields

tuple – int id and rdkit mol.

FPSim2.io.chem.smi_mol_supplier(filename: str, gen_ids: bool, **kwargs) → Iterable[Tuple[int, rdkit.Chem.rdchem.Mol]]

Generator function that reads from a .smi file.

Parameters
  • filename (str) – .smi file name.

  • gen_ids (bool) – generate ids or not.

Yields

tuple – int id and rdkit mol.

Module contents