Chemistry Reference
In-Depth Information
print "Error parsing molfile"
#raise ValueError("Error parsing molfile")
return None
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.graph(smi Text) Returns Text As
$EOPY$
from frowns import Smiles
try:
mol = Smiles.smilin(smi)
except:
return None
hcount = 0
for b in mol.bonds:
b.bondorder = b.bondtype = 1
b.aromatic = 0
for a in mol.atoms:
hcount += a.hcount
a.aromatic = 0
a.charge = 0
nbonds = len(a.bonds)
if a.valences:
a.imp_hcount = a.hcount = a.valences[0] - nbonds
return mol.cansmiles() + '.H' + str(hcount)
$EOPY$ Language plpythonu Immutable;
Assume that the code above is stored in a file named frowns-core.sql. In
order to install these functions into a database named mydb , the following
linux command would be used.
sudo -u postgres psql mydb <frowns-core.sql
It is necessary to install these as the PostgreSQL superuser, here postgres,
or as any other PostgreSQL superuser. This is because the “untrusted” lan-
guage plpythonu is used. It might be more accurate to say “unrestricted,”
since plpythonu can use all the functionality of python.
A.6.3 OpenBabel/python
OpenBabel 7 is program used to interconvert molecular structures from
one file format to another. The underlying C++ functions allow operations
on SMILES, SMARTS, and molfiles, as well as other functionality includ-
ing fingerprints. There is a python wrapper for OpenBabel toolkit. Using
this module and the plpythonu procedural language in PostgreSQL, the
following functions implement the core functions.
Create Schema openbabel;
Grant All On Schema openbabel to public;
Search WWH ::




Custom Search