/** * Return the isotope pattern sorted and normalized by intensity * to the highest abundance. * * @param isotopeP The IsotopePattern object to sort * @return The IsotopePattern sorted */ public static IsotopePattern sortAndNormalizedByIntensity(IsotopePattern isotopeP) { IsotopePattern isoNorma = normalize(isotopeP); return sortByIntensity(isoNorma); }
/** * Validate the isotope pattern of this IMolecularFormula. Important, first * you have to add with the {@link #setParameters(Object[])} a IMolecularFormulaSet * which represents the isotope pattern to compare. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ @Override public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ", formula); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.1); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePattern patternIsoNormalize = IsotopePatternManipulator.normalize(patternIsoPredicted); return is.compare(pattern, patternIsoNormalize); }
/** * Junit test * * @throws Exception */ @Test public void testNormalize_IsotopePattern() { IsotopePattern spExp = new IsotopePattern(); spExp.setMonoIsotope(new IsotopeContainer(156.07770, 2)); spExp.addIsotope(new IsotopeContainer(157.08059, 0.0006)); spExp.addIsotope(new IsotopeContainer(157.07503, 0.0002)); spExp.addIsotope(new IsotopeContainer(158.08135, 0.004)); spExp.setCharge(1); IsotopePattern isoNorma = IsotopePatternManipulator.normalize(spExp); List<IsotopeContainer> listISO = isoNorma.getIsotopes(); Assert.assertEquals(1, isoNorma.getMonoIsotope().getIntensity(), 0.00001); Assert.assertEquals(1, listISO.get(0).getIntensity(), 0.00001); Assert.assertEquals(0.0003, listISO.get(1).getIntensity(), 0.00001); Assert.assertEquals(0.0001, listISO.get(2).getIntensity(), 0.00001); Assert.assertEquals(0.002, listISO.get(3).getIntensity(), 0.00001); Assert.assertEquals(156.07770, isoNorma.getMonoIsotope().getMass(), 0.00001); Assert.assertEquals(156.07770, listISO.get(0).getMass(), 0.00001); Assert.assertEquals(157.08059, listISO.get(1).getMass(), 0.00001); Assert.assertEquals(157.07503, listISO.get(2).getMass(), 0.00001); Assert.assertEquals(158.08135, listISO.get(3).getMass(), 0.00001); Assert.assertEquals(1, isoNorma.getCharge(), 0.00001); }
/** * 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); }
/** * 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); }