final int numOfIsotopes = pattern.getNumberOfIsotopes(); final double mzValues[] = new double[numOfIsotopes]; final float intensityValues[] = new float[numOfIsotopes]; IsotopeContainer isotope = pattern.getIsotope(i);
/** * Clones this IsotopePattern object and its content. * * @return The cloned object */ @Override 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; } }
try { IsotopePattern isoSort = (IsotopePattern) isotopeP.clone(); if (isoSort.getNumberOfIsotopes() == 0) return isoSort; List<IsotopeContainer> listISO = isoSort.getIsotopes(); Collections.sort(listISO, new Comparator<IsotopeContainer>() { @Override isoSort.setMonoIsotope(listISO.get(0));
for (IsotopeContainer sc : isopattern.getIsotopes()) { for (IsotopeContainer sc : isopattern.getIsotopes()) { IsotopePattern sortedIsoPattern = new IsotopePattern(); sortedIsoPattern.setMonoIsotope(new IsotopeContainer(isopattern.getIsotopes().get(0))); for (int i = 1; i < isopattern.getNumberOfIsotopes(); i++) { if (isopattern.getIsotopes().get(i).getIntensity() >= (minIntensity)) { IsotopeContainer container = new IsotopeContainer(isopattern.getIsotopes().get(i)); sortedIsoPattern.addIsotope(container);
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testGetIsotope_int() { IsotopePattern isoP = new IsotopePattern(); IsotopeContainer iso1 = new IsotopeContainer(); isoP.setMonoIsotope(iso1); IsotopeContainer iso2 = new IsotopeContainer(); isoP.addIsotope(iso2); Assert.assertEquals(iso1, isoP.getIsotope(0)); Assert.assertEquals(iso2, isoP.getIsotope(1)); }
/** * Real example. Lipid PC * * @throws Exception */ @Test public void testExperiment() { IsotopePattern spExp = new IsotopePattern(); spExp.setMonoIsotope(new IsotopeContainer(762.6006, 124118304)); spExp.addIsotope(new IsotopeContainer(763.6033, 57558840)); spExp.addIsotope(new IsotopeContainer(764.6064, 15432262)); spExp.setCharge(1.0); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C42H85NO8P", SilentChemObjectBuilder.getInstance()); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.01); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePatternSimilarity is = new IsotopePatternSimilarity(); double score = is.compare(spExp, patternIsoPredicted); Assert.assertEquals(0.97, score, .01); }
if (isoto1.getCharge() == 1) chargeToAdd = massE; else if (isoto1.getCharge() == -1) chargeToAdd = -massE; else chargeToAdd = 0; for (IsotopeContainer isoC : iso1.getIsotopes()) { double mass = isoC.getMass(); isoC.setMass(mass + chargeToAdd); int length = iso1.getNumberOfIsotopes(); IsotopeContainer isoContainer = iso1.getIsotopes().get(i); factor = isoContainer.getIntensity(); totalFactor += factor; if (closestDp == -1) continue; diffMass = isoContainer.getMass() - iso2.getIsotopes().get(closestDp).getMass(); diffMass = Math.abs(diffMass); diffAbun = 1.0d - (isoContainer.getIntensity() / iso2.getIsotopes().get(closestDp).getIntensity()); diffAbun = Math.abs(diffAbun);
@Test public void testGeneratorSavesState() { IsotopePatternGenerator isogen = new IsotopePatternGenerator(.1); IMolecularFormula mf1 = MolecularFormulaManipulator.getMolecularFormula("C6H12O6", builder); IsotopePattern ip1 = isogen.getIsotopes(mf1); Assert.assertEquals(1, ip1.getNumberOfIsotopes()); IMolecularFormula mf2 = MolecularFormulaManipulator.getMolecularFormula("C6H12O6", builder); IsotopePattern ip2 = isogen.getIsotopes(mf2); Assert.assertEquals(1, ip2.getNumberOfIsotopes()); }
/** * Search and find the closest difference in an array in terms of mass and * intensity. Always return the position in this List. * * @param diffValue The difference to look for * @param normMass A List of normalized masses * @return The position in the List */ private int getClosestDataDiff(IsotopeContainer isoContainer, IsotopePattern pattern) { double diff = 100; int posi = -1; for (int i = 0; i < pattern.getNumberOfIsotopes(); i++) { double tempDiff = Math.abs((isoContainer.getMass()) - pattern.getIsotopes().get(i).getMass()); if (tempDiff <= (tolerance_ppm / isoContainer.getMass()) && tempDiff < diff) { diff = tempDiff; posi = i; } } return posi; } }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testSetCharge_double() { IsotopePattern isoP = new IsotopePattern(); isoP.setCharge(1.0); Assert.assertEquals(1.0, isoP.getCharge(), 0.000001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testGetMonoIsotope() { IsotopePattern isoP = new IsotopePattern(); IsotopeContainer isoC = new IsotopeContainer(); isoP.setMonoIsotope(isoC); Assert.assertEquals(isoC, isoP.getMonoIsotope()); }
current = new IsotopePattern(); for (IsotopeContainer container : additional) current.addIsotope(container); } else { for (IsotopeContainer container : current.getIsotopes()) { for (IsotopeContainer other : additional) { current = new IsotopePattern(); for (IsotopeContainer container : containers) { current.addIsotope(container);
/** * Histidine example * * @throws Exception */ @Test public void testCompare_IsotopePattern_IsotopePattern() { IsotopePatternSimilarity is = new IsotopePatternSimilarity(); IsotopePattern spExp = new IsotopePattern(); spExp.setMonoIsotope(new IsotopeContainer(156.07770, 1)); spExp.addIsotope(new IsotopeContainer(157.07503, 0.0004)); spExp.addIsotope(new IsotopeContainer(157.08059, 0.0003)); spExp.addIsotope(new IsotopeContainer(158.08135, 0.002)); IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C6H10N3O2", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.1); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePattern patternIsoNormalize = IsotopePatternManipulator.normalize(patternIsoPredicted); double score = is.compare(spExp, patternIsoNormalize); Assert.assertNotSame(0.0, score); }
/** * Sets the parameters attribute of the IsotopePatternRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ @Override public void setParameters(Object[] params) throws CDKException { if (params.length != 2) throw new CDKException("IsotopePatternRule expects two parameter"); if (!(params[0] instanceof List)) throw new CDKException("The parameter one must be of type List<Double[]>"); if (!(params[1] instanceof Double)) throw new CDKException("The parameter two must be of type Double"); pattern = new IsotopePattern(); for (double[] listISO : (List<double[]>) params[0]) { pattern.addIsotope(new IsotopeContainer(listISO[0], listISO[1])); } is.seTolerance((Double) params[1]); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testGetCharge() { IsotopePattern isoP = new IsotopePattern(); Assert.assertEquals(0, isoP.getCharge(), 0.000001); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testSetMonoIsotope_IsotopeContainer() { IsotopePattern isoP = new IsotopePattern(); isoP.setMonoIsotope(new IsotopeContainer()); Assert.assertNotNull(isoP); }
/** * Gets the parameters attribute of the IsotopePatternRule object. * * @return The parameters value * @see #setParameters */ @Override public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[2]; if (pattern == null) params[0] = null; else { List<double[]> params0 = new ArrayList<double[]>(); for (IsotopeContainer isotope : pattern.getIsotopes()) { params0.add(new double[] { isotope.getMass(), isotope.getIntensity() }); } params[0] = params0; } params[1] = toleranceMass; return params; }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testIsotopePattern() { IsotopePattern isoP = new IsotopePattern(); Assert.assertNotNull(isoP); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testGetIsotopes() { IsotopePattern isoP = new IsotopePattern(); IsotopeContainer iso1 = new IsotopeContainer(); isoP.setMonoIsotope(iso1); IsotopeContainer iso2 = new IsotopeContainer(); isoP.addIsotope(iso2); Assert.assertEquals(iso1, isoP.getIsotopes().get(0)); Assert.assertEquals(iso2, isoP.getIsotopes().get(1)); }
/** * Histidine example * * @throws Exception */ @Test public void testSelectingMF() { IsotopePatternSimilarity is = new IsotopePatternSimilarity(); IsotopePattern spExp = new IsotopePattern(); spExp.setCharge(1); spExp.setMonoIsotope(new IsotopeContainer(156.07770, 1)); spExp.addIsotope(new IsotopeContainer(157.07503, 0.0101)); spExp.addIsotope(new IsotopeContainer(157.08059, 0.074)); spExp.addIsotope(new IsotopeContainer(158.08135, 0.0024)); double score = 0; String mfString = ""; String[] listMF = {"C4H8N6O", "C2H12N4O4", "C3H12N2O5", "C6H10N3O2", "CH10N5O4", "C4H14NO5"}; for (int i = 0; i < listMF.length; i++) { IMolecularFormula formula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula(listMF[i], builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.01); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePattern patternIsoNormalize = IsotopePatternManipulator.normalize(patternIsoPredicted); double tempScore = is.compare(spExp, patternIsoNormalize); if (score < tempScore) { mfString = MolecularFormulaManipulator.getString(formula); score = tempScore; } } Assert.assertEquals("C6H10N3O2", mfString); }