本文整理汇总了C#中ChemicalFormula.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ChemicalFormula.Add方法的具体用法?C# ChemicalFormula.Add怎么用?C# ChemicalFormula.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChemicalFormula
的用法示例。
在下文中一共展示了ChemicalFormula.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntensityNormalizationFactorByIsotope
/// <summary>
///
/// </summary>
/// <param name="argCompond"></param>
/// <param name="argTheoreticalMonoIdx"></param>
/// <param name="argIntensities"></param>
/// <returns></returns>
public static double IntensityNormalizationFactorByIsotope(COL.GlycoLib.GlycanCompound argCompond, int argNumOfLabelingSite, double[] argIntensities, float argPurity)
{
ChemicalFormula MonoChemFormula = new ChemicalFormula();
MonoChemFormula.Add("C", argCompond.Carbon+argCompond.Carbon13);
MonoChemFormula.Add("H", argCompond.Hydrogen+argCompond.Deuterium);
MonoChemFormula.Add("O", argCompond.Oxygen);
//if (argCompond.Carbon13 != 0)
//{
// MonoChemFormula.Add("C{13}", argCompond.Carbon13);
//}
//if (argCompond.Deuterium != 0)
//{
// MonoChemFormula.Add("D", argCompond.Deuterium);
//}
if (argCompond.Sodium != 0)
{
MonoChemFormula.Add("Na", argCompond.Sodium);
}
if (argCompond.Nitrogen != 0)
{
MonoChemFormula.Add("N", argCompond.Nitrogen);
}
IsotopicDistribution ID = new IsotopicDistribution();
MZPeak[] Peaks= ID.CalculateDistribuition(MonoChemFormula,7, IsotopicDistribution.Normalization.BasePeak).GetPeaks().ToArray();
double[] isotopeRatio = new double[7];
for (int i = 0; i < 7; i++)
{
isotopeRatio[i] = Peaks[i].Intensity;
}
double[] CorrectedIntensities = (double[] )argIntensities.Clone();
//Isotope Correction
for (int i = 0; i <= 2; i++)
{
double Ratio = CorrectedIntensities[i]/ isotopeRatio[0];
for (int j = i; j < 7; j++)
{
CorrectedIntensities[j] = CorrectedIntensities[j] - (isotopeRatio[j-i] * Ratio );
}
}
double isotopeCorrectionFactor = CorrectedIntensities[3] / argIntensities[3];
// Purity Correction
//double PurityCorrection = Math.Pow(argPurity, argNumOfLabelingSite);
return isotopeCorrectionFactor;
}
示例2: AddFormulaToItself
public void AddFormulaToItself()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C4H6N2O2");
formulaA.Add(formulaA);
Assert.AreEqual(formulaA, formulaB);
}
示例3: AddIChemicalFormulaToFormula
public void AddIChemicalFormulaToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
IChemicalFormula formulaB = new ChemicalFormula("H2O");
ChemicalFormula formulaC = new ChemicalFormula("C2H5NO2");
formulaA.Add(formulaB);
Assert.AreEqual(formulaA, formulaC);
}
示例4: AddIsotopeToFormula
public void AddIsotopeToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H4NO");
Isotope h1 = Element.PeriodicTable["H"][1];
formulaA.Add(h1, 1);
Assert.AreEqual(formulaA, formulaB);
}
示例5: AddElementToFormula
public void AddElementToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3N2O");
Element n = Element.PeriodicTable["N"];
formulaA.Add(n, 1);
Assert.AreEqual(formulaA, formulaB);
}
示例6: ChemicalFormulaExamples
/// <summary>
/// Basic overview of how chemical formulas can be used and modified
/// </summary>
private static void ChemicalFormulaExamples()
{
Console.WriteLine("**Chemical Formula Examples**");
// Simple chemical formula creation
ChemicalFormula formula1 = new ChemicalFormula("C2H3NO");
WriteFormulaToConsole(formula1);
// Input order does not matter
ChemicalFormula formula2 = new ChemicalFormula("NH3C2O");
WriteFormulaToConsole(formula2);
// Formulas are identicial if they have the exact same type of elements and count
Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));
// You can modify exisiting chemical formulas in many ways.
// You can add a chemical formula to a chemical formula
formula1.Add(formula2);
WriteFormulaToConsole(formula1);
Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));
// You can completely remove an element from a chemical formula
formula1.Remove("C");
WriteFormulaToConsole(formula1);
// Even negative values are possible if not physically possible
formula1.Remove(formula2);
WriteFormulaToConsole(formula1);
// Implicit arithmetic is also possible (supports +, -, and *)
ChemicalFormula formula3 = formula2 - formula1;
WriteFormulaToConsole(formula3);
ChemicalFormula formula4 = formula3 + formula1;
WriteFormulaToConsole(formula4);
ChemicalFormula formula5 = formula2*5;
WriteFormulaToConsole(formula5);
// Formulas consist of a dictionary of isotopes and count, and by default, the most common (abundant) isotope of an element
// is included (i.e. Carbon 12 instead of Carbon 13). You can explicitly state that you want another isotope in a chemical formula
// by this notation: <Element Symbol>{<Mass Number>} (e.g. C{13}, N{15}, etc..)
formula1 = new ChemicalFormula("C2C{13}2H3NO");
formula2 = new ChemicalFormula("C4H3NO");
WriteFormulaToConsole(formula1);
WriteFormulaToConsole(formula2);
Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));
// No need to specify the mass number of the most abundant isotope for an element
formula3 = new ChemicalFormula("C{12}2C2H3NO");
formula4 = new ChemicalFormula("C4H3NO");
Console.WriteLine("Are {0} and {1} equivalent? {2}", formula3, formula4, formula3.Equals(formula4));
}
示例7: AddLargeIsotopeToFormula
public void AddLargeIsotopeToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3NOFe");
Isotope fe = Element.PeriodicTable["Fe"].PrincipalIsotope;
formulaA.Add(fe, 1);
Assert.AreEqual(formulaA, formulaB);
}
示例8: AddZeroSymbolToFormula
public void AddZeroSymbolToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");
formulaA.Add("H", 0);
Assert.AreEqual(formulaA, formulaB);
}
示例9: AddNullIsotopeToFormula
public void AddNullIsotopeToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");
formulaA.Add(NullIsotope, 1);
Assert.AreEqual(formulaA, formulaB);
}
示例10: AddNonExistentSymbolToFormula
public void AddNonExistentSymbolToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
formulaA.Add("Faa", 1);
}
示例11: AddNegativeFormulaToFormula
public void AddNegativeFormulaToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C-1H-2");
ChemicalFormula formulaC = new ChemicalFormula("CHNO");
formulaA.Add(formulaB);
Assert.AreEqual(formulaA, formulaC);
}
示例12: AddZeroIsotopeToFormula
public void AddZeroIsotopeToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");
Isotope h1 = PeriodicTable.GetElement("H")[1];
formulaA.Add(h1, 0);
Assert.AreEqual(formulaA, formulaB);
}
示例13: AddZeroElementToFormula
public void AddZeroElementToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");
Element n = PeriodicTable.GetElement("N");
formulaA.Add(n, 0);
Assert.AreEqual(formulaA, formulaB);
}
示例14: AddNonExistentSymbolToFormula
public void AddNonExistentSymbolToFormula()
{
ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
Assert.Throws<KeyNotFoundException>(() => formulaA.Add("Faa", 1), "The element symbol 'Faa' is not found in the periodic table");
}
示例15: ToHeavyModification
public ChemicalFormulaModification ToHeavyModification(bool c, bool n)
{
var formula = new ChemicalFormula();
if (c)
{
Element carbon = PeriodicTable.GetElement("C");
int carbon12 = ChemicalFormula.Count(carbon[12]);
formula.Add(carbon[12], -carbon12);
formula.Add(carbon[13], carbon12);
}
if (n)
{
Element nitrogen = PeriodicTable.GetElement("N");
int nitrogen14 = ChemicalFormula.Count(nitrogen[14]);
formula.Add(nitrogen[14], -nitrogen14);
formula.Add(nitrogen[15], nitrogen14);
}
return new ChemicalFormulaModification(formula, "#", Site);
}