Chemistry Reference
In-Depth Information
Create Or Replace Function openbabel.fp(smi Text) Returns Bit As
$EOPY$
import pybel
mol = pybel.readstring("smi", smi)
fp = mol.calcfp()
fpx = ['0' for i in range(1024)]
for b in fp.bits:
fpx[b-1] = '1'
return "".join(fpx)
$EOPY$ Language plpythonu Immutable;
Create or Replace FUNCTION openbabel.contains(Bit, Bit) Returns
Boolean As $EOSQL$
Select $2 = ($1 & $2);
$EOSQL$ Language SQL Immutable;
Comment On FUNCTION openbabel.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 openbabel.sql for an example of using openbabel.molfile_
mol() to
-- insert into a table
Drop Type openbabel.mol Cascade;
Create Type openbabel.mol As (name Text, cansmiles Text, coords
Numeric[][], atoms Integer[]);
Create Or Replace Function openbabel.molfile_mol(molfil Text)
Returns openbabel.mol As $EOPY$
import openbabel
obc = openbabel.OBConversion()
mol = openbabel.OBMol()
obc.SetInAndOutFormats("sdf", "can")
if obc.ReadString(mol, molfil):
title = mol.GetTitle()
mol.SetTitle("")
cansmi = obc.WriteString(mol,1)
pat = openbabel.OBSmartsPattern()
if pat.Init(cansmi):
if pat.Match(mol):
map = (pat.GetUMapList())[0]
return title, cansmi, \
"{" + ",".join(["{"+str(a.x())+","+str(a.y())+","+str(a.z())+"}" \
for a in [mol.GetAtom(i) for i in map]]) + "}" , \
"{" + ",".join([str(i) for i in map]) + "}"
print "Error parsing molfile"
#raise ValueError("Error parsing molfile")
return None
$EOPY$ Language plpythonu Immutable;
Drop Type openbabel.named_property Cascade;
Create Type openbabel.named_property As (name Text, value Text);
Search WWH ::




Custom Search