/** * Pretty-print the MFs of this isotope container. * @return the MFs */ String getFormulasString() { StringBuilder sb = new StringBuilder(); for (IMolecularFormula mf : getFormulas()) { if (sb.length() != 0) sb.append(", "); sb.append(MolecularFormulaManipulator.getString(mf, false, true)); } return sb.toString(); }
private void addDistinctFormula(IsotopeContainer container, IMolecularFormula mf) { for (IMolecularFormula curr : container.getFormulas()) if (MolecularFormulaManipulator.compare(curr, mf)) return; container.addFormula(mf); }
/** * Clones this IsotopeContainer object and its content. * * @return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { IsotopeContainer isoClone = new IsotopeContainer(); isoClone.forms.addAll(getFormulas()); isoClone.setIntensity(getIntensity()); isoClone.setMass(getMass()); return isoClone; }
@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)); }
existing.setIntensity(newIntensity); if (storeFormula) { for (IMolecularFormula mf : container.getFormulas()) addDistinctFormula(existing, union(mf, other.getFormula())); IsotopeContainer newcontainer = new IsotopeContainer(mass, abundance); if (storeFormula) { for (IMolecularFormula mf : container.getFormulas()) newcontainer.addFormula(union(mf, other.getFormula()));