Chemistry Reference
In-Depth Information
Create Or Replace Function openbabel.molfile_properties(molfil
Text) Returns Setof openbabel.named_property As $EOPY$
import pybel
mol = pybel.readstring("sdf", molfil)
return mol.data.iteritems()
print "Error parsing molfile"
#raise ValueError("Error parsing molfile")
return None
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function openbabel.graph(smi Text) Returns Text
As $EOPY$
import openbabel
obc = openbabel.OBConversion()
mol = openbabel.OBMol()
obc.SetInAndOutFormats("smi", "can")
try:
obc.ReadString(mol, smi)
except:
return None
hcount = 0
for a in openbabel.OBMolAtomIter(mol):
hcount += a.ImplicitHydrogenCount() + a.ExplicitHydrogenCount()
for b in openbabel.OBMolBondIter(mol):
b.SetBondOrder(1)
b.UnsetAromatic()
for a in openbabel.OBMolAtomIter(mol):
a.UnsetAromatic()
a.SetFormalCharge(0)
return obc.WriteString(mol, 1) + '.H' + str(hcount)
$EOPY$ Language plpythonu Immutable;
Assume that the code above is stored in a file named openbabel-core.sql.
In order to install these functions into a database named mydb , the follow-
ing linux command would be used.
sudo -u postgres psql mydb <openbabel-core.sql
It is necessary to install these as the PostgreSQL superuser, here postgres,
or as any another PostgreSQL superuser. This is because the “untrusted”
language plpythonu is used. It might be more accurate to say “unre-
stricted,” since plpythonu can use all the functionality of python.
A.7 C Language PostgreSQL Functions
C language functions require more work than functions written in other
languages. As with all C programs, they must first be compiled. The
Search WWH ::




Custom Search