Esempio n. 1
0
 public FormulaBuilder(BioMassCalc massCalc)
 {
     _massCalc = massCalc;
     _dictAtomCounts = new Dictionary<string, int>();
 }
Esempio n. 2
0
        public SequenceMassCalc(MassType type)
        {
            _massCalc = new BioMassCalc(type);

            // Not L10N

            // Mass of a proton, i.e. +1 positive charge, hydrogen atom without its electron.
            // See http://antoine.frostburg.edu/chem/senese/101/atoms/index.shtml
            // _massWater = _massCalc.CalculateMass("H2O");
            // _massAmmonia = _massCalc.CalculateMass("NH3");

            // ReSharper disable NonLocalizedString
            _massDiffA = -_massCalc.CalculateMassFromFormula("CO");
            _massDiffB = 0.0;
            _massDiffC = _massCalc.CalculateMassFromFormula("NH3");
            _massDiffY = _massCalc.CalculateMassFromFormula("H2O");
            _massDiffX = _massCalc.CalculateMassFromFormula("CO2");
            _massDiffZ = _massDiffY - _massCalc.CalculateMassFromFormula("NH2");

            _massCleaveN = _massCalc.CalculateMassFromFormula("H");
            _massCleaveC = _massCalc.CalculateMassFromFormula("OH");
            // ReSharper restore NonLocalizedString

            // These numbers are set intentionally smaller than any known instrument
            // can measure.  Filters are then applied to resulting distributions
            // to get more useful numbers.
            _massResolution = 0.001;
            _minimumAbundance = 0.00001;    // 0.001%

            InitAminoAcidMasses();
        }
Esempio n. 3
0
        public static string[] ParseModParts(BioMassCalc calc, string desc)
        {
            string parse = desc;
            calc.ParseMass(ref parse);

            string part1 = desc.Substring(0, desc.Length - parse.Length).Trim();
            string part2 = string.Empty;

            if (parse.Length > 0 && parse[0] == '-') // Not L10N
            {
                parse = parse.Substring(1);
                part2 = parse.Trim();

                calc.ParseMass(ref parse);
            }

            if ((part1.Length == 0 && part2.Length == 0) || parse.Length > 0)
                calc.ThrowArgumentException(desc);

            return new[] { part1, part2 };
        }
Esempio n. 4
0
        public static void ParseModCounts(BioMassCalc calc, string desc, IDictionary<string, int> dictAtomCounts)
        {
            string parse = desc;
            calc.ParseCounts(ref parse, dictAtomCounts, false);
            if (parse.Length > 0 && parse[0] == '-') // Not L10N
            {
                parse = parse.Substring(1);
                calc.ParseCounts(ref parse, dictAtomCounts, true);
            }

            if (parse.Length > 0)
                calc.ThrowArgumentException(desc);
        }
Esempio n. 5
0
        public static double ParseModMass(BioMassCalc calc, string desc)
        {
            string parse = desc;
            double totalMass = calc.ParseMass(ref parse);
            if (parse.Length > 0 && parse[0] == '-') // Not L10N
            {
                parse = parse.Substring(1);
                totalMass -= calc.ParseMass(ref parse);
            }

            if (totalMass == 0.0 || parse.Length > 0)
                calc.ThrowArgumentException(desc);

            return Math.Round(totalMass, MassPrecision);
        }