As you found, the --canonical solution is not at all the efficient way to do this. Here's the proper way to do this using Tim's OBIsomorphismMapper (which uses the VF2 graph matching algorithm I believe).
import pybel ob = pybel.ob mol = pybel.readstring("smi", "CC(=O)Cl") molb = pybel.readstring("smi", "CC(Cl)=O") mol.make3D() molb.make3D() mol.removeh() molb.removeh() query = ob.CompileMoleculeQuery(mol.OBMol) mapper = ob.OBIsomorphismMapper.GetInstance(query) mapping = ob.vpairUIntUInt() mapper.MapFirst(molb.OBMol, mapping) print list(mapping) # Result: ((0, 0), (1, 1), (2, 3), (3, 2)) molb.OBMol.RenumberAtoms([x[1]+1 for x in mapping]) Hopefully something similar will work for you. - Noel On 30 November 2012 14:58, dalvarez <algarcia.dan...@gmail.com> wrote: > Hi there, > > I'm trying to obtain a rotation matrix between two pdb files containing the > same protein. For many of them the following script works perfectly: > > # Load files in OBMol > S = next(pybel.readfile('pdb',struc)) > S.removeh() > T = next(pybel.readfile('pdb',target)) > T.removeh() > > # Align > align = openbabel.OBAlign(False,False) > align.SetRefMol(S.OBMol) > align.SetTargetMol(T.OBMol) > if align.Align(): > OBrotMat = align.GetRotMatrix() > > The problem comes when the atom order is not the same in the two files. > As suggested in other posts, i tried: > >> babel input.pdb -O output.pdb --canonical > > But it results in a Segmentation Fault, or memory failure due to the large > number of atoms in the file. > Anyone can help me working this out? What methods, classes should i use to > do this job within the script before the alignment? > > Thanks in advance! > > Daniel > > > > > -- > View this message in context: > http://forums.openbabel.org/match-atom-order-in-two-pdb-files-of-same-molecule-tp4655723.html > Sent from the General discussion mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss