Paolo provides exactly the right answer once you have the SMARTS that
defines your fragment.
Unfortunately, it doesn't seem to be particularly straightforward to get
this SMARTS from the FragmentCatalog.
Here's a (mostly untested) function that constructs the SMARTS:
def replaceit(fcat,entryId):
# general expression for matching these, don't need it now
# sexpr = re.compile(r'\[?([A-Za-z][H0-9]*?)\]?\<(.*?)\>')
descr = fcat.GetEntryDescription(entryId)
fparams = fcat.GetCatalogParams()
gids = fcat.GetEntryFuncGroupIds(entryId)
fgs = [fparams.GetFuncGroup(x) for x in gids]
done = set()
for fg in fgs:
sma = Chem.MolToSmarts(fg)
nm = fg.GetProp('_Name')
descr = re.sub(r'\[?([A-Za-z][H0-9]*?)\]?\<%s>'%nm,
r'[\1;$(%s)]'%sma,descr)
return descr
Run on your example like this:
fName=os.path.join(RDConfig.RDDataDir,'FunctionalGroups.txt')
fparams = FragmentCatalog.FragCatParams(1,6,fName)
fcat=FragmentCatalog.FragCatalog(fparams)
fcgen=FragmentCatalog.FragCatGenerator()
m = Chem.MolFromSmiles("CCCCC[C@@H](CC[C@H]1[C@@H](C[C@@H]([C@
@H]1CCCCCCC(=O)O)O)O)O")
fcgen.AddFragsFromMol(m,fcat)
sma = replaceit(fcat,49)
print(fcat.GetEntryDescription(49))
print(sma)
I get the following output:
[CH]<-O>[CH]CC[CH]<-O>CC
[CH;$(*-[O&D1])][CH]CC[CH;$(*-[O&D1])]CC
The SMARTS from replaceit() can be used in the example Paolo provides to
highlight the fragments.
I don't think this should be quite so difficult. I'm going to have to look
at this for a bit longer to see if I can come up with a better solution,
but this ought to work.
-greg
On Fri, May 6, 2016 at 5:23 AM, Paolo Tosco <paolo.to...@unito.it> wrote:
> Dear Francesco,
>
> Check this:
>
> https://nbviewer.jupyter.org/gist/ptosco/1a02149fa0602c24c86cc557b0cfedef
>
> More information and examples in this RDKit blog post that Greg published
> some time ago:
>
> http://rdkit.blogspot.it/2015/02/new-drawing-code.html
>
> Best,
> Paolo
>
> > On 5 May 2016, at 17:01, Francesco Del Carratore <
> francescod...@gmail.com> wrote:
> >
> > Hi all,
> > I just started using RDKit, so probably this is a silly question. I have
> the following molecule:
> > m = Chem.MolFromSMILES("CCCCC[C@@H](CC[C@H]1[C@@H](C[C@@H]([C@
> @H]1CCCCCCC(=O)O)O)O)O")
> > As described in the "Getting started" tutorial, I found the fragments of
> this molecule.
> > Now let say I am interested in the following fragment:
> > "C<-C(=O)O>CCC"
> > Is there a way to plot the 2D depiction of the molecule highlighting the
> that specific fragment?
> > Thanks in advance for the help,
> > Best Wishes,
> > Francesco
> >
> >
> ------------------------------------------------------------------------------
> > Find and fix application performance issues faster with Applications
> Manager
> > Applications Manager provides deep performance insights into multiple
> tiers of
> > your business applications. It resolves application problems quickly and
> > reduces your MTTR. Get your free trial!
> > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> > _______________________________________________
> > Rdkit-discuss mailing list
> > Rdkit-discuss@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss