MolecularFormulaSetManipulator { public static boolean contains(IMolecularFormulaSet formulaSet, IMolecularFormula formula) { for (IMolecularFormula fm : formulaSet.molecularFormulas()) { if (MolecularFormulaManipulator.compare(fm, formula)) { return true; } } return false; }  static IMolecularFormula getMaxOccurrenceElements(IMolecularFormulaSet mfSet); static IMolecularFormula getMinOccurrenceElements(IMolecularFormulaSet mfSet); static IMolecularFormulaSet remove(IMolecularFormulaSet formulaSet, IMolecularFormula formulaMin,
            IMolecularFormula formulaMax); static boolean contains(IMolecularFormulaSet formulaSet, IMolecularFormula formula); static IMolecularFormulaSet remove(IMolecularFormulaSet formulaSet, MolecularFormulaRange formulaRange);  }
@Test public void testContains_IMolecularFormulaSet_IMolecularFormula() { IMolecularFormula mf1 = new MolecularFormula(); mf1.addIsotope(builder.newInstance(IIsotope.class, "C"), 4); mf1.addIsotope(builder.newInstance(IIsotope.class, "H"), 12); mf1.addIsotope(builder.newInstance(IIsotope.class, "N"), 1); mf1.addIsotope(builder.newInstance(IIsotope.class, "O"), 4); IMolecularFormula mf3 = new MolecularFormula(); mf3.addIsotope(builder.newInstance(IIsotope.class, "C"), 9); mf3.addIsotope(builder.newInstance(IIsotope.class, "H"), 5); mf3.addIsotope(builder.newInstance(IIsotope.class, "O"), 7); IMolecularFormulaSet formulaSet = new MolecularFormulaSet(); formulaSet.addMolecularFormula(mf1); formulaSet.addMolecularFormula(mf3); IMolecularFormula mf2 = new MolecularFormula(); mf2.addIsotope(builder.newInstance(IIsotope.class, "C"), 4); mf2.addIsotope(builder.newInstance(IIsotope.class, "H"), 12); mf2.addIsotope(builder.newInstance(IIsotope.class, "N"), 1); mf2.addIsotope(builder.newInstance(IIsotope.class, "O"), 4); IMolecularFormula mf4 = new MolecularFormula(); mf4.addIsotope(builder.newInstance(IIsotope.class, "C"), 4); IIsotope hyd = builder.newInstance(IIsotope.class, "H"); hyd.setExactMass(2.0032342); mf4.addIsotope(hyd, 12); mf4.addIsotope(builder.newInstance(IIsotope.class, "N"), 1); mf4.addIsotope(builder.newInstance(IIsotope.class, "O"), 4); Assert.assertTrue(MolecularFormulaSetManipulator.contains(formulaSet, mf2)); Assert.assertFalse(MolecularFormulaSetManipulator.contains(formulaSet, mf4)); }