Skip to content

Instantly share code, notes, and snippets.

@rajarshi
Created April 16, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajarshi/e5e92e250ea359ba27f68afb3153d630 to your computer and use it in GitHub Desktop.
Save rajarshi/e5e92e250ea359ba27f68afb3153d630 to your computer and use it in GitHub Desktop.
@Test public void foo() throws Exception {
IsotopeFactory ifac = Isotopes.getInstance();
IIsotope c = ifac.getMajorIsotope("C");
IIsotope h = ifac.getMajorIsotope("H");
IIsotope o = ifac.getMajorIsotope("O");
IIsotope br79 = ifac.getMajorIsotope("Br");
IIsotope br81 = ifac.getIsotope("Br", 81);
MolecularFormulaRange mfRange = new MolecularFormulaRange();
mfRange.addIsotope(c, 0,7);
mfRange.addIsotope(h, 0,4);
mfRange.addIsotope(o, 0,3);
mfRange.addIsotope(br79, 0,2);
mfRange.addIsotope(br81, 0, 2);
double window = 0.05;
double massMin = 294.8432039 - window;
double massMax = 294.8432039 + window;
RoundRobinFormulaGenerator gen = new RoundRobinFormulaGenerator(builder,
massMin, massMax, mfRange);
IMolecularFormulaSet mfSet = gen.getAllFormulas();
Assert.assertNotNull(mfSet);
MolecularFormulaManipulator mfm = new MolecularFormulaManipulator();
for (IMolecularFormula mf : mfSet.molecularFormulas()) {
System.out.println("mf = " + mf);
System.out.println("mfm.getString(mf) = " + mfm.getString(mf));
System.out.println("mfm.getTotalExactMass(mf) = " + mfm.getTotalExactMass(mf));
System.out.println("mfm.getMajorIsotopeMass(mf) = " + mfm.getMajorIsotopeMass(mf));
java.util.List<IIsotope> br79iso = mfm.getIsotopes(mf, new Element("Br"));
for (IIsotope iso : br79iso) System.out.println("iso = " + iso.getMassNumber());
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment