Hi Greg,

1. "mol_from_Molecule_copy = pybel.Molecule(mol)"
This doesn't copy anything. It writes it out as a Mol file, and then
reads it in from a Mol file. A Mol file has 4 decimal places of
precision. It seems that I should document this.

2. "mol_from_OBMol_copy = pybel.Molecule(mol.OBMol)"
This doesn't copy anything either. It just creates a pybel Molecule as
a thin wrapper around an OBMol.

3. If you want to copy an OBMol, you should use OBMol's copy
constructor, "myCopyMol = pybel.ob.OBMol(mol.OBMol)"

4. FYI, "mol = [mol for mol in pybel.readfile('xyz', 'test1.xyz')][0]"
is better as "mol = pybel.readfile(...).next()"

HTH,
- Noel

On 24 March 2013 18:36, inviso <inv...@gmail.com> wrote:
> In one specific case that I'm able to identify, I'm losing precision on the
> geometry vectors when copying a molecule in pybel.  I've attached a small
> sample of source and a single molecule file that reliably reproduces the
> results for me on Windows with OpenBabel 2.3.1 and Python 2.7.2.  Also,
> confirmed on Rocks Linux with OpenBabel 2.3.2 and Python 2.6.6.
>
> The output on my machine from the sample code is as follows:
> Original       : 0.0602900000, -2.2281500000, 0.0378600000
> Molecule_copy  : 0.0603000000, -2.2281000000, 0.0379000000
> OBMol_copy     : 0.0602900000, -2.2281500000, 0.0378600000
>
> A few notes:
> 1) Yes, the precision in my print format string is ridiculous :)  I just
> wanted to make sure I wasn't arbitrarily clipping precision when displaying
> the output.
> 2) The sample code only outputs the first atom (Rh) as it was all that was
> necessary to show the problem on my machine.
> 3) Since this works fine when passing OBMol into the constructor, it looks
> like it has to be caused by the Molecule._exchange call which in turn calls
> Molecule.write(format='mol')
> 4) Calling Molecule.write(format='mol') directly also shows a loss of
> precision on the geometry in the output.  The .write() call goes into
> openbabel.OBConversion and from there into swig code which I'm not very
> familiar with so I didn't try to follow it deeper into the C++ library.
> 5) It seems like the precision being lost is far greater than I would
> expected from the inherent precision problems of double and it feels more
> like it's just rounding to four digits of precision.  It seems especially
> suspect since using OBMol is accurate.
>
> I will work around this by always using new_copy =
> pybel.Molecule(my_mol.OBMol), but it is an odd behavior.  Is anyone else
> able to confirm?  Is it unexpected behavior to pass pybel.Molecule instead
> of OBMol or is the _cinfony check in the constructor specifically meant for
> that case?
>
> Thanks,
>
> Greg Fortune
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to