/** * 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); }
IsotopeContainer container = new IsotopeContainer(mass, abundance); if (storeFormula) container.setFormula(asFormula(isotope)); additional.add(container); abundance_Mass = calculateAbundanceAndMass(abundance_Mass, additional); isoP = cleanAbundance(isoP, minIntensity); IsotopePattern isoPattern = IsotopePatternManipulator.sortByMass(isoP); return isoPattern;
@Test public void testMultipleFormulasForAMass() { IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("C6Cl2", builder); IsotopePatternGenerator isogen = new IsotopePatternGenerator(0.1).setMinIntensity(0.01) .setMinResolution(0.01) .setStoreFormulas(true); IsotopePattern pattern = isogen.getIsotopes(mf); List<IsotopeContainer> isotopes = pattern.getIsotopes(); Assert.assertThat(isotopes.get(0).getFormulas().size(), is(1)); Assert.assertThat(isotopes.get(1).getFormulas().size(), is(1)); Assert.assertThat(isotopes.get(2).getFormulas().size(), is(2)); Assert.assertThat(isotopes.get(3).getFormulas().size(), is(2)); Assert.assertThat(isotopes.get(4).getFormulas().size(), is(3)); }
/** * Constructor for the IsotopePatternRule object. */ public IsotopePatternRule() { isotopeGe = new IsotopePatternGenerator(0.01); is = new IsotopePatternSimilarity(); is.seTolerance(toleranceMass); }
IsotopeContainer existing = findExisting(containers, mass, resolution); if (existing != null) { double newIntensity = existing.getIntensity() + abundance; if (storeFormula) { for (IMolecularFormula mf : container.getFormulas()) addDistinctFormula(existing, union(mf, other.getFormula())); if (storeFormula) { for (IMolecularFormula mf : container.getFormulas()) newcontainer.addFormula(union(mf, other.getFormula()));
/** * A unit test for JUnit. * * @return Description of the Return Value */ @Test public void testIsotopePatternGenerator() { IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(); Assert.assertNotNull(isotopeGe); }
@Nonnull Double mzTolerance) { IsotopePatternGenerator generator = new IsotopePatternGenerator(minAbundance); IsotopePattern pattern = generator.getIsotopes(cdkFormula);
/** * A unit test for JUnit. * * @return Description of the Return Value */ @Test public void testIsotopePatternGenerator_double() { IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(); Assert.assertNotNull(isotopeGe); }
@Nonnull Double mzTolerance) { IsotopePatternGenerator generator = new IsotopePatternGenerator(minAbundance); IsotopePattern pattern = generator.getIsotopes(cdkFormula);
@Nonnull Double mzTolerance) { IsotopePatternGenerator generator = new IsotopePatternGenerator(minAbundance); IsotopePattern pattern = generator.getIsotopes(cdkFormula);
/** * Calculate isotopes for C20H30Fe2P2S4Cl4 (in CDK 1.5.12, this call * sometimes returns 34 and sometimes 35 isotopes, non-deterministically). */ @Ignore("Non-deterministic test value is bad! This likely depends on our current isotope data which is also bad.") public void testCalculateIsotopesC20H30Fe2P2S4Cl4() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C20H30Fe2P2S4Cl4", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.01); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(35, isos.getNumberOfIsotopes()); }
/** * A unit test for JUnit: * * @return Description of the Return Value */ @Test public void testGetIsotopes_IMolecularFormula() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C41H79N8O3P1", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(2, isos.getNumberOfIsotopes(), 0.001); }
/** * A unit test for JUnit: * * @return Description of the Return Value */ @Test public void testGetIsotopes_IMolecularFormula_withoutONE() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C41H79N8O3P", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.01); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(6, isos.getNumberOfIsotopes(), 0.001); }
@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()); }
/** * @cdk.bug 3273205 */ @Test public void testCalculateIsotopesMn() { IMolecularFormula molFor = new MolecularFormula(); molFor.addIsotope(builder.newInstance(IIsotope.class, "Mn"), 1); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.001); IsotopePattern isoPattern = isotopeGe.getIsotopes(molFor); Assert.assertEquals(1, isoPattern.getNumberOfIsotopes()); }
@Test public void testGetIsotopes_IMolecularFormula_deprotonate() { IsotopePatternGenerator isogen = new IsotopePatternGenerator(.1); IMolecularFormula mf1 = MolecularFormulaManipulator.getMolecularFormula("C6H12O6", builder); MolecularFormulaManipulator.adjustProtonation(mf1, -1); IsotopePattern ip1 = isogen.getIsotopes(mf1); Assert.assertEquals(1, ip1.getNumberOfIsotopes()); isogen = new IsotopePatternGenerator(.1); IMolecularFormula mf2 = MolecularFormulaManipulator.getMolecularFormula("C6H11O6", builder); IsotopePattern ip2 = isogen.getIsotopes(mf2); Assert.assertEquals(1, ip2.getNumberOfIsotopes()); Assert.assertEquals(ip1.getIsotope(0).getMass(), ip2.getIsotope(0).getMass(), 0.001); }
/** * Calculate isotopes for C10000 (failed in CDK 1.5.12). */ @Test public void testCalculateIsotopesC10000() { IMolecularFormula molFor = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("C10000", builder); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isos = isotopeGe.getIsotopes(molFor); Assert.assertEquals(44, isos.getNumberOfIsotopes()); for (int i = 0; i < isos.getNumberOfIsotopes(); i++) Assert.assertTrue(isos.getIsotope(i).getMass() > 120085); }
@Test public void testGetIsotopes_IMolecularFormula_Charged() { IsotopePatternGenerator isogen = new IsotopePatternGenerator(.1); IMolecularFormula mfPositive = MolecularFormulaManipulator.getMolecularFormula("C6H11O6Na", builder); mfPositive.setCharge(1); IsotopePattern ip1 = isogen.getIsotopes(mfPositive); Assert.assertEquals(1, ip1.getNumberOfIsotopes()); isogen = new IsotopePatternGenerator(.1); IMolecularFormula mfNeutral = MolecularFormulaManipulator.getMolecularFormula("C6H12O6Na", builder); mfNeutral.setCharge(0); IsotopePattern ip2 = isogen.getIsotopes(mfNeutral); Assert.assertEquals(1, ip2.getNumberOfIsotopes()); Assert.assertNotEquals(ip1.getIsotope(0).getMass(), ip2.getIsotope(0).getMass()); }
/** * A unit test for JUnit: Isotopes of the Bromine. * * @return Description of the Return Value */ @Test public void testGetIsotopes1() { IMolecularFormula molFor = new MolecularFormula(); molFor.addIsotope(builder.newInstance(IIsotope.class, "Br")); molFor.addIsotope(builder.newInstance(IIsotope.class, "Br")); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isoPattern = isotopeGe.getIsotopes(molFor); Assert.assertEquals(3, isoPattern.getNumberOfIsotopes()); }
/** * 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); }