protected override MetaMorpheusEngineResults RunSpecific()
        {
            // don't try to localize mass differences for ambiguous peptides
            foreach (PeptideSpectralMatch psm in AllResultingIdentifications.Where(b => b.FullSequence != null))
            {
                // Stop loop if canceled
                if (GlobalVariables.StopLoops)
                {
                    break;
                }

                MsDataScan scan = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                Ms2ScanWithSpecificMass     scanWithSpecificMass = new Ms2ScanWithSpecificMass(scan, psm.ScanPrecursorMonoisotopicPeakMz, psm.ScanPrecursorCharge, psm.FullFilePath, CommonParameters);
                PeptideWithSetModifications peptide = psm.BestMatchingPeptides.First().Peptide;
                double massDifference = psm.ScanPrecursorMass - peptide.MonoisotopicMass;

                // this section will iterate through all residues of the peptide and try to localize the mass-diff at each residue and report a score for each residue
                var localizedScores = new List <double>();
                for (int r = 0; r < peptide.Length; r++)
                {
                    // create new PeptideWithSetMods with unidentified mass difference at the given residue
                    PeptideWithSetModifications peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference);

                    // this is the list of theoretical products for this peptide with mass-difference on this residue
                    List <Product> productsWithLocalizedMassDiff = peptideWithLocalizedMassDiff.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus).ToList();

                    var matchedIons = MatchFragmentIons(scanWithSpecificMass, productsWithLocalizedMassDiff, CommonParameters);

                    // score when the mass-diff is on this residue
                    double localizedScore = CalculatePeptideScore(scan, matchedIons);

                    localizedScores.Add(localizedScore);
                }

                psm.LocalizedScores = localizedScores;
            }

            return(new LocalizationEngineResults(this));
        }
Esempio n. 2
0
        protected override MetaMorpheusEngineResults RunSpecific()
        {
            TerminusType terminusType = ProductTypeMethods.IdentifyTerminusType(ProductTypes);

            foreach (PeptideSpectralMatch psm in AllResultingIdentifications)
            {
                // Stop loop if canceled
                if (GlobalVariables.StopLoops)
                {
                    break;
                }

                psm.MatchedIonSeriesDict            = new Dictionary <ProductType, int[]>();
                psm.MatchedIonMassToChargeRatioDict = new Dictionary <ProductType, double[]>();
                psm.ProductMassErrorDa        = new Dictionary <ProductType, double[]>();
                psm.ProductMassErrorPpm       = new Dictionary <ProductType, double[]>();
                psm.MatchedIonIntensitiesDict = new Dictionary <ProductType, double[]>();
                var    theScan          = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                double thePrecursorMass = psm.ScanPrecursorMass;
                foreach (ProductType productType in ProductTypes)
                {
                    var sortedTheoreticalProductMasses = psm.CompactPeptides.First().Key.ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                        productType
                    });
                    Array.Sort(sortedTheoreticalProductMasses);
                    List <int>    matchedIonSeriesList            = new List <int>();
                    List <double> matchedIonMassToChargeRatioList = new List <double>();
                    List <double> productMassErrorDaList          = new List <double>();
                    List <double> productMassErrorPpmList         = new List <double>();
                    List <double> matchedIonIntensityList         = new List <double>();

                    //populate the above lists
                    MatchIonsOld(theScan, commonParameters.ProductMassTolerance, sortedTheoreticalProductMasses, matchedIonSeriesList, matchedIonMassToChargeRatioList, productMassErrorDaList, productMassErrorPpmList, matchedIonIntensityList, thePrecursorMass, productType, commonParameters.AddCompIons);

                    psm.MatchedIonSeriesDict.Add(productType, matchedIonSeriesList.ToArray());
                    psm.MatchedIonMassToChargeRatioDict.Add(productType, matchedIonMassToChargeRatioList.ToArray());
                    psm.ProductMassErrorDa.Add(productType, productMassErrorDaList.ToArray());
                    psm.ProductMassErrorPpm.Add(productType, productMassErrorPpmList.ToArray());
                    psm.MatchedIonIntensitiesDict.Add(productType, matchedIonIntensityList.ToArray());
                }
            }

            foreach (PeptideSpectralMatch psm in AllResultingIdentifications.Where(b => b.NumDifferentCompactPeptides == 1))
            {
                // Stop loop if canceled
                if (GlobalVariables.StopLoops)
                {
                    break;
                }

                var    theScan          = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                double thePrecursorMass = psm.ScanPrecursorMass;

                if (psm.FullSequence == null)
                {
                    continue;
                }

                PeptideWithSetModifications representative = psm.CompactPeptides.First().Value.Item2.First();

                var localizedScores = new List <double>();
                for (int indexToLocalize = 0; indexToLocalize < representative.Length; indexToLocalize++)
                {
                    PeptideWithSetModifications localizedPeptide = representative.Localize(indexToLocalize, psm.ScanPrecursorMass - representative.MonoisotopicMass);

                    var gg = localizedPeptide.CompactPeptide(terminusType).ProductMassesMightHaveDuplicatesAndNaNs(ProductTypes);
                    Array.Sort(gg);
                    var score = CalculatePeptideScoreOld(theScan, commonParameters.ProductMassTolerance, gg, thePrecursorMass, DissociationTypes, commonParameters.AddCompIons, 0);
                    localizedScores.Add(score);
                }

                psm.LocalizedScores = localizedScores;
            }
            return(new LocalizationEngineResults(this));
        }
Esempio n. 3
0
        protected override MetaMorpheusEngineResults RunSpecific()
        {
            // don't try to localize mass differences for ambiguous peptides
            PeptideSpectralMatch[] unambiguousPsms = AllResultingIdentifications.Where(b => b.FullSequence != null).ToArray();

            double psmsSearched       = 0;
            int    oldPercentProgress = 0;

            ReportProgress(new ProgressEventArgs(oldPercentProgress, "Localizing mass-differences... ", NestedIds));

            Parallel.ForEach(Partitioner.Create(0, unambiguousPsms.Length),
                             new ParallelOptions {
                MaxDegreeOfParallelism = CommonParameters.MaxThreadsToUsePerFile
            },
                             (range, loopState) =>
            {
                for (int i = range.Item1; i < range.Item2; i++)
                {
                    PeptideSpectralMatch psm = unambiguousPsms[i];

                    // Stop loop if canceled
                    if (GlobalVariables.StopLoops)
                    {
                        break;
                    }

                    MsDataScan scan = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                    Ms2ScanWithSpecificMass scanWithSpecificMass = new Ms2ScanWithSpecificMass(scan, psm.ScanPrecursorMonoisotopicPeakMz, psm.ScanPrecursorCharge, psm.FullFilePath, CommonParameters);
                    PeptideWithSetModifications peptide          = psm.BestMatchingPeptides.First().Peptide;
                    double massDifference = psm.ScanPrecursorMass - peptide.MonoisotopicMass;

                    // this section will iterate through all residues of the peptide and try to localize the mass-diff at each residue and report a score for each residue
                    var localizedScores = new List <double>();
                    for (int r = 0; r < peptide.Length; r++)
                    {
                        // create new PeptideWithSetMods with unidentified mass difference at the given residue
                        PeptideWithSetModifications peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference);

                        // this is the list of theoretical products for this peptide with mass-difference on this residue
                        List <Product> productsWithLocalizedMassDiff = peptideWithLocalizedMassDiff.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus).ToList();

                        var matchedIons = MatchFragmentIons(scanWithSpecificMass, productsWithLocalizedMassDiff, CommonParameters);

                        // score when the mass-diff is on this residue
                        double localizedScore = CalculatePeptideScore(scan, matchedIons);

                        localizedScores.Add(localizedScore);
                    }

                    psm.LocalizedScores = localizedScores;

                    // report search progress (PSM mass differences localized so far out of total)
                    psmsSearched++;
                    var percentProgress = (int)((psmsSearched / unambiguousPsms.Length) * 100);

                    if (percentProgress > oldPercentProgress)
                    {
                        oldPercentProgress = percentProgress;
                        ReportProgress(new ProgressEventArgs(percentProgress, "Localizing mass-differences... ", NestedIds));
                    }
                }
            });

            return(new LocalizationEngineResults(this));
        }