Example #1
0
        //If XlSites is of same types
        private PsmCross XlSitesSame(Ms2ScanWithSpecificMass theScan, PsmCross psmCrossAlpha, PsmCross psmCrossBeta,
                                     CrosslinkerTypeClass crosslinker, int ind, int inx)
        {
            PsmCross psmCross   = null;
            var      xlPosAlpha = PsmCross.XlPosCal(psmCrossAlpha.compactPeptide, crosslinker.CrosslinkerModSites);
            var      xlPosBeta  = PsmCross.XlPosCal(psmCrossBeta.compactPeptide, crosslinker.CrosslinkerModSites);

            if (xlPosAlpha.Count() >= 1 && xlPosBeta.Count() >= 1)
            {
                PsmCross.XlLocalization(theScan, psmCrossAlpha, psmCrossBeta.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, ProductTypes, commonParameters.ProductMassTolerance, Charge_2_3, Charge_2_3_PrimeFragment, xlPosAlpha);
                PsmCross.XlLocalization(theScan, psmCrossBeta, psmCrossAlpha.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, ProductTypes, commonParameters.ProductMassTolerance, Charge_2_3, Charge_2_3_PrimeFragment, xlPosBeta);

                if (psmCrossAlpha.XLBestScore < psmCrossBeta.XLBestScore)
                {
                    var swap = psmCrossAlpha;
                    psmCrossAlpha = psmCrossBeta;
                    psmCrossBeta  = swap;
                }
                psmCrossAlpha.XlRank             = new int[] { ind, inx };
                psmCrossAlpha.XLTotalScore       = psmCrossAlpha.XLBestScore + psmCrossBeta.XLBestScore;
                psmCrossAlpha.XLQvalueTotalScore = Math.Sqrt(psmCrossAlpha.XLBestScore) * psmCrossBeta.XLBestScore;
                psmCrossAlpha.BetaPsmCross       = psmCrossBeta;
                if (crosslinker.Cleavable)
                {
                    psmCrossAlpha.ParentIonMaxIntensityRanks.AddRange(psmCrossBeta.ParentIonMaxIntensityRanks);
                    psmCrossAlpha.ParentIonExistNum += psmCrossBeta.ParentIonExistNum;
                }
                psmCrossAlpha.CrossType = PsmCrossType.Cross;

                psmCross = psmCrossAlpha;
            }
            return(psmCross);
        }
Example #2
0
        //Calculate score based on All possible Products Masses for inter- or intra- crosslinks and deadend.
        public static void XlLocalizationForLoopCrosslink(Ms2ScanWithSpecificMass theScan, PsmCross psmCross, double modMass, CrosslinkerTypeClass crosslinker, List <ProductType> lp, Tolerance fragmentTolerance, List <int> linkPos)
        {
            var pmmhList = PsmCross.XlCalculateTotalProductMassesForLoopCrosslink(psmCross, modMass, crosslinker, lp, linkPos);

            List <double>         scoreList = new List <double>();
            List <MatchedIonInfo> miil      = new List <MatchedIonInfo>();

            foreach (var pmm in pmmhList)
            {
                var    matchedIonMassesListPositiveIsMatch = new MatchedIonInfo(pmm.ProductMz.Length);
                double pmmScore = PsmCross.XlMatchIons(theScan.TheScan, fragmentTolerance, pmm.ProductMz, pmm.ProductName, matchedIonMassesListPositiveIsMatch);
                miil.Add(matchedIonMassesListPositiveIsMatch);
                scoreList.Add(pmmScore);
            }

            psmCross.XLBestScore    = scoreList.Max();
            psmCross.MatchedIonInfo = miil[scoreList.IndexOf(scoreList.Max())];
            psmCross.XlPos          = pmmhList[scoreList.IndexOf(scoreList.Max())].XlPos + 1;
            psmCross.XlPos2         = pmmhList[scoreList.IndexOf(scoreList.Max())].XlPos2 + 1;
        }
Example #3
0
        //Targetting function: to find two peptides that in the Top matched peptides
        private PsmCross FindCrosslinkedPeptide(Ms2ScanWithSpecificMass theScan, List <BestPeptideScoreNotch> theScanBestPeptide, int i)
        {
            List <PsmCross> bestPsmCrossList       = new List <PsmCross>();
            PsmCross        bestPsmCross           = null;
            string          crosslinkerModSitesAll = new string((Crosslinker.CrosslinkerModSites + Crosslinker.CrosslinkerModSites2).ToCharArray().Distinct().ToArray());

            for (int ind = 0; ind < theScanBestPeptide.Count; ind++)
            {
                //Single Peptide
                if (XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods) >= 0)
                {
                    var productMasses = theScanBestPeptide[ind].BestPeptide.ProductMassesMightHaveDuplicatesAndNaNs(ProductTypes);
                    Array.Sort(productMasses);
                    double score          = CalculatePeptideScoreOld(theScan.TheScan, commonParameters.ProductMassTolerance, productMasses, theScan.PrecursorMass, DissociationTypes, AddComplementaryIons, 0);
                    var    psmCrossSingle = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, score, i, theScan, commonParameters.DigestionParams);
                    psmCrossSingle.XLTotalScore = psmCrossSingle.Score;
                    psmCrossSingle.CrossType    = PsmCrossType.Singe;

                    bestPsmCrossList.Add(psmCrossSingle);
                }
                //Deadend Peptide
                else if (QuenchTris && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + Crosslinker.DeadendMassTris) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan, commonParameters.DigestionParams);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinkerModSitesAll);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, Crosslinker.DeadendMassTris, Crosslinker, ProductTypes, commonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndTris;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                else if (QuenchH2O && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + Crosslinker.DeadendMassH2O) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan, commonParameters.DigestionParams);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinkerModSitesAll);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, Crosslinker.DeadendMassH2O, Crosslinker, ProductTypes, commonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndH2O;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                else if (QuenchNH2 && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + Crosslinker.DeadendMassNH2) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan, commonParameters.DigestionParams);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinkerModSitesAll);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, Crosslinker.DeadendMassNH2, Crosslinker, ProductTypes, commonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndNH2;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                //loop peptide
                else if (Crosslinker.LoopMass != 0 && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + Crosslinker.LoopMass) >= 0)
                {
                    var psmCrossLoop = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan, commonParameters.DigestionParams);
                    var xlPos        = PsmCross.XlPosCal(psmCrossLoop.compactPeptide, Crosslinker.CrosslinkerModSites);
                    if (xlPos.Count() >= 2)
                    {
                        PsmCross.XlLocalizationForLoopCrosslink(theScan, psmCrossLoop, Crosslinker.LoopMass, Crosslinker, ProductTypes, commonParameters.ProductMassTolerance, xlPos);
                        psmCrossLoop.XLTotalScore = psmCrossLoop.XLBestScore;
                        psmCrossLoop.CrossType    = PsmCrossType.Loop;
                        bestPsmCrossList.Add(psmCrossLoop);
                    }
                }
                //Cross-linked peptide
                else if (theScan.PrecursorMass - theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods >= 200)
                {
                    var x = theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods;
                    for (int inx = ind; inx < theScanBestPeptide.Count; inx++)
                    {
                        var y = theScanBestPeptide[inx].BestPeptide.MonoisotopicMassIncludingFixedMods;
                        if (XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, x + y + Crosslinker.TotalMass) >= 0)
                        {
                            var psmCrossAlpha = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan, commonParameters.DigestionParams);
                            var psmCrossBeta  = new PsmCross(theScanBestPeptide[inx].BestPeptide, theScanBestPeptide[inx].BestNotch, theScanBestPeptide[inx].BestScore, i, theScan, commonParameters.DigestionParams);

                            PsmCross psmCross = null;
                            if (Crosslinker.CrosslinkerModSites == Crosslinker.CrosslinkerModSites2)
                            {
                                psmCross = XlSitesSame(theScan, psmCrossAlpha, psmCrossBeta, Crosslinker, ind, inx);
                            }
                            else
                            {
                                psmCross = XlSitesTwoDiff(theScan, psmCrossAlpha, psmCrossBeta, Crosslinker, ind, inx);
                            }

                            if (psmCross != null)
                            {
                                bestPsmCrossList.Add(psmCross);
                            }
                        }
                    }
                }
            }

            if (bestPsmCrossList.Count != 0)
            {
                bestPsmCross = bestPsmCrossList.OrderByDescending(p => p.XLTotalScore).First();
                if (bestPsmCrossList.Count > 1)
                {
                    bestPsmCross.DScore = Math.Abs(bestPsmCrossList.First().XLTotalScore - bestPsmCrossList[1].XLTotalScore);
                }
            }

            return(bestPsmCross);
        }
Example #4
0
        //Calculate All possible Products Masses based on ModMass and linkPos
        public static List <ProductMassesMightHave> XlCalculateTotalProductMassesForLoopCrosslink(PsmCross psmCross, double modMass, CrosslinkerTypeClass crosslinker, List <ProductType> lp, List <int> linkPos)
        {
            int length = psmCross.compactPeptide.NTerminalMasses.Length;
            var pmmh   = psmCross.ProductMassesMightHaveDuplicatesAndNaNs(lp);
            ProductMassesMightHave pmmhTop = new ProductMassesMightHave();

            List <ProductMassesMightHave> pmmhList = new List <ProductMassesMightHave>();

            if (linkPos.Count() >= 2)
            {
                for (int ipos = 0; ipos < linkPos.Count() - 1; ipos++)
                {
                    for (int jpos = ipos + 1; jpos < linkPos.Count(); jpos++)
                    {
                        var pmmhCurr = new ProductMassesMightHave();
                        pmmhCurr.XlPos  = linkPos[ipos];
                        pmmhCurr.XlPos2 = linkPos[jpos];
                        List <double> x = new List <double>();
                        List <string> y = new List <string>();

                        for (int i = 0; i < pmmh.ProductMz.Length; i++)
                        {
                            var cr = pmmh.ProductName[i][0];
                            //get the position of amino acid
                            var nm = Int32.Parse(System.Text.RegularExpressions.Regex.Match(pmmh.ProductName[i], @"\d+").Value);
                            if ((cr == 'b' || cr == 'c') && nm < linkPos[ipos] + 1)
                            {
                                x.Add(pmmh.ProductMz[i]);
                                y.Add(pmmh.ProductName[i]);
                            }
                            if ((cr == 'y' || cr == 'z') && nm < length - linkPos[jpos] + 1)
                            {
                                x.Add(pmmh.ProductMz[i]);
                                y.Add(pmmh.ProductName[i]);
                            }
                            if (cr == 'b' && nm >= linkPos[jpos] + 1)
                            {
                                x.Add(pmmh.ProductMz[i] + modMass);
                                y.Add("t1b" + nm.ToString());
                            }

                            if (cr == 'c' && nm >= linkPos[jpos] + 1)
                            {
                                x.Add(pmmh.ProductMz[i] + modMass);
                                y.Add("t1c" + nm.ToString());
                            }

                            if (cr == 'y' && (nm >= length - linkPos[ipos] + 1))
                            {
                                x.Add(pmmh.ProductMz[i] + modMass);
                                y.Add("t1y" + nm.ToString());
                            }

                            if (cr == 'z' && (nm >= length - linkPos[ipos] + 1))
                            {
                                x.Add(pmmh.ProductMz[i] + modMass);
                                y.Add("t1z" + nm.ToString());
                            }
                        }
                        pmmhCurr.ProductMz   = x.ToArray();
                        pmmhCurr.ProductName = y.ToArray();
                        Array.Sort(pmmhCurr.ProductMz, pmmhCurr.ProductName);
                        pmmhList.Add(pmmhCurr);
                    }
                }
            }
            return(pmmhList);
        }
Example #5
0
        //Calculate score based on All possible Products Masses for inter- or intra- crosslinks and deadend.
        public static void XlLocalization(Ms2ScanWithSpecificMass theScan, PsmCross psmCross, double modMass,
                                          CrosslinkerTypeClass crosslinker, List <ProductType> lp, Tolerance fragmentTolerance, bool Charge_2_3, bool Charge_2_3_PrimeFragment, List <int> linkPos)
        {
            var pmmhList = PsmCross.XlCalculateTotalProductMasses(psmCross, modMass, crosslinker, lp, Charge_2_3, Charge_2_3_PrimeFragment, linkPos);

            List <double>         scoreList = new List <double>();
            List <MatchedIonInfo> miil      = new List <MatchedIonInfo>();

            foreach (var pmm in pmmhList)
            {
                var    matchedIonMassesListPositiveIsMatch = new MatchedIonInfo(pmm.ProductMz.Length);
                double pmmScore = PsmCross.XlMatchIons(theScan.TheScan, fragmentTolerance, pmm.ProductMz, pmm.ProductName, matchedIonMassesListPositiveIsMatch);
                miil.Add(matchedIonMassesListPositiveIsMatch);
                scoreList.Add(pmmScore);
            }

            psmCross.XLBestScore    = scoreList.Max();
            psmCross.MatchedIonInfo = miil[scoreList.IndexOf(scoreList.Max())];
            psmCross.XlPos          = pmmhList[scoreList.IndexOf(scoreList.Max())].XlPos + 1;
            if (crosslinker.Cleavable)
            {
                psmCross.ParentIonMaxIntensityRanks = new List <int>();
                if (psmCross.MatchedIonInfo.MatchedIonName.Any(p => p != null && p.Contains("PepS")))
                {
                    psmCross.ParentIonExist    += "PepS";
                    psmCross.ParentIonExistNum += 1;
                }
                if (psmCross.MatchedIonInfo.MatchedIonName.Any(p => p != null && p.Contains("PepL")))
                {
                    psmCross.ParentIonExist    += "PepL";
                    psmCross.ParentIonExistNum += 1;
                }
                //if (psmCross.MatchedIonInfo.MatchedIonName.Any(p => p != null && p.Equals("PepS2")))
                //{
                //    psmCross.ParentIonExist += "PepS2";
                //    psmCross.ParentIonExistNum += 1;
                //}
                //if (psmCross.MatchedIonInfo.MatchedIonName.Any(p => p != null && p.Equals("PepL2")))
                //{
                //    psmCross.ParentIonExist += "PepL2";
                //    psmCross.ParentIonExistNum += 1;
                //}
                for (int i = 0; i < psmCross.MatchedIonInfo.MatchedIonName.Length; i++)
                {
                    if (psmCross.MatchedIonInfo.MatchedIonName[i] != null)
                    {
                        if (psmCross.MatchedIonInfo.MatchedIonName[i].Contains("Pep"))
                        {
                            psmCross.ParentIonMaxIntensityRanks.Add(psmCross.MatchedIonInfo.MatchedIonIntensityRank[i]);
                        }
                    }
                }
            }
            if (Charge_2_3 || Charge_2_3_PrimeFragment)
            {
                int Charge2IonExist = 0;
                for (int i = 0; i < psmCross.MatchedIonInfo.MatchedIonName.Length; i++)
                {
                    if (psmCross.MatchedIonInfo.MatchedIonName[i] != null && (psmCross.MatchedIonInfo.MatchedIonName[i].Contains("t2") || psmCross.MatchedIonInfo.MatchedIonName[i].Contains("t3")))
                    {
                        Charge2IonExist++;
                    }
                }
                psmCross.Charge2IonExist = Charge2IonExist;
            }
        }
Example #6
0
        //Calculate All possible Products Masses based on ModMass and linkPos
        public static List <ProductMassesMightHave> XlCalculateTotalProductMasses(PsmCross psmCross, double modMass,
                                                                                  CrosslinkerTypeClass crosslinker, List <ProductType> lp, bool Charge_2_3, bool Charge_2_3_PrimeFragment, List <int> linkPos)
        {
            int length = psmCross.compactPeptide.NTerminalMasses.Length;
            var pmmh   = psmCross.ProductMassesMightHaveDuplicatesAndNaNs(lp);
            ProductMassesMightHave pmmhTop = new ProductMassesMightHave();

            List <ProductMassesMightHave> pmmhList = new List <ProductMassesMightHave>();

            foreach (var ipos in linkPos)
            {
                var pmmhCurr = new ProductMassesMightHave();
                pmmhCurr.XlPos = ipos;
                List <double> x = new List <double>();
                List <string> y = new List <string>();
                if (crosslinker.Cleavable)
                {
                    x.Add((double)psmCross.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.CleaveMassShort);
                    y.Add("PepS");
                    x.Add(((double)psmCross.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.CleaveMassShort) / 2);
                    y.Add("PepS2");
                    x.Add((double)psmCross.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.CleaveMassLong);
                    y.Add("PepL");
                    x.Add(((double)psmCross.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.CleaveMassLong) / 2);
                    y.Add("PepL2");
                }
                for (int i = 0; i < pmmh.ProductMz.Length; i++)
                {
                    var cr = pmmh.ProductName[i][0];
                    //get the position of amino acid
                    var nm = Int32.Parse(System.Text.RegularExpressions.Regex.Match(pmmh.ProductName[i], @"\d+").Value);
                    if ((cr == 'b' || cr == 'c') && nm < ipos + 1)
                    {
                        x.Add(pmmh.ProductMz[i]);
                        y.Add(pmmh.ProductName[i]);
                        if (Charge_2_3_PrimeFragment && cr == 'b')
                        {
                            x.Add(pmmh.ProductMz[i] / 2);
                            y.Add("t2b" + nm.ToString());
                            x.Add(pmmh.ProductMz[i] / 3);
                            y.Add("t3b" + nm.ToString());
                        }
                        if (Charge_2_3_PrimeFragment && cr == 'c')
                        {
                            x.Add(pmmh.ProductMz[i] / 2);
                            y.Add("t2c" + nm.ToString());
                            x.Add(pmmh.ProductMz[i] / 3);
                            y.Add("t3c" + nm.ToString());
                        }
                    }
                    if ((cr == 'y' || cr == 'z') && nm < length - ipos + 1)
                    {
                        x.Add(pmmh.ProductMz[i]);
                        y.Add(pmmh.ProductName[i]);
                        if (Charge_2_3_PrimeFragment && cr == 'y')
                        {
                            x.Add(pmmh.ProductMz[i] / 2);
                            y.Add("t2y" + nm.ToString());
                            x.Add(pmmh.ProductMz[i] / 3);
                            y.Add("t3y" + nm.ToString());
                        }
                        if (Charge_2_3_PrimeFragment && cr == 'z')
                        {
                            x.Add(pmmh.ProductMz[i] / 2);
                            y.Add("t2z" + nm.ToString());
                            x.Add(pmmh.ProductMz[i] / 3);
                            y.Add("t3z" + nm.ToString());
                        }
                    }
                    if (cr == 'b' && nm >= ipos + 1)
                    {
                        x.Add(pmmh.ProductMz[i] + modMass);
                        y.Add("t1b" + nm.ToString());
                        if (Charge_2_3)
                        {
                            x.Add((pmmh.ProductMz[i] + modMass) / 2);
                            y.Add("t2b" + nm.ToString());
                            x.Add((pmmh.ProductMz[i] + modMass) / 3);
                            y.Add("t3b" + nm.ToString());
                        }
                        if (crosslinker.Cleavable)
                        {
                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassShort);
                            y.Add("sb" + nm.ToString());

                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassLong);
                            y.Add("lb" + nm.ToString());
                        }
                    }

                    if (cr == 'c' && nm >= ipos + 1)
                    {
                        x.Add(pmmh.ProductMz[i] + modMass);
                        y.Add("t1c" + nm.ToString());
                        if (Charge_2_3)
                        {
                            x.Add((pmmh.ProductMz[i] + modMass) / 2);
                            y.Add("t2c" + nm.ToString());
                            x.Add((pmmh.ProductMz[i] + modMass) / 3);
                            y.Add("t3c" + nm.ToString());
                        }

                        if (crosslinker.Cleavable)
                        {
                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassShort);
                            y.Add("sc" + nm.ToString());

                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassLong);
                            y.Add("lc" + nm.ToString());
                        }
                    }

                    if (cr == 'y' && (nm >= length - ipos + 1))
                    {
                        x.Add(pmmh.ProductMz[i] + modMass);
                        y.Add("t1y" + nm.ToString());

                        if (Charge_2_3)
                        {
                            x.Add((pmmh.ProductMz[i] + modMass) / 2);
                            y.Add("t2y" + nm.ToString());
                            x.Add((pmmh.ProductMz[i] + modMass) / 3);
                            y.Add("t3y" + nm.ToString());
                        }
                        if (crosslinker.Cleavable)
                        {
                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassShort);
                            y.Add("sy" + nm.ToString());

                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassLong);
                            y.Add("ly" + nm.ToString());
                        }
                    }

                    if (cr == 'z' && (nm >= length - ipos + 1))
                    {
                        x.Add(pmmh.ProductMz[i] + modMass);
                        y.Add("t1z" + nm.ToString());
                        if (Charge_2_3)
                        {
                            x.Add((pmmh.ProductMz[i] + modMass) / 2);
                            y.Add("t2z" + nm.ToString());
                            x.Add((pmmh.ProductMz[i] + modMass) / 3);
                            y.Add("t3z" + nm.ToString());
                        }
                        if (crosslinker.Cleavable)
                        {
                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassShort);
                            y.Add("sz" + nm.ToString());

                            x.Add(pmmh.ProductMz[i] + crosslinker.CleaveMassLong);
                            y.Add("lz" + nm.ToString());
                        }
                    }
                }
                pmmhCurr.ProductMz   = x.ToArray();
                pmmhCurr.ProductName = y.ToArray();
                Array.Sort(pmmhCurr.ProductMz, pmmhCurr.ProductName);
                pmmhList.Add(pmmhCurr);
            }

            return(pmmhList);
        }
Example #7
0
        //Calculate All possible Products Masses based on ModMass and linkPos
        public static ProductMassesMightHave XlCalculateTotalProductMassesForSingle(PsmCross psmCross, List <ProductType> lp, bool Charge_2_3_PrimeFragment)
        {
            int length = psmCross.compactPeptide.NTerminalMasses.Length;
            var pmmh   = psmCross.ProductMassesMightHaveDuplicatesAndNaNs(lp);

            var pmmhCurr = new ProductMassesMightHave();

            List <double> x = new List <double>();
            List <string> y = new List <string>();

            for (int i = 0; i < pmmh.ProductMz.Length; i++)
            {
                var cr = pmmh.ProductName[i][0];
                //get the position of amino acid
                var nm = Int32.Parse(System.Text.RegularExpressions.Regex.Match(pmmh.ProductName[i], @"\d+").Value);
                if ((cr == 'b' || cr == 'c') && nm <= length + 1)
                {
                    x.Add(pmmh.ProductMz[i]);
                    y.Add(pmmh.ProductName[i]);
                    if (Charge_2_3_PrimeFragment && cr == 'b')
                    {
                        x.Add(pmmh.ProductMz[i] / 2);
                        y.Add("t2b" + nm.ToString());
                        x.Add(pmmh.ProductMz[i] / 3);
                        y.Add("t3b" + nm.ToString());
                    }
                    if (Charge_2_3_PrimeFragment && cr == 'c')
                    {
                        x.Add(pmmh.ProductMz[i] / 2);
                        y.Add("t2c" + nm.ToString());
                        x.Add(pmmh.ProductMz[i] / 3);
                        y.Add("t3c" + nm.ToString());
                    }
                }
                if ((cr == 'y' || cr == 'z') && nm <= length + 1)
                {
                    x.Add(pmmh.ProductMz[i]);
                    y.Add(pmmh.ProductName[i]);
                    if (Charge_2_3_PrimeFragment && cr == 'y')
                    {
                        x.Add(pmmh.ProductMz[i] / 2);
                        y.Add("t2y" + nm.ToString());
                        x.Add(pmmh.ProductMz[i] / 3);
                        y.Add("t3y" + nm.ToString());
                    }
                    if (Charge_2_3_PrimeFragment && cr == 'z')
                    {
                        x.Add(pmmh.ProductMz[i] / 2);
                        y.Add("t2z" + nm.ToString());
                        x.Add(pmmh.ProductMz[i] / 3);
                        y.Add("t3z" + nm.ToString());
                    }
                }
            }
            pmmhCurr.ProductMz   = x.ToArray();
            pmmhCurr.ProductName = y.ToArray();

            Array.Sort(pmmhCurr.ProductMz, pmmhCurr.ProductName);


            return(pmmhCurr);
        }
Example #8
0
        //Targetting function: to find two peptides that in the Top matched peptides
        private PsmCross FindCrosslinkedPeptide(Ms2ScanWithSpecificMass theScan, List <BestPeptideScoreNotch> theScanBestPeptide, int i)
        {
            List <PsmCross> bestPsmCrossList = new List <PsmCross>();
            PsmCross        bestPsmCross     = null;

            for (int ind = 0; ind < theScanBestPeptide.Count; ind++)
            {
                //Single Peptide
                if (XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods) >= 0)
                {
                    var productMasses = theScanBestPeptide[ind].BestPeptide.ProductMassesMightHaveDuplicatesAndNaNs(lp);
                    Array.Sort(productMasses);
                    double score          = CalculatePeptideScore(theScan.TheScan, CommonParameters.ProductMassTolerance, productMasses, theScan.PrecursorMass, dissociationTypes, addCompIons, 0);
                    var    psmCrossSingle = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, score, i, theScan);
                    psmCrossSingle.XLTotalScore = psmCrossSingle.Score;
                    psmCrossSingle.CrossType    = PsmCrossType.Singe;

                    bestPsmCrossList.Add(psmCrossSingle);
                }
                //Deadend Peptide
                else if (quench_Tris && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.DeadendMassTris) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinker);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, crosslinker.DeadendMassTris, crosslinker, lp, CommonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndTris;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                else if (quench_H2O && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.DeadendMassH2O) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinker);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, crosslinker.DeadendMassH2O, crosslinker, lp, CommonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndH2O;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                else if (quench_NH2 && XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.DeadendMassNH2) >= 0)
                {
                    var psmCrossEnd = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan);
                    var xlPos       = PsmCross.XlPosCal(psmCrossEnd.compactPeptide, crosslinker);
                    if (xlPos.Count() >= 1)
                    {
                        PsmCross.XlLocalization(theScan, psmCrossEnd, crosslinker.DeadendMassNH2, crosslinker, lp, CommonParameters.ProductMassTolerance, false, false, xlPos);
                        psmCrossEnd.XLTotalScore = psmCrossEnd.XLBestScore;
                        psmCrossEnd.CrossType    = PsmCrossType.DeadEndNH2;
                        bestPsmCrossList.Add(psmCrossEnd);
                    }
                }
                //loop peptide
                else if (XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.LoopMass) >= 0)
                {
                    var psmCrossLoop = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan);
                    var xlPos        = PsmCross.XlPosCal(psmCrossLoop.compactPeptide, crosslinker);
                    if (xlPos.Count() >= 2)
                    {
                        PsmCross.XlLocalizationForLoopCrosslink(theScan, psmCrossLoop, crosslinker.LoopMass, crosslinker, lp, CommonParameters.ProductMassTolerance, xlPos);
                        psmCrossLoop.XLTotalScore = psmCrossLoop.XLBestScore;
                        psmCrossLoop.CrossType    = PsmCrossType.Loop;
                        bestPsmCrossList.Add(psmCrossLoop);
                    }
                }
                //Cross-linked peptide
                else if (theScan.PrecursorMass - theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods >= 200)
                {
                    var x = theScanBestPeptide[ind].BestPeptide.MonoisotopicMassIncludingFixedMods;
                    for (int inx = ind; inx < theScanBestPeptide.Count; inx++)
                    {
                        var y = theScanBestPeptide[inx].BestPeptide.MonoisotopicMassIncludingFixedMods;
                        if (XLPrecusorSearchMode.Accepts(theScan.PrecursorMass, x + y + crosslinker.TotalMass) >= 0 && PsmCross.XlPosCal(theScanBestPeptide[ind].BestPeptide, crosslinker).Count != 0 && PsmCross.XlPosCal(theScanBestPeptide[inx].BestPeptide, crosslinker).Count != 0)
                        {
                            var psmCrossAlpha = new PsmCross(theScanBestPeptide[ind].BestPeptide, theScanBestPeptide[ind].BestNotch, theScanBestPeptide[ind].BestScore, i, theScan);
                            var psmCrossBeta  = new PsmCross(theScanBestPeptide[inx].BestPeptide, theScanBestPeptide[inx].BestNotch, theScanBestPeptide[inx].BestScore, i, theScan);
                            var xlPosAlpha    = PsmCross.XlPosCal(psmCrossAlpha.compactPeptide, crosslinker);
                            var xlPosBeta     = PsmCross.XlPosCal(psmCrossBeta.compactPeptide, crosslinker);
                            if (xlPosAlpha.Count() >= 1 && xlPosBeta.Count() >= 1)
                            {
                                PsmCross.XlLocalization(theScan, psmCrossAlpha, psmCrossBeta.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, lp, CommonParameters.ProductMassTolerance, charge_2_3, charge_2_3_PrimeFragment, xlPosAlpha);
                                PsmCross.XlLocalization(theScan, psmCrossBeta, psmCrossAlpha.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, lp, CommonParameters.ProductMassTolerance, charge_2_3, charge_2_3_PrimeFragment, xlPosBeta);

                                if (psmCrossAlpha.XLBestScore < psmCrossBeta.XLBestScore)
                                {
                                    var swap = psmCrossAlpha;
                                    psmCrossAlpha = psmCrossBeta;
                                    psmCrossBeta  = swap;
                                }
                                psmCrossAlpha.XlRank             = new int[] { ind, inx };
                                psmCrossAlpha.XLTotalScore       = psmCrossAlpha.XLBestScore + psmCrossBeta.XLBestScore;
                                psmCrossAlpha.XLQvalueTotalScore = Math.Sqrt(psmCrossAlpha.XLBestScore) * psmCrossBeta.XLBestScore;
                                psmCrossAlpha.BetaPsmCross       = psmCrossBeta;
                                if (crosslinker.Cleavable)
                                {
                                    psmCrossAlpha.ParentIonMaxIntensityRanks.AddRange(psmCrossBeta.ParentIonMaxIntensityRanks);
                                    psmCrossAlpha.ParentIonExistNum += psmCrossBeta.ParentIonExistNum;
                                }
                                psmCrossAlpha.CrossType = PsmCrossType.Cross;
                                bestPsmCrossList.Add(psmCrossAlpha);
                            }
                        }
                    }
                }
            }

            if (bestPsmCrossList.Count != 0)
            {
                bestPsmCross = bestPsmCrossList.OrderByDescending(p => p.XLTotalScore).First();
                if (bestPsmCrossList.Count > 1)
                {
                    bestPsmCross.DScore = Math.Abs(bestPsmCrossList.First().XLTotalScore - bestPsmCrossList[1].XLTotalScore);
                }
            }

            return(bestPsmCross);
        }