Package org.openscience.cdk.debug
Class DebugMolecularFormula
- java.lang.Object
-
- org.openscience.cdk.formula.MolecularFormula
-
- org.openscience.cdk.debug.DebugMolecularFormula
-
- All Implemented Interfaces:
Cloneable
,ICDKObject
,IMolecularFormula
public class DebugMolecularFormula extends MolecularFormula implements IMolecularFormula
Debugging implementation ofIMolecularFormula
.- Source code:
- main
- Belongs to CDK module:
- datadebug
-
-
Constructor Summary
Constructors Constructor Description DebugMolecularFormula()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMolecularFormula
add(IMolecularFormula formula)
Adds an molecularFormula to this MolecularFormula.IMolecularFormula
addIsotope(IIsotope isotope)
Adds an Isotope to this MolecularFormula one time.IMolecularFormula
addIsotope(IIsotope isotope, int count)
Adds an Isotope to this MolecularFormula in a number of occurrences.boolean
contains(IIsotope isotope)
True, if the MolecularFormula contains the given IIsotope object and not the instance.IChemObjectBuilder
getBuilder()
Returns aIChemObjectBuilder
for the data classes that extend this class.Integer
getCharge()
Access the charge of this IMolecularFormula.int
getIsotopeCount()
Checks a set of Nodes for the number of different isotopes in the IMolecularFormula.int
getIsotopeCount(IIsotope isotope)
Checks a set of Nodes for the occurrence of the isotope in the IMolecularFormula from a particular isotope.Map<Object,Object>
getProperties()
Returns a Map with the IChemObject's properties.I should integrate into ChemObject.<T> T
getProperty(Object description)
Returns a property for the IChemObject - the object is automatically cast to the required type.Iterable<IIsotope>
isotopes()
Returns an Iterator for looping over all isotopes in this IMolecularFormula.void
removeAllIsotopes()
Removes all isotopes of this molecular formula.void
removeIsotope(IIsotope isotope)
Removes the given isotope from the MolecularFormula.void
removeProperty(Object description)
Removes a property for a IChemObject.void
setCharge(Integer charge)
Sets the charge of this IMolecularFormula, since there is no atom associated with the charge the number of a given isotope is not modified.void
setProperties(Map<Object,Object> properties)
Sets the properties of this object.void
setProperty(Object description, Object property)
Sets a property for a IChemObject.-
Methods inherited from class org.openscience.cdk.formula.MolecularFormula
clone, getProperty, isTheSame
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.IMolecularFormula
clone, getProperty
-
-
-
-
Method Detail
-
add
public IMolecularFormula add(IMolecularFormula formula)
Adds an molecularFormula to this MolecularFormula.- Specified by:
add
in interfaceIMolecularFormula
- Overrides:
add
in classMolecularFormula
- Parameters:
formula
- The molecularFormula to be added to this chemObject- Returns:
- The IMolecularFormula
-
addIsotope
public IMolecularFormula addIsotope(IIsotope isotope)
Adds an Isotope to this MolecularFormula one time.- Specified by:
addIsotope
in interfaceIMolecularFormula
- Overrides:
addIsotope
in classMolecularFormula
- Parameters:
isotope
- The isotope to be added to this MolecularFormula- Returns:
- the new molecular formula
- See Also:
MolecularFormula.addIsotope(IIsotope, int)
-
addIsotope
public IMolecularFormula addIsotope(IIsotope isotope, int count)
Adds an Isotope to this MolecularFormula in a number of occurrences.- Specified by:
addIsotope
in interfaceIMolecularFormula
- Overrides:
addIsotope
in classMolecularFormula
- Parameters:
isotope
- The isotope to be added to this MolecularFormulacount
- The number of occurrences to add- Returns:
- the new molecular formula
- See Also:
MolecularFormula.addIsotope(IIsotope)
-
contains
public boolean contains(IIsotope isotope)
True, if the MolecularFormula contains the given IIsotope object and not the instance. The method looks for other isotopes which has the same symbol, natural abundance and exact mass.- Specified by:
contains
in interfaceIMolecularFormula
- Overrides:
contains
in classMolecularFormula
- Parameters:
isotope
- The IIsotope this MolecularFormula is searched for- Returns:
- True, if the MolecularFormula contains the given isotope object
-
getCharge
public Integer getCharge()
Access the charge of this IMolecularFormula. If the charge has not been set the return value is null.- Specified by:
getCharge
in interfaceIMolecularFormula
- Overrides:
getCharge
in classMolecularFormula
- Returns:
- the charge of this IMolecularFormula
- See Also:
IMolecularFormula.setCharge(java.lang.Integer)
-
getIsotopeCount
public int getIsotopeCount(IIsotope isotope)
Checks a set of Nodes for the occurrence of the isotope in the IMolecularFormula from a particular isotope. It returns 0 if the does not exist.- Specified by:
getIsotopeCount
in interfaceIMolecularFormula
- Overrides:
getIsotopeCount
in classMolecularFormula
- Parameters:
isotope
- The IIsotope to look for- Returns:
- The occurrence of this isotope in this IMolecularFormula
- See Also:
MolecularFormula.getIsotopeCount()
-
getIsotopeCount
public int getIsotopeCount()
Checks a set of Nodes for the number of different isotopes in the IMolecularFormula.- Specified by:
getIsotopeCount
in interfaceIMolecularFormula
- Overrides:
getIsotopeCount
in classMolecularFormula
- Returns:
- The the number of different isotopes in this IMolecularFormula
- See Also:
MolecularFormula.getIsotopeCount(IIsotope)
-
getProperties
public Map<Object,Object> getProperties()
Returns a Map with the IChemObject's properties.I should integrate into ChemObject.- Specified by:
getProperties
in interfaceIMolecularFormula
- Overrides:
getProperties
in classMolecularFormula
- Returns:
- The object's properties as an Hashtable
- See Also:
MolecularFormula.setProperties(java.util.Map<java.lang.Object, java.lang.Object>)
-
getProperty
public <T> T getProperty(Object description)
Returns a property for the IChemObject - the object is automatically cast to the required type. This does however mean if the wrong type is provided then a runtime ClassCastException will be thrown.IAtom atom = new Atom("C"); atom.setProperty("number", 1); // set an integer property // access the property and automatically cast to an int Integer number = atom.getProperty("number"); // if the method is in a chain or needs to be nested the type // can be provided methodAcceptingInt(atom.getProperty("number", Integer.class)); // the type cannot be checked and so... String number = atom.getProperty("number"); // ClassCastException // if the type is provided a more meaningful error is thrown atom.getProperty("number", String.class); // IllegalArgumentException
- Specified by:
getProperty
in interfaceIMolecularFormula
- Overrides:
getProperty
in classMolecularFormula
- Type Parameters:
T
- generic return type- Parameters:
description
- An object description of the property (most likely a unique string)- Returns:
- The object containing the property. Returns null if property is not set.
- See Also:
IMolecularFormula.setProperty(java.lang.Object, java.lang.Object)
,IMolecularFormula.getProperty(Object, Class)
,IMolecularFormula.removeProperty(java.lang.Object)
-
isotopes
public Iterable<IIsotope> isotopes()
Returns an Iterator for looping over all isotopes in this IMolecularFormula.- Specified by:
isotopes
in interfaceIMolecularFormula
- Overrides:
isotopes
in classMolecularFormula
- Returns:
- An Iterator with the isotopes in this IMolecularFormula
-
removeAllIsotopes
public void removeAllIsotopes()
Removes all isotopes of this molecular formula.- Specified by:
removeAllIsotopes
in interfaceIMolecularFormula
- Overrides:
removeAllIsotopes
in classMolecularFormula
-
removeIsotope
public void removeIsotope(IIsotope isotope)
Removes the given isotope from the MolecularFormula.- Specified by:
removeIsotope
in interfaceIMolecularFormula
- Overrides:
removeIsotope
in classMolecularFormula
- Parameters:
isotope
- The IIsotope to be removed
-
removeProperty
public void removeProperty(Object description)
Removes a property for a IChemObject. I should integrate into ChemObject.- Specified by:
removeProperty
in interfaceIMolecularFormula
- Overrides:
removeProperty
in classMolecularFormula
- Parameters:
description
- The object description of the property (most likely a unique string)- See Also:
MolecularFormula.setProperty(java.lang.Object, java.lang.Object)
,MolecularFormula.getProperty(java.lang.Object)
-
setCharge
public void setCharge(Integer charge)
Sets the charge of this IMolecularFormula, since there is no atom associated with the charge the number of a given isotope is not modified.// Correct usage IMolecularFormula phenolate = MolecularFormulaManipulator.getMolecularFormula("C6H5O", builder) mf.setCharge(-1); // MF=C6H5O- // Wrong! the H6 is not automatically adjust IMolecularFormula phenolate = MolecularFormulaManipulator.getMolecularFormula("C6H6O", builder) mf.setCharge(-1); // MF=C6H6O- (wrong)
If you wish to adjust the protonation of a formula try the convenience method of theMolecularFormulaManipulator
:IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[C6H5O]-", bldr); MolecularFormulaManipulator.adjustProtonation(mf, +1); MolecularFormulaManipulator.getString(mf); // "C6H6O"
- Specified by:
setCharge
in interfaceIMolecularFormula
- Overrides:
setCharge
in classMolecularFormula
- Parameters:
charge
- The partial charge- See Also:
IMolecularFormula.getCharge()
-
setProperties
public void setProperties(Map<Object,Object> properties)
Sets the properties of this object.- Specified by:
setProperties
in interfaceIMolecularFormula
- Overrides:
setProperties
in classMolecularFormula
- Parameters:
properties
- a Hashtable specifying the property values- See Also:
MolecularFormula.getProperties()
-
setProperty
public void setProperty(Object description, Object property)
Sets a property for a IChemObject. I should integrate into ChemObject.- Specified by:
setProperty
in interfaceIMolecularFormula
- Overrides:
setProperty
in classMolecularFormula
- Parameters:
description
- An object description of the property (most likely a unique string)property
- An object with the property itself- See Also:
MolecularFormula.getProperty(java.lang.Object)
,MolecularFormula.removeProperty(java.lang.Object)
-
getBuilder
public IChemObjectBuilder getBuilder()
Returns aIChemObjectBuilder
for the data classes that extend this class.- Specified by:
getBuilder
in interfaceICDKObject
- Overrides:
getBuilder
in classMolecularFormula
- Returns:
- The
IChemObjectBuilder
matching thisICDKObject
-
-