On 23/11/2010 09:30, Floriane Montanari wrote:
> Hi,
> My request is gonna be very similar to this one in the Mail Archive
> <http://www.mail-archive.com/[email protected]/msg00047.html>.
> I am working on a project completely similar to the one of Mikko
> Kasanen, the difference being that we are using the Python API for our
> coding.
> (Reminder: the user provides a smiles string or a file containing a
> molecule and a Tanimoto threshold, and we would like to output the
> list of molecules of our big database that are similar enough to the
> input).
> I have noticed that the Pybel library doesn't support that similarity
> search, but that openbabel.py should. But cannot use the FindSimilar()
> method because of the type of the arguments. So basically my question is:
> Is there a way to use the method FindSimilar() with Python? I think
> SWIG doesn't support multimaps for Python.
Below is a copy of a post of mine to the OpenBabel-Scripting list on
23rd May 2008. I think Noel has pointed various people towards this
way of doing FastSearch but the Nabble link seems broken. The then new
function OpenInAndOutFiles() being tested here is present in 2.3.0
and presumably part of the Python bindings. A similarity search would
just require another AddOption line. You might as well use the
facility at this higher level, even if you have to use a temporary
file for the results.
Chris
I've now added this to the development code. Here it is making an
index and then substructure searching it. (Note that my Python is
rather shaky.)
I don't think the CloseOutFile() is necessary here but may be
sometimes. It is a bit tedious compared with the babel command line,
but maybe Pybel could help?
>>> import openbabel
>>> conv=openbabel.OBConversion()
>>> conv.OpenInAndOutFiles("1200mols.smi","index.fs")
True
>>> conv.SetInAndOutFormats("smi","fs")
True
>>> conv.Convert()
This will prepare an index of 1200mols.smi and may take some time...
It took 6 seconds
1192
>>> conv.CloseOutFile()
>>> conv.OpenInAndOutFiles("index.fs","results.smi")
True
>>> conv.SetInAndOutFormats("fs","smi")
True
>>> conv.AddOption("s",conv.GENOPTIONS,"C=CC#N")
>>> conv.Convert()
10 candidates from fingerprint search phase
1202
>>> f=open("results.smi")
>>> f.read()
'OC(=O)C(=Cc1ccccc1)C#N\t298\nN#CC(=Cc1ccccc1)C#N\t490\nO=N(=O)c1cc(ccc1)C=C(C#N
)C#N\t491\nClc1ccc(cc1)C=C(C#N)C#N\t492\nClc1ccc(c(c1)Cl)C=C(C#N)C#N\t493\nClc1c
cc(cc1Cl)C=C(C#N)C#N\t494\nBrc1ccc(cc1)C=C(C#N)C#N\t532\nClc1ccccc1C=C(C#N)C#N\t
542\nN#CC(=CC=Cc1occc1)C#N\t548\nCCOC(=O)C(C#N)=C(C)C\t1074\n'
>>>
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss