import java.io.IOException;
import chemaxon.marvin.calculations.ElementalAnalyserPlugin;
import chemaxon.marvin.plugin.PluginException;
import chemaxon.struc.Molecule;
import chemaxon.formats.MolImporter;
<p>
<pre></pre>
http://www.chemaxon.com/marvin/examples/plugin/index.html
@version
@since
@author
public class ElementalAnalyserPluginExample {
public static void main(String[] args) {
try {
ElementalAnalyserPlugin plugin = new ElementalAnalyserPlugin();
plugin.setDoublePrecision(2);
MolImporter importer = new MolImporter(args[0]);
Molecule mol;
while ((mol = importer.read()) != null) {
plugin.setMolecule(mol);
plugin.run();
double mass = plugin.getMass();
double exactMass = plugin.getExactMass();
int atomCount = plugin.getAllAtomCount();
int countOfC = plugin.getAtomCount(6);
int countOfC14 = plugin.getAtomCount(6, 14);
String formula = plugin.getFormula();
String composition = plugin.getComposition();
System.out.println(mol.toFormat("smiles") + "\n formula: "
+ formula + ", mass: " + mass + ", exact mass: "
+ exactMass + "\n number of atoms (" + atomCount
+ "): C (" + countOfC + "), C-14 (" + countOfC14 + ")"
+ "\n composition: " + composition + "\n");
}
importer.close();
} catch (IOException e) {
System.err.println("I/O error has occurred.");
e.printStackTrace();
} catch (PluginException e) {
System.err.println("Plugin processing or calculation error.");
e.printStackTrace();
}
}
}