Skip to content

Commit

Permalink
allow rdkit mols in interators
Browse files Browse the repository at this point in the history
  • Loading branch information
eloyfelix committed Oct 6, 2023
1 parent 2948019 commit cdb9e21
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion FPSim2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
except Exception as e:
pass

__version__ = "0.4.5"
__version__ = "0.4.6"
21 changes: 10 additions & 11 deletions FPSim2/io/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,27 @@ def build_fp(rdmol, fp_type, fp_params, mol_id):
return fp


def load_molecule(mol_string: str) -> Chem.Mol:
def load_molecule(molecule: Any) -> Chem.Mol:
"""Reads SMILES, molblock or InChI and returns a RDKit mol.
Parameters
----------
mol_string : str
SMILES, molblock or InChI.
molecule : Any
Chem.Mol, SMILES, molblock or InChI.
Returns
-------
mol: ROMol
RDKit molecule.
"""
if re.search(MOLFILE_RE, mol_string, flags=re.MULTILINE):
rdmol = Chem.MolFromMolBlock(mol_string)
elif mol_string.startswith("InChI="):
try:
rdmol = Chem.MolFromInchi(mol_string)
except:
rdmol = None
if isinstance(molecule, Chem.Mol):
return molecule
if re.search(MOLFILE_RE, molecule, flags=re.MULTILINE):
rdmol = Chem.MolFromMolBlock(molecule)
elif molecule.startswith("InChI="):
rdmol = Chem.MolFromInchi(molecule)
else:
rdmol = Chem.MolFromSmiles(mol_string)
rdmol = Chem.MolFromSmiles(molecule)
return rdmol


Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Eloy Félix Manzanares
Copyright (c) 2019-2023 Eloy Félix Manzanares

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def build_extensions(self):
long_description_content_type="text/markdown",
ext_modules=ext_modules,
install_requires=[
"rdkit>=2022.3.3",
"rdkit>=2023.03.2",
"tables>=3.4.4",
"numpy >=1.14",
"sqlalchemy>=1.4.47",
Expand Down

0 comments on commit cdb9e21

Please sign in to comment.