Chemistry Reference
In-Depth Information
Create Or Replace Function frowns.list_matches(Text, Text, Integer)
Returns Integer[] As $EOSQL$
Select frowns.list_matches($1, $2, $3, 0);
$EOSQL$ Language SQL Immutable;
Create Or Replace Function frowns.fp(smi Text, nbits Integer,
maxpath Integer) Returns Bit As $EOPY$
from frowns import Fingerprint
from frowns import Smiles
mol = Smiles.smilin(smi)
numints = nbits / 32
fp = Fingerprint.generateFingerprint(mol, numInts=numints,
pathLength=maxpath)
return "".join([str(bit) for bit in fp.to_list()])
$EOPY$ Language plpythonu Immutable;
Create Or Replace Function frowns.fp(smi Text) Returns Bit As
$EOSQL$
Select frowns.fp($1, 512, 7);
$EOSQL$ Language SQL Immutable;
Create or Replace FUNCTION frowns.contains(Bit, Bit) Returns
Boolean As $EOSQL$
Select $2 = ($1 & $2);
$EOSQL$ Language SQL Immutable;
Comment On FUNCTION frowns.contains(bit, bit)
Is 'does first bit string contain all the bits of second';
-- get all info from molfiles in one record for insert into a table
-- see frowns.sql for an example of using frowns.molfile_mol() to
-- insert into a table
Drop Type frowns.mol Cascade;
Create Type frowns.mol As (name Text, cansmiles Text, coords
Numeric[][], atoms Integer[]);
Create Or Replace Function frowns.molfile_mol(molfile Text) Returns
frowns.mol As $EOPY$
from frowns import MDL
from frowns import Smiles
import StringIO
fd = StringIO.StringIO(molfile + "\n$$$$")
for mol, text, error in MDL.sdin(fd):
if not mol:
print error + text
return None
else:
# sometimes mol.cansmiles emits [C] when C is proper, amol seems
to fix that
amol = Smiles.smilin(mol.cansmiles())
return (mol.name, amol.cansmiles(), \
"{" + ",".join(["{"+str(a.x)+","+str(a.y)+","+str(a.z)+"}" \
for a in mol.canonical_list[0][1]]) + "}" , \
"{" + ",".join([str(a.index+1) \
for a in mol.canonical_list[0][1]]) + "}" )
Search WWH ::




Custom Search