Chemistry Reference
In-Depth Information
FROWNS python modules are used to show a second way in which the
core functions might be implemented. The following plpythonu code
extends PostgreSQL with most of the core functions described in Chapter
7. The isosmiles and keksmiles functions are not included here because of
limitations of FROWNS.
Create Schema frowns;
Grant All On Schema frowns to public;
Create Or Replace Function frowns.valid(smi Text) Returns Boolean
As $EOPY$
from frowns import Smiles
try:
mol = Smiles.smilin(smi)
return True
except:
return False
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.cansmiles(smi Text) Returns Text
As $EOPY$
from frowns import Smiles
mol = Smiles.smilin(smi)
return mol.cansmiles()
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.smiles_to_symbols(smi Text)
Returns Text[] As $EOPY$
from frowns import Smiles
mol = Smiles.smilin(smi)
return "{" + ",".join((a.symbol for a in mol.atoms)) + "}"
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.smiles_to_bonds(smi Text) Returns
Integer[][2] As $EOPY$
from frowns import Smiles
mol = Smiles.smilin(smi)
iatom = 0
return "{" + ",".join( \
[ "{" + ",".join((str(b.atoms[0].index+1),str(b.atoms[1].
index+1),str(b.bondtype))) + "}" for b in mol.bonds ] \
) + "}"
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.smiles_to_molfile(smi Text, name
Text, coords Numeric[][]) Returns Text As $EOPY$
from frowns import Smiles
# just get the molfile format right.
# stereochemistry missing; charges only appear in CHG records
mol = Smiles.smilin(smi)
(x,y,z) = (0.0, 0.0, 0.0)
if name is None:
Search WWH ::




Custom Search