コード例 #1
0
        public pHistBumpViewModel()
        {
            // Initialize this view model with default values
            searchParams = new SearchParams();

            mgf = null;
        }
コード例 #2
0
ファイル: SearchParamsTest.cs プロジェクト: vnbhatia/triplet
        public SearchParams getDefaultSearchParams()
        {
            SearchParams searchParams = new SearchParams();
            searchParams.isDeNovoSearch = false;
            searchParams.neutralLossMass = "98";
            searchParams.errorTolerance = "0.2500";
            searchParams.intensityCutoff = "75";
            searchParams.RTWindow = "120";
            searchParams.maxNumberOfLosses = "1";

            return searchParams;
        }
コード例 #3
0
ファイル: MGFFile.cs プロジェクト: vnbhatia/triplet
        public List<PeakResultView> findAllNeutralLossPeaks(SearchParams searchParams)
        {
            if (ionSpectra == null)
                return null;

            List<PeakResultView> neutralLossPeaks = new List<PeakResultView>();
            foreach (IonSpectrum spectrum in ionSpectra)
            {
                // Filter out peaks that are below the intesity threshold. For our purposes, these are considered to be "noise" peaks
                double maxIntensity = spectrum.getMaxIntensity();
                List<Peak> peaksAboveIntensityThreshold = spectrum.peaks.FindAll(p => (p.intensity/maxIntensity)*100 >= searchParams.intensityCutoff_num);

                // Search for neutral losses of the current parent ion
                double pepmass = 0;
                if (!Double.TryParse(spectrum.pepmass, out pepmass))
                {
                    Console.WriteLine("Warning: Skipping spectrum, " + spectrum.title + ", because its pepmass is unreadable.");
                    continue;
                }
                List<Peak> peakList = spectrum.findNeutralLossPeaks(pepmass, searchParams);

                // If we find any neutral loss peaks, add them to the list
                if (peakList != null && peakList.Count > 0)
                {
                    List<PeakResultView> peakResultView = new List<PeakResultView>();
                    double RT_begin = Math.Max((spectrum.retentionTime - (searchParams.RTWindow_num / 2)) / 60, 0);
                    double RT_end = (spectrum.retentionTime + (searchParams.RTWindow_num / 2)) / 60;

                    foreach (Peak p in peakList)
                    {
                        peakResultView.Add(new PeakResultView(p, maxIntensity, RT_begin, RT_end));
                    }
                    neutralLossPeaks.InsertRange(0, peakResultView);
                }
            }

            neutralLossPeaks = neutralLossPeaks.OrderBy(p => p.spectrumTitle).ThenBy(p => p.pepmass).ToList();
            return neutralLossPeaks;
        }
コード例 #4
0
ファイル: IonSpectrum.cs プロジェクト: vnbhatia/triplet
        public List<Peak> findNeutralLossPeaks(double parentMZ, SearchParams searchParams)
        {
            if (z == 0 || !isPositiveIonMode)
            {
                Console.WriteLine("Error: Cannot perform neutral loss search if precursor ion charge is invalid");
                return null;
            }

            List<Peak> NLPeaks = new List<Peak>();
            List<double> NLMassesFound = new List<double>();
            double currentMaxIntensity = getMaxIntensity();

            // Specify which NL Ions are primary NL ions we would like to search for (we don't want to search as if all the peaks input are primary NL peaks - that likely increases FP rate)
            // TODO: implement UI interface to toggle a NL ion as a "primary" or "secondary" NL ion
            List<double> primaryNLIons = new List<double>();
            primaryNLIons.Add(searchParams.neutralLossMass_num[0]); // TODO: change - this is hardcoding that only the first ion is the primary NL peak

            for (int NLMassIndex = 0; NLMassIndex < searchParams.neutralLossMass_num.Count; NLMassIndex++) // Cycle through each "parent"/primary neutral loss search ion
            {
                bool currentNLMassFound = false;
                double currentNLMass = searchParams.neutralLossMass_num[NLMassIndex];
                if (!primaryNLIons.Contains(currentNLMass))
                    continue; // Skip non-primary NL ions

                for (int i = 0; i < searchParams.maxNumberOfLosses_num; i++) // Find the maximum number of neutral losses for the current primary NL ion
                {
                    double searchMass = parentMZ - (Convert.ToDouble(i + 1) * currentNLMass) / z;
                    double searchMass_min = searchMass - (searchParams.errorTolerance_num);
                    double searchMass_max = searchMass + (searchParams.errorTolerance_num);

                    List<Peak> matchingPeaks = peaks.FindAll(anyPeak => anyPeak.mz <= searchMass_max && anyPeak.mz >= searchMass_min &&
                        (anyPeak.intensity / currentMaxIntensity) * 100 >= searchParams.intensityCutoff_num);

                    if (matchingPeaks != null)
                    {
                        if (matchingPeaks.Count > 0 && currentNLMassFound == false)
                        {
                            currentNLMassFound = true;
                            if (!NLMassesFound.Contains(currentNLMass))
                                NLMassesFound.Add(currentNLMass);

                            // Since we found a primary NL peak, find secondary ions with the secondary peak intensity cutoff
                            for (int NLMassIndex2 = 0; NLMassIndex2 < searchParams.neutralLossMass_num.Count; NLMassIndex2++)
                            {
                                if (NLMassIndex2 == NLMassIndex)
                                    continue; // Skip the neutral loss mass that is currently the primary neutral loss
                                bool currentNLMassFound2 = false;
                                double currentNLMass2 = searchParams.neutralLossMass_num[NLMassIndex2];

                                double searchMass2 = parentMZ - (Convert.ToDouble(i + 1) * currentNLMass2) / z;
                                double searchMass_min2 = searchMass2 - (searchParams.errorTolerance_num);
                                double searchMass_max2 = searchMass2 + (searchParams.errorTolerance_num);

                                List<Peak> matchingPeaks2 = peaks.FindAll(anyPeak => anyPeak.mz <= searchMass_max2 && anyPeak.mz >= searchMass_min2 &&
                                    (anyPeak.intensity / currentMaxIntensity) * 100 >= searchParams.intensityCutoff2_num);

                                // Account for the secondary peak being found
                                if (matchingPeaks2.Count > 0 && currentNLMassFound2 == false)
                                {
                                    currentNLMassFound2 = true;
                                    if (!NLMassesFound.Contains(currentNLMass2))
                                        NLMassesFound.Add(currentNLMass2);
                                }

                                // Add the secondary peaks to the matching peak list
                                foreach (Peak p_secondary in matchingPeaks2)
                                {
                                    if (!matchingPeaks.Exists(somePeak => Peak.AreEqual(somePeak, p_secondary)))
                                        matchingPeaks.Add(p_secondary);
                                }
                            }
                        }

                        // Assign each peak in matchingPeaks a consecutive neutral loss index, then add the peak to the
                        // NLPeaks master list if it doesn't already exist within it
                        foreach (Peak p in matchingPeaks)
                        {
                            p.consecutiveNeutralLossIndex = i + 1;
                            if ( !NLPeaks.Exists(somePeak => Peak.AreEqual(somePeak, p)) )
                                NLPeaks.Add(p);
                        }
                    }
                }
            }

            if (searchParams.allNLsRequiredPerSpectrum)
            {
                if (NLMassesFound.Count == searchParams.neutralLossMass_num.Count)
                    return NLPeaks;
                else
                    return new List<Peak>();
            }
            else
                return NLPeaks;
        }