Hi Chris,

You're missing one step: BRICS.BRICSBuild() is expecting molecules, not
SMILES.
If you add a call to Chem.MolFromSmiles() you should get what you want :

In [12]: mcat = [Chem.MolFromSmiles(x) for x in catalog]

In [13]: ms = BRICS.BRICSBuild(mcat)

In [14]: for m in ms: print Chem.MolToSmiles(m)
c1ncnc(-c2ncncn2)n1
c1ncnc(C2CC2)n1
c1ncnc(C2CNC2)n1
c1ncnc(Oc2ncncn2)n1
c1ncnc(OC2CC2)n1
c1ncnc(OC2CNC2)n1
C1CC1OC1CC1
C1CC1OC1CNC1
C1NCC1OC1CNC1

The other option is to call BRICS.BricsDecompose() with the returnMols
argument:
In [17]: catalog = BRICS.BRICSDecompose(base,returnMols=True)

In [18]: ms = BRICS.BRICSBuild(catalog)

In [19]: for m in ms: print Chem.MolToSmiles(m)
c1ncnc(C2CC2)n1
c1ncnc(C2CNC2)n1
c1ncnc(-c2ncncn2)n1
c1ncnc(Oc2ncncn2)n1
c1ncnc(OC2CC2)n1
c1ncnc(OC2CNC2)n1
C1CC1OC1CC1
C1CC1OC1CNC1
C1NCC1OC1CNC1


Best,
-greg


On Sat, Mar 14, 2015 at 2:34 PM, Chris Arthur <[email protected]>
wrote:

> Hi guys,
>
> i hope some can help.
>
> I am trying to run the code from
> <
> https://www.mail-archive.com/[email protected]/msg00479.html
> >
>
> from rdkit import Chem
> from rdkit.Chem import BRICS
> base = Chem.MolFromSmiles("n1cncnc1OCC(C1CC1)OC1CNC1")
>
> catalog = BRICS.BRICSDecompose(base)
> print catalog
>
> ms = BRICS.BRICSBuild(catalog)
> ms = list(ms)
> len(ms)
>
> for m in ms[:5]: print Chem.MolToSmiles(m)
>
>
> Brics is decomposing molecules correctly (as shown by print catalog)
> and ms reports as a
> <generator object BRICSBuild at 0x0000000009CBCA68>
>
> But I get errors whenever I try to get structures from ms (see the
> following trackback)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 580, in runfile
>     execfile(filename, namespace)
>   File "//
> ads.bris.ac.uk/filestore/myfiles/staff14/chxcja/Desktop/brics-test.py",
> line 11, in <module>
>     ms = list(ms)
>   File "c:\RDKit\rdkit\Chem\BRICS.py", line 532, in BRICSBuild
>     if seed.HasSubstructMatch(rxn._matchers[0]):
> AttributeError: 'str' object has no attribute 'HasSubstructMatch'
>
> I am using Anaconda Python (Py2.7) on windows with RDKit_2014_09_02
>
> Can anyone suggest what I'm doing wrong?
>
> Thanks
>
> Chris
>
> --
> Dr Christopher J. Arthur
> School of Chemistry
> University of Bristol
> BRISTOL, BS8 1TS,  UK
> E-mail:  [email protected]
>
> Office: (+44 117) 331 7192
> Mass Spectrometry Lab: (+44 117) 331 7358.
> FAX: (+44 117) 927 7985
>
> WWW URL: http://www.chm.bris.ac.uk/staff/carthur.htm
> LinkedIn  Profile: https://www.linkedin.com/in/drchrisarthur
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to