Hi, Maybe someone with more insight into the specifics can give a more stable answer, but what I’ve found is that you can invert a center with the following code: config.winding = 2 if config.winding == 1 else 1 ts.SetConfig(config) So replacing config.Invert() with these two lines will make your example work at least…
Kind regards, Fredrik 18 jun 2014 kl. 03:45 skrev Stefano Forli <fo...@scripps.edu>: > Hi everyone, > > I'm trying to invert the chirality of a chemical group using Python. I had > searched quite > a while before finding something that I could use (despite the fact the > question showed up > a few times in the mailing list). > > My starting points were a discussion on Blueobelisk[1] and a guide file[2] > that Noel > linked in an old mailing list thread but I couldn't find in the current > release. > The example in [2] didn't work in my case, and it seems to use deprecated > .Set*ClockwiseStereo() functions, therefore, I tried the other one that's > following the > blessed way (correct me if I'm wrong) with OBStereoFacade. > Here is the code, that works up to a certain point: > > ----- > import pybel > ob = pybel.ob > > smarts = pybel.Smarts("c[C@H](C(=O)O)") > inverse = pybel.Smarts("c[C@@H](C(=O)O)") > outputfile = pybel.Outputfile('smi', 'converted.smi', overwrite=1) > > inmol = [ '[O]C(=O)[C@H](c1cccnc1)C' ] > for smi in inmol: > mol = pybel.readstring('smi', smi) > old = mol.__str__ > matches = smarts.findall(mol) > firstmatch = matches[0] > if matches: > print "MATCH" > facade = ob.OBStereoFacade(mol.OBMol) > for matchingatom in firstmatch: > ts = facade.GetTetrahedralStereo(matchingatom) > if ts: > print "TS\t", ts > config = ts.GetConfig() > print "CONFIG\t", config > # these commands will raise an error > # ob.OBTetrahedralStereo.Invert(config) > # ob.OBTetrahedralStereo_invert(config) > config.Invert() > > ts.SetConfig(config) > assert inverse.findall(mol), "Hasn't been inverted!" > outputfile.write(mol) > new = mol.__str__ > print "STILL THE SAME?", old == new > > outputfile.close() > ----- > When attempting to invert the chirality, it fails with the following error: > > Traceback (most recent call last): > File "invertChiralityFacade.py", line 24, in <module> > config.Invert() > AttributeError: 'OBTetrahedralConfig' object has no attribute 'Invert' > > I've tried all combinations mentioned here [3] and none of them worked. > Besides, it seems > here is no mention of the Invert function in openbabel.py. > I would really appreciate any input on the matter. > > Thanks! > > Stefano > > > [1] > http://blueobelisk.shapado.com/questions/which-openbabel-dev-version-methods-should-be-used-for-altering-stereochemistry > [2] > http://www.filewatcher.com/p/openbabel-2.3.0.tar.gz.14321281/openbabel-2.3.0/doc/guide/_sources/UseTheLibrary/PythonExamples.txt.html > [3] https://code.google.com/p/pythonocc/issues/detail?id=20 > > > -- > 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/ > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
signature.asc
Description: Message signed with OpenPGP using GPGMail
------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems
_______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss