User e6dac1475d
10-01-2014 15:37:00
Dear ChemAxon team,
I am using the Java API v6.1.3 and I would like to get the formula for a constant part of a polymer, starting from a molfile. How can I do it?
Example:
Given the following compound (see attached molfile ChEBI_15693.mol), which is an aldose, with a RepeatingUnitSgroup (SRU):
If I do:
import chemaxon.struc.Molecule;
[...]
MolImporter importer = new MolImporter(new ByteArrayInputStream(structure.getBytes()));
Molecule mol = importer.read();
[...] mol.getFormula()
I get:
(CH2O)nC2H4O2
How do I get C2H4O2 only?
I tried the two following possibilities:
1. I can't perform mol.removeAllSGroups() before calling getFormula() (Molecule.removeAllSGroups() is protected)
2, I tried the ElementalAnalyserPlugin, getFormula(), but I get:
java.lang.NullPointerException
at chemaxon.struc.Molecule.addSgroupClone(Molecule.java:1046)
[...]
Do you have a suggestion to get C2H4O2 out of this molfile in a clean way?
Thanks for you support,
Thierry