Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New and faster method to generate the isotope pattern from a molecula…
…r formula. git-svn-id: https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/cdk-1.2.x@13221 eb4e18e3-b210-0410-a6ab-dec725e4b171
- Loading branch information
miguelrojasch
committed
Nov 22, 2008
1 parent
9cd2a65
commit d1527c6
Showing
12 changed files
with
1,453 additions
and
625 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
src/main/org/openscience/cdk/formula/IsotopeContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package org.openscience.cdk.formula; | ||
|
||
import org.openscience.cdk.annotations.TestClass; | ||
import org.openscience.cdk.annotations.TestMethod; | ||
import org.openscience.cdk.interfaces.IMolecularFormula; | ||
import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; | ||
|
||
|
||
/** | ||
* This class defines a isotope container. It contains in principle a | ||
* IMolecularFormula, a mass and intensity/abundance value. | ||
* | ||
* @author Miguel Rojas Cherto | ||
* | ||
* @cdk.module formula | ||
*/ | ||
@TestClass("org.openscience.cdk.formula.IsotopeContainerTest") | ||
public class IsotopeContainer{ | ||
private IMolecularFormula form; | ||
private double masOs; | ||
private double inte; | ||
|
||
/** | ||
* Constructor of the IsotopeContainer object. | ||
*/ | ||
public IsotopeContainer(){ | ||
|
||
} | ||
/** | ||
* Constructor of the IsotopeContainer object setting a IMolecularFormula | ||
* object and intensity value. | ||
* | ||
* @param formula The formula of this container | ||
* @param intensity The intensity of this container | ||
*/ | ||
@TestMethod("testIsotopeContainer_IMolecularFormula_double") | ||
public IsotopeContainer(IMolecularFormula formula, double intensity){ | ||
form = formula; | ||
if(formula != null) | ||
masOs = MolecularFormulaManipulator.getTotalExactMass(formula); | ||
inte = intensity; | ||
} | ||
/** | ||
* Constructor of the IsotopeContainer object setting a mass | ||
* and intensity value. | ||
* | ||
* @param mass The mass of this container | ||
* @param intensity The intensity of this container | ||
*/ | ||
@TestMethod("testIsotopeContainer_double_double") | ||
public IsotopeContainer(double mass, double intensity){ | ||
masOs = mass; | ||
inte = intensity; | ||
} | ||
/** | ||
* Set IMolecularFormula object of this container. | ||
* | ||
* @param formula The IMolecularFormula of the this container | ||
*/ | ||
@TestMethod("testSetFormula_IMolecularFormula") | ||
public void setFormula(IMolecularFormula formula){ | ||
form = formula; | ||
} | ||
/** | ||
* Set the mass value of this container. | ||
* | ||
* @param mass The mass of the this container | ||
*/ | ||
@TestMethod("testSetMass_double") | ||
public void setMass(double mass){ | ||
masOs = mass; | ||
} | ||
|
||
/** | ||
* Set the intensity value of this container. | ||
* | ||
* @param intensity The intensity of the this container | ||
*/ | ||
@TestMethod("testSetIntensity_double") | ||
public void setIntensity(double intensity){ | ||
inte = intensity; | ||
} | ||
/** | ||
* Get the IMolecularFormula object of this container. | ||
* | ||
* @return The IMolecularformula of the this container | ||
*/ | ||
@TestMethod("testGetFormula") | ||
public IMolecularFormula getFormula(){ | ||
return form; | ||
} | ||
/** | ||
* Get the mass value of this container. | ||
* | ||
* @return The mass of the this container | ||
*/ | ||
@TestMethod("testGetMass") | ||
public double getMass(){ | ||
return masOs; | ||
} | ||
|
||
/** | ||
* Get the intensity value of this container. | ||
* | ||
* @return The intensity of the this container | ||
*/ | ||
@TestMethod("testGetIntensity") | ||
public double getIntensity(){ | ||
return inte; | ||
} | ||
/** | ||
* Clones this IsotopeContainer object and its content. | ||
* | ||
* @return The cloned object | ||
*/ | ||
@TestMethod("testClone") | ||
public Object clone() throws CloneNotSupportedException { | ||
IsotopeContainer isoClone = new IsotopeContainer(); | ||
isoClone.setFormula(getFormula()); | ||
isoClone.setIntensity(getIntensity()); | ||
isoClone.setMass(getMass()); | ||
return isoClone; | ||
} | ||
|
||
} |
132 changes: 132 additions & 0 deletions
132
src/main/org/openscience/cdk/formula/IsotopePattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package org.openscience.cdk.formula; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.openscience.cdk.annotations.TestClass; | ||
import org.openscience.cdk.annotations.TestMethod; | ||
|
||
|
||
|
||
/** | ||
* This class defines the properties of a deisotoped | ||
* pattern distribution. A isotope pattern is a set of | ||
* compounds with different set of isotopes. | ||
* | ||
* @author Miguel Rojas Cherto | ||
* | ||
* @cdk.module formula | ||
*/ | ||
@TestClass("org.openscience.cdk.formula.IsotopePatternTest") | ||
public class IsotopePattern { | ||
|
||
private List<IsotopeContainer> isotopeCList = new ArrayList<IsotopeContainer>(); | ||
|
||
private int monoIsotopePosition; | ||
|
||
private double chargI=0; | ||
|
||
/** | ||
* Constructor of the IsotopePattern object. | ||
*/ | ||
public IsotopePattern(){ | ||
|
||
} | ||
/** | ||
* Set the mono isotope object. | ||
* | ||
* @param isoContainer The IsotopeContainer object | ||
*/ | ||
@TestMethod("testSetMonoIsotope_IsotopeContainer") | ||
public void setMonoIsotope(IsotopeContainer isoContainer){ | ||
isotopeCList.add(isoContainer); | ||
monoIsotopePosition = isotopeCList.indexOf(isoContainer); | ||
} | ||
/** | ||
* Add an isotope object. | ||
* | ||
* @param isoContainer The IsotopeContainer object | ||
*/ | ||
@TestMethod("testAddIsotope_IsotopeContainer") | ||
public void addIsotope(IsotopeContainer isoContainer){ | ||
isotopeCList.add(isoContainer); | ||
} | ||
/** | ||
* Returns the mono-isotope peak that form this isotope pattern. | ||
* | ||
* @return The IsotopeContainer acting as mono-isotope | ||
*/ | ||
@TestMethod("testGetMonoIsotope") | ||
public IsotopeContainer getMonoIsotope(){ | ||
return isotopeCList.get(monoIsotopePosition); | ||
} | ||
|
||
/** | ||
* Returns the all isotopes that form this isotope pattern. | ||
* | ||
* @return The IsotopeContainer acting as mono-isotope | ||
*/ | ||
@TestMethod("testGetIsotopes") | ||
public List<IsotopeContainer > getIsotopes(){ | ||
return isotopeCList; | ||
} | ||
/** | ||
* Returns the a isotopes given a specific position. | ||
* | ||
* @param The position | ||
* @return The isotope | ||
*/ | ||
@TestMethod("testGetIsotope_int") | ||
public IsotopeContainer getIsotope(int position){ | ||
return isotopeCList.get(position); | ||
} | ||
/** | ||
* Returns the number of isotopes in this pattern. | ||
* | ||
* @return The number of isotopes | ||
*/ | ||
@TestMethod("testGetNumberOfIsotopes") | ||
public int getNumberOfIsotopes(){ | ||
return isotopeCList.size(); | ||
} | ||
|
||
/** | ||
* Set the charge in this pattern. | ||
* | ||
* @param charge The charge value | ||
*/ | ||
@TestMethod("testSetCharge_double") | ||
public void setCharge(double charge) { | ||
chargI = charge; | ||
|
||
} | ||
|
||
/** | ||
* Get the charge in this pattern. | ||
* | ||
* @return The charge value | ||
*/ | ||
@TestMethod("testGetCharge") | ||
public double getCharge() { | ||
return chargI; | ||
|
||
} | ||
/** | ||
* Clones this IsotopePattern object and its content. | ||
* | ||
* @return The cloned object | ||
*/ | ||
@TestMethod("testClone") | ||
public Object clone() throws CloneNotSupportedException { | ||
IsotopePattern isoClone = new IsotopePattern(); | ||
IsotopeContainer isoHighest = getMonoIsotope(); | ||
for(IsotopeContainer isoContainer: isotopeCList){ | ||
if(isoHighest.equals(isoContainer)) | ||
isoClone.setMonoIsotope((IsotopeContainer) isoContainer.clone()); | ||
else | ||
isoClone.addIsotope((IsotopeContainer) isoContainer.clone()); | ||
} | ||
isoClone.setCharge(getCharge()); | ||
return isoClone; | ||
} | ||
} |
Oops, something went wrong.