Hi,

 

If I run the script below, with testmol.sdf as attached, the first remove_hydrogens() gives no complaint, the second gives the error

 

File "test_ccdc_h.py", line 17, in <module>
mol1.remove_hydrogens()
File "/home/davidc/anaconda2/envs/TwoD2ThreeD/lib/python2.7/site-packages/ccdc/molecule.py", line 1454, in remove_hydrogens
ChemistryLib.remove_hydrogens(self._molecule)

TypeError: in method 'remove_hydrogens', argument 1 of type 'EditableMolecule &'

 

I can't find any documentation about editable or non-editable molecules. Can someone please help me understand what the difference is between the two cases and how I go about removing hydrogens from a molecule read from a string? My real use case is with SDF records POSTed to a webservice, so I don't want to have to go through a file.

 

Thanks,

Dave

-------------------------------------------------------------------------------------------------

Script:

 

#!/usr/bin/env python

from ccdc import io
from ccdc.molecule import Molecule

mol_reader = io.MoleculeReader( 'testmol.sdf' )
mol = mol_reader[0]
mol.remove_hydrogens() #  works fine

f = open( 'testmol.sdf' , 'r' )
fc = f.read()
mol1 = Molecule.from_string( fc , 'sdf' )
mol1.remove_hydrogens() # generates error

Hi David,

I'm afraid you have unearthed a genuine bug.  Discussions are underway here to see if it can be fixed in the forthcoming API version 1.3 release.

In the meantime you can work around the problem by using the internal API:

mol = Molecule.from_string(...)

mol = Molecule(mol.identifier, _molecule=mol._molecule.create_editable_molecule())

Sorry about this.

 

Richard

Hi Richard,

Sorry not to reply sooner, I've been on holiday. I'm happy to report that the script now runs using the beta version of the 1.3 API.  Thanks for squeezing it in so close to the wire.

Dave

 

You must be signed in to post in this forum.