public class MolecularFormulaManipulator extends Object
IMolecularFormula
's. For example:Modifier and Type | Field and Description |
---|---|
static int |
MolWeight
For use with
getMass(IMolecularFormula) . |
static int |
MolWeightIgnoreSpecified
For use with
getMass(IMolecularFormula) . |
static int |
MonoIsotopic
For use with
getMass(IMolecularFormula) . |
static int |
MostAbundant
For use with
getMass(IMolecularFormula) . |
static Comparator<IIsotope> |
NAT_ABUN_COMP |
Constructor and Description |
---|
MolecularFormulaManipulator() |
Modifier and Type | Method and Description |
---|---|
static boolean |
adjustProtonation(IMolecularFormula mf,
int hcnt)
Adjust the protonation of a molecular formula.
|
static boolean |
compare(IMolecularFormula formula1,
IMolecularFormula formula2)
Compare two IMolecularFormula looking at type and number of IIsotope and
charge of the formula.
|
static boolean |
containsElement(IMolecularFormula formula,
IElement element)
True, if the MolecularFormula contains the given element as IIsotope object.
|
static List<IElement> |
elements(IMolecularFormula formula)
Get a list of all Elements which are contained
molecular.
|
static String[] |
generateOrderEle()
Returns the Elements ordered according to (approximate) probability of occurrence.
|
static IAtomContainer |
getAtomContainer(IMolecularFormula formula)
Method that actually does the work of convert the IMolecularFormula
to IAtomContainer.
|
static IAtomContainer |
getAtomContainer(IMolecularFormula formula,
IAtomContainer atomContainer)
Method that actually does the work of convert the IMolecularFormula
to IAtomContainer given a IAtomContainer.
|
static IAtomContainer |
getAtomContainer(String formulaString,
IChemObjectBuilder builder)
Converts a formula string (like "C2H4") into an atom container with atoms
but no bonds.
|
static int |
getAtomCount(IMolecularFormula formula)
Checks a set of Nodes for the occurrence of each isotopes
instance in the molecular formula.
|
static double |
getDBE(IMolecularFormula formula)
Returns the number of double bond equivalents in this molecule.
|
static int |
getElementCount(IMolecularFormula formula,
IElement element)
Checks a set of Nodes for the occurrence of the isotopes in the
molecular formula from a particular IElement.
|
static int |
getElementCount(IMolecularFormula formula,
IIsotope isotope)
Occurrences of a given element from an isotope in a molecular formula.
|
static int |
getElementCount(IMolecularFormula formula,
String symbol)
Occurrences of a given element in a molecular formula.
|
static List<IElement> |
getHeavyElements(IMolecularFormula formula)
Returns a set of nodes excluding all the hydrogens.
|
static String |
getHillString(IMolecularFormula formula)
Deprecated.
|
static String |
getHTML(IMolecularFormula formula)
Returns the string representation of the molecular formula based on Hill
System with numbers wrapped in <sub></sub> tags.
|
static String |
getHTML(IMolecularFormula formula,
boolean chargeB,
boolean isotopeB)
Returns the string representation of the molecular formula based on Hill
System with numbers wrapped in <sub></sub> tags and the
isotope of each Element in <sup></sup> tags and the total
charge of IMolecularFormula in <sup></sup> tags.
|
static String |
getHTML(IMolecularFormula formula,
String[] orderElements,
boolean showCharge,
boolean showIsotopes)
Returns the string representation of the molecular formula with numbers
wrapped in <sub></sub> tags and the isotope of each Element
in <sup></sup> tags and the total showCharge of IMolecularFormula
in <sup></sup> tags.
|
static List<IIsotope> |
getIsotopes(IMolecularFormula formula,
IElement element)
Get a list of IIsotope from a given IElement which is contained
molecular.
|
static double |
getMajorIsotopeMass(IMolecularFormula formula)
Deprecated.
use
getMass(IMolecularFormula, int) with option
MonoIsotopic . |
static IMolecularFormula |
getMajorIsotopeMolecularFormula(String stringMF,
IChemObjectBuilder builder)
Construct an instance of IMolecularFormula, initialized with a molecular
formula string.
|
static double |
getMass(IMolecularFormula mf)
Calculate the mass of a formula, this function takes an optional
'mass flavour' that switches the computation type.
|
static double |
getMass(IMolecularFormula mf,
int flav)
Calculate the mass of a formula, this function takes an optional
'mass flavour' that switches the computation type.
|
static IMolecularFormula |
getMolecularFormula(IAtomContainer atomContainer)
Method that actually does the work of convert the atomContainer
to IMolecularFormula.
|
static IMolecularFormula |
getMolecularFormula(IAtomContainer atomContainer,
IMolecularFormula formula)
Method that actually does the work of convert the atomContainer
to IMolecularFormula given a IMolecularFormula.
|
static IMolecularFormula |
getMolecularFormula(String stringMF,
IChemObjectBuilder builder)
Construct an instance of IMolecularFormula, initialized with a molecular
formula string.
|
static IMolecularFormula |
getMolecularFormula(String stringMF,
IMolecularFormula formula)
add in a instance of IMolecularFormula the elements extracts form
molecular formula string.
|
static IMolecularFormula |
getMostAbundant(IAtomContainer mol)
Compute the most abundant MF.
|
static IMolecularFormula |
getMostAbundant(IMolecularFormula mf)
Compute the most abundant MF.
|
static double |
getNaturalExactMass(IMolecularFormula formula)
Deprecated.
use
getMass(IMolecularFormula, int) with option
MolWeightIgnoreSpecified . |
static String |
getString(IMolecularFormula formula)
Returns the string representation of the molecular formula.
|
static String |
getString(IMolecularFormula formula,
boolean setOne)
Returns the string representation of the molecular formula.
|
static String |
getString(IMolecularFormula formula,
boolean setOne,
boolean setMassNumber)
Returns the string representation of the molecular formula.
|
static String |
getString(IMolecularFormula formula,
String[] orderElements,
boolean setOne)
Returns the string representation of the molecular formula.
|
static String |
getString(IMolecularFormula formula,
String[] orderElements,
boolean setOne,
boolean setMassNumber)
Returns the string representation of the molecular formula.
|
static double |
getTotalExactMass(IMolecularFormula formula)
Deprecated.
calls
getMass(IMolecularFormula, int) with option
MonoIsotopic and adjusts for charge with
correctMass(double, Integer) . These functions should be used
directly. |
static double |
getTotalMassNumber(IMolecularFormula formula)
Get the summed mass number of all isotopes from an MolecularFormula.
|
static double |
getTotalNaturalAbundance(IMolecularFormula formula)
Get the summed natural abundance of all isotopes from an MolecularFormula.
|
static List<IIsotope> |
putInOrder(String[] orderElements,
IMolecularFormula formula) |
static IMolecularFormula |
removeElement(IMolecularFormula formula,
IElement element)
Removes all isotopes from a given element in the MolecularFormula.
|
static String |
simplifyMolecularFormula(String formula)
Simplify the molecular formula.
|
public static final int MolWeight
getMass(IMolecularFormula)
. This option uses the mass
stored on atoms (IIsotope.getExactMass()
) or the average mass of the
element when unspecified.public static final int MolWeightIgnoreSpecified
getMass(IMolecularFormula)
. This option ignores the
mass stored on atoms (IIsotope.getExactMass()
) and uses the average
mass of each element. This option is primarily provided for backwards
compatibility.public static final int MonoIsotopic
getMass(IMolecularFormula)
. This option uses the mass
stored on atoms IIsotope.getExactMass()
or the mass of the major
isotope when this is not specified.public static final int MostAbundant
getMass(IMolecularFormula)
. This option uses the mass
stored on atoms IIsotope.getExactMass()
and then calculates a
distribution for any unspecified atoms and uses the most abundant
distribution. For example C6Br6 would have three
79Br and 81Br because their abundance is 51 and
49%.public static final Comparator<IIsotope> NAT_ABUN_COMP
public static int getAtomCount(IMolecularFormula formula)
formula
- The MolecularFormula to checkpublic static int getElementCount(IMolecularFormula formula, IElement element)
formula
- The MolecularFormula to checkelement
- The IElement objectpublic static int getElementCount(IMolecularFormula formula, IIsotope isotope)
formula
- the formulaisotope
- isotope of an elementgetElementCount(IMolecularFormula, IElement)
public static int getElementCount(IMolecularFormula formula, String symbol)
formula
- the formulasymbol
- element symbol (e.g. C for carbon)getElementCount(IMolecularFormula, IElement)
public static List<IIsotope> getIsotopes(IMolecularFormula formula, IElement element)
formula
- The MolecularFormula to checkelement
- The IElement objectpublic static List<IElement> elements(IMolecularFormula formula)
formula
- The MolecularFormula to checkpublic static boolean containsElement(IMolecularFormula formula, IElement element)
formula
- IMolecularFormula molecularFormulaelement
- The element this MolecularFormula is searched forpublic static IMolecularFormula removeElement(IMolecularFormula formula, IElement element)
formula
- IMolecularFormula molecularFormulaelement
- The IElement of the IIsotopes to be removedpublic static String getString(IMolecularFormula formula, String[] orderElements, boolean setOne)
formula
- The IMolecularFormula ObjectorderElements
- The order of ElementssetOne
- True, when must be set the value 1 for elements with
one atomgetHTML(IMolecularFormula)
,
generateOrderEle()
,
generateOrderEle_Hill_NoCarbons()
,
generateOrderEle_Hill_WithCarbons()
public static String getString(IMolecularFormula formula, String[] orderElements, boolean setOne, boolean setMassNumber)
formula
- The IMolecularFormula ObjectorderElements
- The order of ElementssetOne
- True, when must be set the value 1 for elements with
one atomsetMassNumber
- If the formula contains an isotope of an element that is the
non-major isotope, the element is represented as [XE]
where
X
is the mass number and E
is the element symbolgetHTML(IMolecularFormula)
,
generateOrderEle()
,
generateOrderEle_Hill_NoCarbons()
,
generateOrderEle_Hill_WithCarbons()
public static String getString(IMolecularFormula formula)
formula
- The IMolecularFormula ObjectgetHTML(IMolecularFormula)
public static String getString(IMolecularFormula formula, boolean setOne)
formula
- The IMolecularFormula ObjectsetOne
- True, when must be set the value 1 for elements with
one atomgetHTML(IMolecularFormula)
public static String getString(IMolecularFormula formula, boolean setOne, boolean setMassNumber)
formula
- The IMolecularFormula ObjectsetOne
- True, when must be set the value 1 for elements with
one atomsetMassNumber
- If the formula contains an isotope of an element that is the
non-major isotope, the element is represented as [XE]
where
X
is the mass number and E
is the element symbolgetHTML(IMolecularFormula)
public static List<IIsotope> putInOrder(String[] orderElements, IMolecularFormula formula)
@Deprecated public static String getHillString(IMolecularFormula formula)
getString(org.openscience.cdk.interfaces.IMolecularFormula)
public static String getHTML(IMolecularFormula formula)
formula
- The IMolecularFormula objectgetHTML(IMolecularFormula, boolean, boolean)
public static String getHTML(IMolecularFormula formula, boolean chargeB, boolean isotopeB)
formula
- The IMolecularFormula objectchargeB
- True, If it has to show the chargeisotopeB
- True, If it has to show the Isotope massgetHTML(IMolecularFormula)
public static String getHTML(IMolecularFormula formula, String[] orderElements, boolean showCharge, boolean showIsotopes)
formula
- The IMolecularFormula objectorderElements
- The order of ElementsshowCharge
- True, If it has to show the showChargeshowIsotopes
- True, If it has to show the Isotope massgetHTML(IMolecularFormula)
public static IMolecularFormula getMolecularFormula(String stringMF, IChemObjectBuilder builder)
The hydrogens must be implicit.
stringMF
- The molecularFormula stringbuilder
- a IChemObjectBuilder which is used to construct atomsgetMolecularFormula(String,IMolecularFormula)
public static IMolecularFormula getMajorIsotopeMolecularFormula(String stringMF, IChemObjectBuilder builder)
stringMF
- The molecularFormula stringbuilder
- a IChemObjectBuilder which is used to construct atomsgetMolecularFormula(String,IMolecularFormula)
public static IMolecularFormula getMolecularFormula(String stringMF, IMolecularFormula formula)
The hydrogens must be implicit.
stringMF
- The molecularFormula stringgetMolecularFormula(String, IChemObjectBuilder)
@Deprecated public static double getTotalExactMass(IMolecularFormula formula)
getMass(IMolecularFormula, int)
with option
MonoIsotopic
and adjusts for charge with
correctMass(double, Integer)
. These functions should be used
directly.public static double getTotalMassNumber(IMolecularFormula formula)
formula
- The IMolecularFormula to calculatepublic static double getMass(IMolecularFormula mf, int flav)
IIsotope.setMassNumber(Integer)
or IIsotope.setExactMass(Double)
set to non-null and non-zero.
MolWeight
(default) - uses the exact mass of each
atom when an isotope is specified, if not specified the average mass
of the element is used.MolWeightIgnoreSpecified
- uses the average mass of each
element, ignoring any isotopic/exact mass specificationMonoIsotopic
- uses the exact mass of each
atom when an isotope is specified, if not specified the major isotope
mass for that element is used.MostAbundant
- uses the exact mass of each atom when
specified, if not specified a distribution is calculated and the
most abundant isotope pattern is used.mf
- molecular formulaflav
- flavorgetMass(IMolecularFormula, int)
,
MolWeight
,
MolWeightIgnoreSpecified
,
MonoIsotopic
,
MostAbundant
public static double getMass(IMolecularFormula mf)
IIsotope.setMassNumber(Integer)
or IIsotope.setExactMass(Double)
set to non-null and non-zero.
MolWeight
(default) - uses the exact mass of each
atom when an isotope is specified, if not specified the average mass
of the element is used.MolWeightIgnoreSpecified
- uses the average mass of each
element, ignoring any isotopic/exact mass specificationMonoIsotopic
- uses the exact mass of each
atom when an isotope is specified, if not specified the major isotope
mass for that element is used.MostAbundant
- uses the exact mass of each atom when
specified, if not specified a distribution is calculated and the
most abundant isotope pattern is used.mf
- molecular formulagetMass(IMolecularFormula, int)
,
MolWeight
,
MolWeightIgnoreSpecified
,
MonoIsotopic
,
MostAbundant
@Deprecated public static double getNaturalExactMass(IMolecularFormula formula)
getMass(IMolecularFormula, int)
with option
MolWeightIgnoreSpecified
.@Deprecated public static double getMajorIsotopeMass(IMolecularFormula formula)
getMass(IMolecularFormula, int)
with option
MonoIsotopic
.public static double getTotalNaturalAbundance(IMolecularFormula formula)
formula
- The IMolecularFormula to calculatepublic static double getDBE(IMolecularFormula formula) throws CDKException
formula
- The IMolecularFormula to calculateCDKException
- if DBE cannot be be evaluatedpublic static IMolecularFormula getMolecularFormula(IAtomContainer atomContainer)
The hydrogens must be implicit.
atomContainer
- IAtomContainer objectgetMolecularFormula(IAtomContainer,IMolecularFormula)
public static IMolecularFormula getMolecularFormula(IAtomContainer atomContainer, IMolecularFormula formula)
The hydrogens must be implicit.
atomContainer
- IAtomContainer objectformula
- IMolecularFormula molecularFormula to put the new IsotopesgetMolecularFormula(IAtomContainer)
public static IAtomContainer getAtomContainer(IMolecularFormula formula)
The hydrogens must be implicit.
formula
- IMolecularFormula objectgetAtomContainer(IMolecularFormula, IAtomContainer)
public static IAtomContainer getAtomContainer(IMolecularFormula formula, IAtomContainer atomContainer)
The hydrogens must be implicit.
formula
- IMolecularFormula objectatomContainer
- IAtomContainer to put the new ElementsgetAtomContainer(IMolecularFormula)
public static IAtomContainer getAtomContainer(String formulaString, IChemObjectBuilder builder)
formulaString
- the formula to convertbuilder
- a chem object builderpublic static String[] generateOrderEle()
This begins with the "elements of life" C, H, O, N, (Si, P, S, F, Cl), then continues with the "common" chemical synthesis ingredients, closing off with the tail-end of the periodic table in atom-number order and finally the generic R-group.
public static boolean compare(IMolecularFormula formula1, IMolecularFormula formula2)
formula1
- The first IMolecularFormulaformula2
- The second IMolecularFormulapublic static List<IElement> getHeavyElements(IMolecularFormula formula)
formula
- The IMolecularFormulapublic static String simplifyMolecularFormula(String formula)
formula
- The molecular formulapublic static boolean adjustProtonation(IMolecularFormula mf, int hcnt)
IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[C6H5O]-", bldr); MolecularFormulaManipulator.adjustProtonation(mf, +1); // now "C6H6O" MolecularFormulaManipulator.adjustProtonation(mf, -1); // now "C6H5O-"The return value indicates whether the protonation could be adjusted:
IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[Cl]-", bldr); MolecularFormulaManipulator.adjustProtonation(mf, +0); // false still "[Cl]-" MolecularFormulaManipulator.adjustProtonation(mf, +1); // true now "HCl" MolecularFormulaManipulator.adjustProtonation(mf, -1); // true now "[Cl]-" (again) MolecularFormulaManipulator.adjustProtonation(mf, -1); // false still "[Cl]-" (no H to remove!)The method tries to select an existing hydrogen isotope to augment. If no hydrogen isotopes are found a new major isotope (1H) is created.
mf
- molecular formulahcnt
- the number of hydrogens to add/remove, (>0 protonate:, <0: deprotonate)public static IMolecularFormula getMostAbundant(IMolecularFormula mf)
mf
- a molecular formula with unspecified isotopespublic static IMolecularFormula getMostAbundant(IAtomContainer mol)
mol
- a molecule with unspecified isotopesCopyright © 2021. All rights reserved.