Molecule objects can contain general properties (property value - property key pairs). The formats mrv, sdf, rdf are able to store the molecule properties.
String value = molecule.getProperty(LOGP_FIELD); //LOGP_FIELD is the name of the property
Otherwise we need to go through the property names. An example is below:
for (int i=0; i<molecule.getPropertyCount(); i++) { String key = molecule.getPropertyKey(i); // name of the property String value = molecule.getProperty(key); // the property value }
For a complete source code, please see ImportProperties.java
.
MolFileHandler.collectFileInfo(inputStream, 0, collectedFields); java.util.Iteratoriterator = collectedFields.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); }
For a complete source code, please see CollectProperties.java
.
The following example shows how to add properties via API:
Molecule mol = MolImporter.importMol("ccccc"); MHashProp hashProp = new MHashProp(); mol.setPropertyObject("ROOT", hashProp); hashProp.put("CdId", new MStringProp("1")); hashProp.put("Formula", new MStringProp("C5H10")); MMoleculeProp secondaryStruc = new MMoleculeProp(MolImporter.importMol("cc")); hashProp.put("secondStruct", secondaryStruc); mol.setProperty("$REGNO", "MI24"); System.out.println(MolExporter.exportToFormat(mol, "rdf"));
For a complete source code, please see ExportProperties.java
.
External or internal registry number of a molecule can be added to the molecule or reaction via API. The mrv, mol (sdf, rdf) format exports and imports these registry numbers after specifying them:
... int regno = 218; while ((mol=imp.read())!=null){ //add the internal registry number (sequence number in the database) of the reaction mol.setProperty("$REGNO", "RI" + regno); regno++; exp.write(mol); } ...
For a complete source code, please see ExportingReactions.java
.
Image generation |
Molecule converter
|