Thanks, Noel. I had seen your method but I had decided to go with OBReaction + RXN, because it would make life much easier for users of the tool I'm writing. In this way, they could import their RXN files prepared elsewhere without having to craft SMARTS patterns manually.
Then, when I got stuck with that, I went back to the transformations, but I was able only to change elements and bond orders, not adding extra atoms: -----8<----8<---8<---8<----8<-----8<----------- import pybel ob = pybel.ob start = '[O:1]=[C:2]-[C:3]=[C:4]' # end = '[O:1]=[C:2]-[C:3]-[C:4]-[S][C]' # not working end = '[O:1]=[C:2]-[C:3]-[C:4]-[S:5][C:6]' # not working transformer = ob.OBChemTsfm() transformer.Init(start, end) org = 'C=CC(=O)Nc1ccccc1' mol = pybel.readstring('can', org) startPattern = pybel.Smarts(start) endPattern = pybel.Smarts(end) # check that the pattern is found print "Find start matching: ", bool(len(startPattern.findall(mol))) transformer.Apply(mol.OBMol) print "Original :", org print "Modified :", mol.write('can') print "Check for modified pattern:", bool(len(endPattern.findall(mol)) ) -----8<----8<---8<---8<----8<-----8<----------- Although, if there's a way to have OBChemTsfm() working also for in silico reactions, how hard would it be to parse a RXN reaction(*) and convert its elements into SMARTS strings to be used with the OBChemTsfm? Stefano (*) pairwise reactions only, at this point. On 07/29/2014 05:09 AM, Noel O'Boyle wrote: > Does this help? > http://baoilleach.blogspot.co.uk/2012/08/transforming-molecules-intowellother.html > > Note that OBReaction was not involved at any point. Furthermore, we had some > problems > wrapping OBReaction in Python - not sure if these were ever resolved... > > - Noel > > > On 29 July 2014 00:38, Stefano Forli <fo...@scripps.edu > <mailto:fo...@scripps.edu>> wrote: > > Hi all, > > I'm trying to write a Python object to apply a RXN transformation to a > series of > molecules. > In particular, I'm peeking at the RXN format source (rxnformat.cpp) to > populate an > OBReaction() object but then I don't know how to tie it to the OBChemTsfm > class to perform > the actual transformation. > Unfortunately, I had not much luck in finding documentation on the > matter, so any > suggestions will be more than welcome. > > Thanks, > > S > > > -- > Stefano Forli, PhD > > Staff Scientist > Molecular Graphics Laboratory > Dept. of Integrative Structural > and Computational Biology, MB-112F > The Scripps Research Institute > 10550 North Torrey Pines Road > La Jolla, CA 92037-1000, USA. > > tel: (858) 784-2055 > fax: (858) 784-2860 > email: fo...@scripps.edu <mailto:fo...@scripps.edu> > http://www.scripps.edu/~forli/ > > > ------------------------------------------------------------------------------ > Infragistics Professional > Build stunning WinForms apps today! > Reboot your WinForms applications with our WinForms controls. > Build a bridge from your legacy apps to the future. > > http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > <mailto:OpenBabel-discuss@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > -- Stefano Forli, PhD Staff Scientist Molecular Graphics Laboratory Dept. of Integrative Structural and Computational Biology, MB-112F The Scripps Research Institute 10550 North Torrey Pines Road La Jolla, CA 92037-1000, USA. tel: (858) 784-2055 fax: (858) 784-2860 email: fo...@scripps.edu http://www.scripps.edu/~forli/ ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss