コード例 #1
0
        private List <MzRange> GetMasses()
        {
            var massesAndFrequency      = new Dictionary <double, double>();
            var tracerFormulaEnumerator = new TracerFormulaEnumerator(Sequence, _tracerDefs.Values);

            while (tracerFormulaEnumerator.MoveNext())
            {
                MassDistribution massDistribution = _aminoAcidFormulas.GetMassDistribution(
                    MoleculeFromTracerFormula(tracerFormulaEnumerator.Current), 0);
                massDistribution = massDistribution.OffsetAndDivide(_aminoAcidFormulas.GetMassShift(Sequence), 1);
                foreach (var entry in massDistribution)
                {
                    if (entry.Value < MinAbundance)
                    {
                        continue;
                    }
                    double currentAbundance;
                    massesAndFrequency.TryGetValue(entry.Key, out currentAbundance);
                    if (currentAbundance >= entry.Value)
                    {
                        continue;
                    }
                    massesAndFrequency[entry.Key] = entry.Value;
                }
            }
            var allMasses = new List <double>(massesAndFrequency.Keys);

            allMasses.Sort();
            var result = new List <MzRange>();

            foreach (var mass in allMasses)
            {
                if (result.Count == 0)
                {
                    result.Add(new MzRange(mass));
                    continue;
                }
                var lastMass = result[result.Count - 1];
                if (lastMass.Distance(mass) > MassResolution)
                {
                    result.Add(new MzRange(mass));
                    continue;
                }
                result[result.Count - 1] = lastMass.Union(mass);
            }
            return(result);
        }
コード例 #2
0
 public MassDistribution GetMassDistribution(AminoAcidFormulas aminoAcidFormulas)
 {
     return(aminoAcidFormulas.GetMassDistribution(Sequence, Charge));
 }