convertToFrags and property keys

User 0224fcf261

17-12-2004 17:29:53

Hi guys,





I have opened a molecule from an SD file into a Molecule object, this Molecule actually contains two molecules and a number of property keys. If i split the molecules using:





Code:



Molecule[] molArray = myMol.convertToFrags();








The i get an array of two Molecules (each containing one molecule) but they don't have the property keys from the initial parent Molecule object. Is there a simple way to do this or do i have to iteratively copy the property keys over to each Molecule in my array ? i notice i can getPropertyKeys() as an Enumeration put i don't seem to be able to setPropertyKeys(Enumeration). It would be useful if the convertToFrags automatically copied propety keys across.





I hope this makes sense!


Thanks


Alistair

ChemAxon fb166edcbd

18-12-2004 14:56:04

The molecules created by





Code:



Molecule[] molArray = myMol.convertToFrags();








do not contain the properties of the original molecule, since these properties may not be valid for the fragments. They do not contain the property keys either, since having a property key is the same as having a property value with that property key. Setting a property means setting a <key, value> pair by





Code:



mol.setProperty(key, value);








Currently it is not possible to copy all properties together but it is not too difficult to copy them one-by-one:





Code:



Molecule[] molArray = myMol.convertToFrags();


Enumeration keys = myMol.getPropertyKeys();


while (keys.hasMoreElements()) {


     String key = (String) keys.nextElement();


     String value = myMol.getProperty(key);


     for (int i=0; i < molArray.length; ++i) {     


           molArray[i].setProperty(key, value);


     }


}