public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances) { var massDistribution = isotopeAbundances[Symbol]; massDistribution = massDistribution.SetAbundance(IsotopeMass, AtomPercentEnrichment); return(massDistribution); }
/// <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)); }
public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances) { var massDistribution = isotopeAbundances[Symbol]; double mass = massDistribution.ToArray()[IsotopeIndex].Key; massDistribution = massDistribution.SetAbundance(mass, AtomPercentEnrichment); return(massDistribution); }
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); }
/// <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)); }
public Settings ChangeIsotopeAbundances(IsotopeAbundances isotopeAbundances) { return(ChangeProp(ImClone(this), im => im.IsotopeAbundances = isotopeAbundances ?? DEFAULT.IsotopeAbundances)); }
public MassDistribution CalcDistribution(IsotopeAbundances isotopeAbundances) { var massDistribution = isotopeAbundances[Symbol]; double mass = massDistribution.ToArray()[IsotopeIndex].Key; massDistribution = massDistribution.SetAbundance(mass, AtomPercentEnrichment); return massDistribution; }
/// <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); }
// 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); }
public MassDistribution GetMZDistributionFromFormula(string formula, int charge, IsotopeAbundances abundances) { Molecule molecule = Molecule.Parse(formula); return GetMzDistribution(molecule, charge, abundances, 0, false); }
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); }
public MassDistribution GetMzDistribution(string seq, int charge, IsotopeAbundances abundances) { return GetMzDistribution(seq, charge, abundances, null); }
public MassDistribution GetMZDistributionFromFormula(string formula, int charge, IsotopeAbundances abundances) { return _massCalcBase.GetMZDistributionFromFormula(formula, charge, abundances); }
public MassDistribution GetMzDistribution(string seq, int charge, IsotopeAbundances abundances) { return _massCalcBase.GetMzDistribution(seq, charge, abundances, _mods); }
public AminoAcidFormulas SetIsotopeAbundances(IsotopeAbundances newAbundances) { var result = Clone(); result.IsotopeAbundances = newAbundances; return result; }