public void ChemicalFormulaGeneratorContainsFormula() { ChemicalFormulaGenerator generator = new ChemicalFormulaGenerator(new ChemicalFormula("H2O")); List<ChemicalFormula> formulas = generator.AllFormulas().ToList(); ChemicalFormula ho = new ChemicalFormula("HO"); Assert.Contains(ho, formulas); }
private static void ChemicalFormulaGeneratorExample() { //// Create a generator with formula bounds. In this case, every formula needs to have at least H2 but no more than C4H2 //ChemicalFormulaGenerator generator = new ChemicalFormulaGenerator(new ChemicalFormula("H2"), new ChemicalFormula("C4H2")); //var formulas = generator.FromMass(0, 100).ToList(); //foreach (var formula in formulas) //{ // WriteFormulaToConsole(formula); //} //Console.WriteLine("Unique Formulas: " + formulas.Count); // Create a generator with formula bounds. In this case, every formula needs to have at least H2 but no more than C4H2 ChemicalFormulaGenerator generator = new ChemicalFormulaGenerator(new ChemicalFormula("C10000N1000H1000O1000")); DoubleRange range = DoubleRange.FromPPM(new ChemicalFormula("C62H54N42O24").MonoisotopicMass, 0.1); double mass = range.Mean; int count = 0; foreach (var formula in generator.FromMass(range).Validate()) { Console.WriteLine("{0,-15} {1:F10} {2,-5:G5} ppm", formula, formula.MonoisotopicMass, Tolerance.GetTolerance(formula.MonoisotopicMass, mass, ToleranceUnit.PPM)); count++; } Console.WriteLine("Unique Formulas: " + count); }
private static void ChemicalFormulaGeneratorExample() { ChemicalFormulaGenerator generator = new ChemicalFormulaGenerator(new ChemicalFormula("H2"), new ChemicalFormula("C4H2")); var formulas = generator.FromMass(0, 100).ToList(); Console.WriteLine("Unique Formulas: " + formulas.Count); }