Ejemplo n.º 1
0
        public static CalculatedPeaks Calculate(PeptideFileAnalysis peptideFileAnalysis, IEnumerable <CalculatedPeaks> otherPeaks)
        {
            var tracerFormulae = peptideFileAnalysis.TurnoverCalculator.ListTracerFormulas();
            var result         = new CalculatedPeaks(peptideFileAnalysis);

            if (!peptideFileAnalysis.AutoFindPeak)
            {
                var previous = peptideFileAnalysis.PeakData;
                if (previous.Peaks.Count == tracerFormulae.Count)
                {
                    for (int i = 0; i < previous.Peaks.Count; i++)
                    {
                        var peak = previous.Peaks[i];
                        if (result._peaks.Count == 0)
                        {
                            result.MakeBasePeak(tracerFormulae[i], peak.StartTime, peak.EndTime);
                        }
                        else
                        {
                            result.MakeSecondaryPeak(tracerFormulae[i], peak.StartTime, peak.EndTime);
                        }
                    }
                    var maxArea = result._peaks.Values.Max(peak => peak.Area);
                    result = result.ChangeBasePeak(result._peaks.First(kvp => kvp.Value.Area.Equals(maxArea)).Key);
                    result.IntegrationNote = IntegrationNote.Manual;
                }
            }
            if (result._peaks.Count == 0)
            {
                result.LookForBestPeak(otherPeaks);
            }
            result.FinishCalculation();
            return(result);
        }
Ejemplo n.º 2
0
 private TracerChromatograms GetTracerChromatograms()
 {
     if (_tracerChromatograms == null)
     {
         _tracerChromatograms = PeptideFileAnalysis.GetTracerChromatograms(_smoothChromatograms);
     }
     return(_tracerChromatograms);
 }
Ejemplo n.º 3
0
        public CalculatedPeaks GetCalculatePeaks(PeptideFileAnalysis peptideFileAnalysis)
        {
            if (null == _calculatedPeaks)
            {
                return(null);
            }
            CalculatedPeaks calculatedPeaks;

            _calculatedPeaks.TryGetValue(peptideFileAnalysis.Id, out calculatedPeaks);
            return(calculatedPeaks);
        }
Ejemplo n.º 4
0
        public List <PeptideFileAnalysis> GetFileAnalyses()
        {
            var result = new List <PeptideFileAnalysis>();

            using (var session = Workspace.OpenSession())
            {
                var criteria = session.CreateCriteria(typeof(DbPeptideFileAnalysis))
                               .Add(Restrictions.Eq("MsDataFile", session.Load <DbMsDataFile>(Id)));
                foreach (DbPeptideFileAnalysis peptideFileAnalysis in criteria.List())
                {
                    int index = Workspace.PeptideAnalyses.IndexOfKey(peptideFileAnalysis.PeptideAnalysis.GetId());
                    if (index >= 0)
                    {
                        result.Add(PeptideFileAnalysis.GetPeptideFileAnalysis(
                                       Workspace.PeptideAnalyses[index],
                                       peptideFileAnalysis));
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
 public PeptideDistributions(PeptideFileAnalysis peptideFileAnalysis) : base(peptideFileAnalysis.Workspace)
 {
     Parent = peptideFileAnalysis;
     SetId(peptideFileAnalysis.Id);
     IsDirty = true;
 }
Ejemplo n.º 6
0
 public PeptideDistributions(PeptideFileAnalysis peptideFileAnalysis, DbPeptideFileAnalysis dbPeptideFileAnalysis)
     : base(peptideFileAnalysis.Workspace, dbPeptideFileAnalysis)
 {
     Parent = peptideFileAnalysis;
 }
Ejemplo n.º 7
0
        public TracerChromatograms(PeptideFileAnalysis peptideFileAnalysis, ChromatogramSetData chromatogramSet, bool smoothed)
        {
            Smoothed            = smoothed;
            ChromatogramSet     = chromatogramSet;
            PeptideFileAnalysis = peptideFileAnalysis;
            var    pointDict          = new Dictionary <TracerFormula, IList <double> >();
            var    chromatogramsDict  = new Dictionary <MzKey, IList <double> >();
            var    turnoverCalculator = PeptideAnalysis.GetTurnoverCalculator();
            double massAccuracy       = PeptideAnalysis.GetMassAccuracy();

            foreach (var chromatogramEntry in ChromatogramSet.Chromatograms)
            {
                if (PeptideAnalysis.ExcludedMasses.Contains(chromatogramEntry.Key.MassIndex))
                {
                    continue;
                }
                var chromatogram = chromatogramEntry.Value;
                var mzRange      = turnoverCalculator.GetMzs(chromatogramEntry.Key.Charge)[chromatogramEntry.Key.MassIndex];
                var intensities  = chromatogram.ChromatogramPoints.Select(point => point.GetIntensity(mzRange, massAccuracy)).ToArray();
                if (smoothed)
                {
                    intensities = SavitzkyGolaySmooth(intensities);
                }
                chromatogramsDict.Add(chromatogramEntry.Key, intensities);
            }
            int massCount              = PeptideFileAnalysis.PeptideAnalysis.GetMassCount();
            var times                  = chromatogramSet.Times.ToArray();
            var scores                 = new List <double>();
            var tracerFormulas         = turnoverCalculator.ListTracerFormulas();
            var theoreticalIntensities = turnoverCalculator.GetTheoreticalIntensities(tracerFormulas);

            for (int i = 0; i < times.Length; i++)
            {
                var intensities = new List <double>();
                for (int iMass = 0; iMass < massCount; iMass++)
                {
                    double intensity = 0;
                    for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++)
                    {
                        IList <double> chromatogram;
                        if (chromatogramsDict.TryGetValue(new MzKey(charge, iMass), out chromatogram))
                        {
                            intensity += chromatogram[i];
                        }
                        else
                        {
                            intensity = double.NaN;
                        }
                    }
                    intensities.Add(intensity);
                }
                double score;
                IDictionary <TracerFormula, IList <double> > predictedIntensities;
                PeptideAnalysis.GetTurnoverCalculator().GetTracerAmounts(intensities, out score, out predictedIntensities, tracerFormulas, theoreticalIntensities);
                foreach (var entry in predictedIntensities)
                {
                    IList <double> list;
                    if (!pointDict.TryGetValue(entry.Key, out list))
                    {
                        list = new List <double>();
                        pointDict.Add(entry.Key, list);
                    }
                    list.Add(entry.Value.Sum());
                }
                scores.Add(score);
            }
            var points = new SortedDictionary <TracerFormula, IList <double> >();
            var peaks  = new Dictionary <TracerFormula, IList <CrawdadPeak> >();

            foreach (var entry in pointDict)
            {
                points.Add(entry.Key, entry.Value);
                CrawPeakFinderWrapper peakFinder = new CrawPeakFinderWrapper();
                peakFinder.SetChromatogram(times, entry.Value);
                peaks.Add(entry.Key, peakFinder.CalcPeaks(MaxPeaks));
            }
            Points   = points;
            Scores   = scores;
            Times    = chromatogramSet.Times;
            RawPeaks = peaks;
        }
Ejemplo n.º 8
0
 private CalculatedPeaks(PeptideFileAnalysis peptideFileAnalysis)
 {
     PeptideFileAnalysis = peptideFileAnalysis;
     AutoFindPeak        = peptideFileAnalysis.AutoFindPeak;
 }