How do I use Marvin to find the exact mass of the most abundant isotope of an atom?
The most abundant isotope can be detemined with the getMostFrequentNaturalIsotope function of the PeriodicSystem class. This class is not yet in the APIDoc, but available from in the struc package. Its parameter is the atomic number and returns the mass number of the most abundant isotope of the given atom. Then you can call the getMass function of the same class to have the exact mass number of that isotope. For example (nitrogen):
|getMass(7, getMostFrequentNaturalIsotope(7)); |
will return 14.003074005
It seems, however, that you want to calculate the exact mass of a molecule using the mass of the most frequent isotopes. This is often needed for MS molecule and fragment ion calculations.
We have the ElementalAnalyser plugin which directly calculates the exact mass. Just call its exactMass function and you will get the desired value. http://www.chemaxon.com/marvin/doc/api/chemaxon/marvin/calculations/ElementalAnalyserPlugin.html
So you probably do not have to access the PeriodicSystem class, since ElementalAnalyser offers the required functionality for you (even taking care of implicit hydrogens).
From the url you gave me, I couldn't find exactMass method from class ElementalAnalyserPlugin.
The exact mass calculation can be accessed through our general plugin mechanism. Enclosed please find an example code and a SMILES molecule.
|java ElemAnalTest test.smiles |
Getting the result from the plugin is not very user friendly at the moment, therefore we will add some nice functions to this plugin so that exact mass could be get by a call to ElementalAnalyserPlugin.exactMass(). This will be available in the next Marvin release coming out soon.
I hope this will help. Some more plugin usage examples can be found
in the API headers of some plugin classes, see:
The ElementalAnalyserPlugin class is our example plugin demonstrating how developers can create their own plugins. It embeds the ElementalAnalyser class, which actually has the exactMass function.
We decided to make this embedded class directly available in the next release, so the plugin layer will not be needed if you want to access the exact mass calculation (and some other useful functions) from code. The corresponding plugin will still be there as a free sample plugin.