Created
July 21, 2014 14:58
-
-
Save abhik1368/332a22bc7f8c5df36204 to your computer and use it in GitHub Desktop.
inchifrommol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create function | |
create or replace function inchi_mol(x text) | |
returns text | |
AS $$ | |
from rdkit import Chem | |
from rdkit.Chem import AllChem | |
file = open("/home/chembl/logerror2.txt","a") | |
try : | |
m=Chem.MolFromInchi(x) | |
if m is not None : | |
try: | |
AllChem.Compute2DCoords(m) | |
except (RuntimeError,ValueError,TypeError,Exception): | |
pass | |
file.write("2DCoords Error:") | |
file.write(x) | |
file.write("\n") | |
try : | |
return Chem.MolToMolBlock(m) | |
except (RuntimeError,ValueError,TypeError,Exception) : | |
pass | |
file.write("Molblock Error:") | |
file.write(x) | |
file.write("\n") | |
else: | |
file.write("Inchi to Mol Error:") | |
file.write(x) | |
file.write("\n") | |
except : | |
pass | |
file.write("Mol Error:") | |
file.write("\n") | |
file.close() | |
$$ LANGUAGE plpython2u SECURITY DEFINER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment