From: Stefano F. <fo...@sc...> - 2014-10-03 18:30:02
|
I partially agree with the explanation. What makes me uncomfortable is the inconsistency of the behavior between the two methods. Ideally, either both OBAtom.GetResidue() and OBResidue.GetResidue() should trigger residue perception, or none. The current behavior opens the way to all kinds of unpleasant behavior depending on the order in which the two functions are called (basically, the way in which I found out about it). Although, if it is indeed a feature, I think it should be documented. Thanks for the OBChainsParser tip, it seems very useful. S On 10/03/2014 02:19 AM, Noel O'Boyle wrote: > I guess that calling GetResidue triggers residue perception but the > iterator doesn't trigger it. I don't think it's a bug - just because > GetResidue automatically does something doesn't mean that everything > should. In particular, iterators shouldn't have side-effects. To > directly perceive, uses OBChainsParser. > > - Noel > > On 3 October 2014 02:15, Stefano Forli <fo...@sc...> wrote: >> Hi, >> I'm a little bit puzzled by the behavior of the following code: >> ---------------------------- >> import pybel >> ob = pybel.ob >> smi = 'c1ccccc1' >> mol = pybel.readstring('smi', smi).OBMol >> print "RESIDUES FOUND:", len([ x for x in ob.OBResidueIter(mol)]) >> mol.GetAtom(1).GetResidue() >> print "RESIDUES FOUND:", len([ x for x in ob.OBResidueIter(mol)]) >> print mol.GetResidue(0).GetName() >> ---------------------------- >> On v2.3.1 the output is: >> RESIDUES FOUND: 0 >> RESIDUES FOUND: 1 >> LIG >> >> >> Basically, the OBMol has no residues before OBAtom.GetAtom() gets called, then one is >> created (and named "LIG"). >> It seems like a bug to me, but I want to be sure I'm not missing anything before reporting >> it... >> >> 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: +1 (858)784-2055 >> fax: +1 (858)784-2860 >> email: fo...@sc... >> http://www.scripps.edu/~forli/ >> >> ------------------------------------------------------------------------------ >> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer >> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports >> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper >> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer >> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk >> _______________________________________________ >> OpenBabel-discuss mailing list >> Ope...@li... >> 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: +1 (858)784-2055 fax: +1 (858)784-2860 email: fo...@sc... http://www.scripps.edu/~forli/ |