예제 #1
0
        public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances)
        {
            var massDistribution = isotopeAbundances[Symbol];

            massDistribution = massDistribution.SetAbundance(IsotopeMass, AtomPercentEnrichment);
            return(massDistribution);
        }
예제 #2
0
        /// <summary>
        /// Synchronizes the masses of an <see cref="IsotopeAbundances"/> object with
        /// the masses of this <see cref="BioMassCalc"/>, ensuring compatible mass calculations
        /// using the different classes.  This is only allowed with a monoisotopic mass calculator.
        /// </summary>
        /// <param name="abundances">An existing <see cref="IsotopeAbundances"/> object to be synchronized</param>
        /// <returns>An <see cref="IsotopeAbundances"/> object synchronized with this <see cref="BioMassCalc"/></returns>
        public IsotopeAbundances SynchMasses(IsotopeAbundances abundances)
        {
            if (MassType != MassType.Monoisotopic)
            {
                throw new InvalidOperationException(
                          Resources.
                          BioMassCalc_SynchMasses_Fixing_isotope_abundance_masses_requires_a_monoisotopic_mass_calculator);
            }

            var dictFixes = new Dictionary <string, MassDistribution>();

            foreach (var atomAbundance in abundances)
            {
                double monoMassCalc;
                if (!_atomicMasses.TryGetValue(atomAbundance.Key, out monoMassCalc))
                {
                    continue;
                }
                double secondMassCalc, thirdMassCalc;
                _atomicMasses.TryGetValue(atomAbundance.Key + "'", out secondMassCalc); // Not L10N
                _atomicMasses.TryGetValue(atomAbundance.Key + "\"", out thirdMassCalc); // Not L10N
                var massDist      = atomAbundance.Value;
                var massDistFixed = SynchDist(massDist, monoMassCalc, secondMassCalc, thirdMassCalc);
                if (!ReferenceEquals(massDist, massDistFixed))
                {
                    dictFixes.Add(atomAbundance.Key, massDistFixed);
                }
            }
            return(abundances.SetAbundances(dictFixes));
        }
예제 #3
0
        public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances)
        {
            var    massDistribution = isotopeAbundances[Symbol];
            double mass             = massDistribution.ToArray()[IsotopeIndex].Key;

            massDistribution = massDistribution.SetAbundance(mass, AtomPercentEnrichment);
            return(massDistribution);
        }
예제 #4
0
        private void DoValidate()
        {
            var isotopes    = BioMassCalc.DEFAULT_ABUNDANCES;
            var dictSymDist = _isotopeEnrichments.ToDictionary(e => e.IsotopeSymbol,
                                                               e => e.CalcDistribution(isotopes));

            // Make sure all heavy symbols used in Skyline are represented.
            foreach (string symbol in BioMassCalc.HeavySymbols.Where(symbol => !dictSymDist.ContainsKey(symbol)))
            {
                dictSymDist.Add(symbol, new IsotopeEnrichmentItem(symbol, 1.0).CalcDistribution(isotopes));
            }

            IsotopeAbundances = isotopes.SetAbundances(dictSymDist);
        }
예제 #5
0
        /// <summary>
        /// Ensure that the entries for D and T are the same as the entries for H' and H".
        /// </summary>
        public static IsotopeAbundances AddHeavyNicknames(IsotopeAbundances isotopeAbundances)
        {
            var changes = new Dictionary <string, MassDistribution>();

            foreach (var kvp in DICT_HEAVYSYMBOL_NICKNAMES)
            {
                MassDistribution massDistribution;
                if (isotopeAbundances.TryGetValue(kvp.Value, out massDistribution))
                {
                    changes.Add(kvp.Key, massDistribution);
                }
            }

            return(isotopeAbundances.SetAbundances(changes));
        }
예제 #6
0
 public Settings ChangeIsotopeAbundances(IsotopeAbundances isotopeAbundances)
 {
     return(ChangeProp(ImClone(this), im => im.IsotopeAbundances = isotopeAbundances ?? DEFAULT.IsotopeAbundances));
 }
예제 #7
0
        private void DoValidate()
        {
            var isotopes = BioMassCalc.DEFAULT_ABUNDANCES;
            var dictSymDist = _isotopeEnrichments.ToDictionary(e => e.IsotopeSymbol,
                                                               e => e.CalcDistribution(isotopes));

            // Make sure all heavy symbols used in Skyline are represented.
            foreach (string symbol in BioMassCalc.HeavySymbols.Where(symbol => !dictSymDist.ContainsKey(symbol)))
            {
                dictSymDist.Add(symbol, new IsotopeEnrichmentItem(symbol, 1.0).CalcDistribution(isotopes));
            }

            IsotopeAbundances = isotopes.SetAbundances(dictSymDist);
        }
예제 #8
0
 public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances)
 {
     var massDistribution = isotopeAbundances[Symbol];
     double mass = massDistribution.ToArray()[IsotopeIndex].Key;
     massDistribution = massDistribution.SetAbundance(mass, AtomPercentEnrichment);
     return massDistribution;
 }
예제 #9
0
        /// <summary>
        /// Synchronizes the masses of an <see cref="IsotopeAbundances"/> object with
        /// the masses of this <see cref="BioMassCalc"/>, ensuring compatible mass calculations
        /// using the different classes.  This is only allowed with a monoisotopic mass calculator.
        /// </summary>
        /// <param name="abundances">An existing <see cref="IsotopeAbundances"/> object to be synchronized</param>
        /// <returns>An <see cref="IsotopeAbundances"/> object synchronized with this <see cref="BioMassCalc"/></returns>
        public IsotopeAbundances SynchMasses(IsotopeAbundances abundances)
        {
            if (MassType != MassType.Monoisotopic)
                throw new InvalidOperationException(
                    Resources.
                        BioMassCalc_SynchMasses_Fixing_isotope_abundance_masses_requires_a_monoisotopic_mass_calculator);

            var dictFixes = new Dictionary<string, MassDistribution>();
            foreach (var atomAbundance in abundances)
            {
                double monoMassCalc;
                if (!_atomicMasses.TryGetValue(atomAbundance.Key, out monoMassCalc))
                    continue;
                double secondMassCalc, thirdMassCalc;
                _atomicMasses.TryGetValue(atomAbundance.Key + "'", out secondMassCalc); // Not L10N
                _atomicMasses.TryGetValue(atomAbundance.Key + "\"", out thirdMassCalc); // Not L10N
                var massDist = atomAbundance.Value;
                var massDistFixed = SynchDist(massDist, monoMassCalc, secondMassCalc, thirdMassCalc);
                if (!ReferenceEquals(massDist, massDistFixed))
                    dictFixes.Add(atomAbundance.Key, massDistFixed);
            }
            return abundances.SetAbundances(dictFixes);
        }
예제 #10
0
// ReSharper disable once ParameterTypeCanBeEnumerable.Local
        private MassDistribution GetMzDistribution(Molecule molecule, int charge, IsotopeAbundances abundances, double unexplainedMass, bool isMassH)
        {
            // Low resolution to get back only peaks at Dalton (i.e. neutron) boundaries
            var md = new MassDistribution(_massResolution, _minimumAbundance);
            var result = md;
            foreach (var element in molecule)
            {
                result = result.Add(md.Add(abundances[element.Key]).Multiply(element.Value));
            }
            return result.OffsetAndDivide(unexplainedMass + charge* (isMassH ? BioMassCalc.MassProton : -BioMassCalc.MassElectron), charge);
        }
예제 #11
0
 public MassDistribution GetMZDistributionFromFormula(string formula, int charge, IsotopeAbundances abundances)
 {
     Molecule molecule = Molecule.Parse(formula);
     return GetMzDistribution(molecule, charge, abundances, 0, false);
 }
예제 #12
0
 public MassDistribution GetMzDistribution(string seq, int charge, IsotopeAbundances abundances, ExplicitSequenceMods mods)
 {
     double unexplainedMass;
     Molecule molecule = GetFormula(seq, mods, out unexplainedMass);
     return GetMzDistribution(molecule, charge, abundances, unexplainedMass, true);
 }
예제 #13
0
 public MassDistribution GetMzDistribution(string seq, int charge, IsotopeAbundances abundances)
 {
     return GetMzDistribution(seq, charge, abundances, null);
 }
예제 #14
0
 public MassDistribution GetMZDistributionFromFormula(string formula, int charge, IsotopeAbundances abundances)
 {
     return _massCalcBase.GetMZDistributionFromFormula(formula, charge, abundances);
 }
예제 #15
0
        public MassDistribution GetMzDistribution(string seq, int charge, IsotopeAbundances abundances)




        {
            return _massCalcBase.GetMzDistribution(seq, charge, abundances, _mods);
        }
예제 #16
0
 public AminoAcidFormulas SetIsotopeAbundances(IsotopeAbundances newAbundances)
 {
     var result = Clone();
     result.IsotopeAbundances = newAbundances;
     return result;
 }