public QMatch(QMatch Match)
 {
     ApexRT       = Match.ApexRT;
     ApexScore    = Match.ApexScore;
     ApexMZ       = Match.ApexMZ;
     ApexIndex    = Match.ApexIndex;
     Score        = Match.Score;
     RTDisp       = Match.RTDisp;
     IsotopeRatio = Match.IsotopeRatio;
     MaxConv      = Match.MaxConv;
     Shift        = Match.Shift;
     if (Match.MSMatches != null)
     {
         MSMatches = new List <MSMatch>();
         MSMatch MS;
         for (int i = 0; i < Match.MSMatches.Count; i++)
         {
             MS = new MSMatch(Match.MSMatches[i]);
             MSMatches.Add(MS);
         }
     }
     else
     {
         MSMatches = null;
     }
 }
Пример #2
0
 public QPeptide()
 {
     Match           = new QMatch();
     AlreadySearched = false;
 }
        public QMatch FindBestScore(double MZ, int Charge, double IsoRatio, double MinRT, double MaxRT)
        {
            MSMatch First = null, Best = null;

            QMatch Res = new QMatch();

            Res.Clean();
            Res.MSMatches = new List <MSMatch>();

            double FirstIso = 0.0, SecondIso = 0.0;
            double BestScore = 0.0, fs = 0.0;
            int    BestIndex = 0;

            int    Scan  = 0;
            double AveRT = (MinRT + MaxRT) / 2;

            RawFile.ScanNumFromRT(AveRT, ref Scan);
            Scan = ms2index[Scan];

            //отступаем до минимального времени RT в массиве спектров
            double LowMZ = (MZ * Charge + (float)1.007277) / (Charge + 1);
            double HighMZ;

            if (Charge > 1)
            {
                HighMZ = (MZ * Charge - 1.007277) / (Charge - 1);
            }
            else
            {
                HighMZ = 0.0;
            }

            while (Scan > 0 && RawSpectra[Scan].RT >= MinRT)
            {
                Scan = IndexRev[Scan];
            }

            //цикл поиска лучшего
            while (Scan != -1 && RawSpectra[Scan].RT <= MaxRT)
            {
                if (Program.Processor.Deconvolution) //прихватываем другие зарядовые состояния
                {
                    First = FindMatchwithCharges(Scan, MZ, Charge, LowMZ, HighMZ);
                }
                else
                {
                    First = FindMatch(Scan, MZ, Charge);
                }

                //если не найден сам пик или его первый изотоп - сбрасываем
                if (First.Score == 0.0 || (First.SecondIsotope == 0.0 && !Program.Processor.MetaProfile))
                {
                    Scan = IndexDir[Scan];
                    continue;
                }

                FirstIso = First.FirstIsotope +
                           (First.UpperCharges == null ? 0 : First.UpperCharges.FirstIsotope) +
                           (First.LowerCharges == null ? 0 : First.LowerCharges.FirstIsotope);
                SecondIso = First.SecondIsotope +
                            (First.UpperCharges == null ? 0 : First.UpperCharges.SecondIsotope) +
                            (First.LowerCharges == null ? 0 : First.LowerCharges.SecondIsotope);

                fs = SecondIso / FirstIso;

                double CurrentScore = First.Score +
                                      (First.UpperCharges == null ? 0 : First.UpperCharges.Score) +
                                      (First.LowerCharges == null ? 0 : First.LowerCharges.Score);

                //пик может распространяться за границы, но апекс должен быть внутри
                if (CurrentScore > BestScore && ((fs > IsoRatio * 0.5 && fs < IsoRatio * 2) || Program.Processor.MetaProfile))
                {
                    BestScore = CurrentScore;
                    BestIndex = Scan;
                    Best      = First;
                }
                //переходим к следующему full-ms
                Scan = IndexDir[Scan];
            }

            if (BestScore == 0.0)
            {
                return(null);
            }

            //если хоть что-то нашли
            //добавляем наибольшее
            LowMZ = (Best.MZ * Charge + (float)1.007277) / (Charge + 1);
            if (Charge > 1)
            {
                HighMZ = (MZ * Charge - 1.007277) / (Charge - 1);
            }
            else
            {
                HighMZ = 0.0;
            }


            Res.ApexRT = Best.RT;
            Res.MSMatches.Add(Best);

            //берем сплошную область вокруг Best - вперед
            for (Scan = IndexDir[BestIndex]; Scan > 0; Scan = IndexDir[Scan])
            {
                if (Program.Processor.Deconvolution)
                { //прихватываем другие зарядовые состояния
                    First = FindMatchwithCharges(Scan, Best.MZ, Charge, LowMZ, HighMZ);
                }
                else
                {
                    First = FindMatch(Scan, Best.MZ, Charge);
                }

                if (First.Score == 0.0 || (First.SecondIsotope == 0.0 && !Program.Processor.MetaProfile))
                {
                    Res.MSMatches.Add(First);
                    break;
                }

                //ограничение по уровню разрешения пика
                if (Program.Processor.MetaProfile && First.Score <= Best.Score * (Program.Processor.RTRes / 100.0))
                {
                    break;
                }

                //ограничение по ширине пика
                if (Program.Processor.MetaProfile && Res.MSMatches[Res.MSMatches.Count - 1].RT - Res.MSMatches[0].RT > Program.Processor.MaxRTWidth)
                {
                    return(null);
                }

                fs = First.SecondIsotope / First.FirstIsotope;
                //включаем здесь контроль по соотношению изотопов
                //if (fs < IsoRatio*0.5 || fs > IsoRatio * 2 ){
                //    break;
                //}
                //пик может распространяться за границы, но апекс должен быть внутри - по крайней мере для метаболитов
                if (Program.Processor.MetaProfile && First.RT > MaxRT && First.Score > Best.Score * 1.1)
                {
                    return(null);
                }

                Res.MSMatches.Add(First);
            }

            //берем сплошную область вокруг Best - назад
            for (Scan = IndexRev[BestIndex]; Scan > 0; Scan = IndexRev[Scan])
            {
                if (Program.Processor.Deconvolution)  //прихватываем другие зарядовые состояния
                {
                    First = FindMatchwithCharges(Scan, Best.MZ, Charge, LowMZ, HighMZ);
                }
                else
                {
                    First = FindMatch(Scan, Best.MZ, Charge);
                }

                if (First.Score == 0.0 || (First.SecondIsotope == 0.0 && !Program.Processor.MetaProfile))
                {
                    Res.MSMatches.Insert(0, First);
                    break;
                }
                //ограничение по уровню разрешения пика
                if (Program.Processor.MetaProfile && First.Score <= Best.Score * (Program.Processor.RTRes / 100.0))
                {
                    break;
                }

                //ограничение по ширине пика
                if (Program.Processor.MetaProfile && Res.MSMatches[Res.MSMatches.Count - 1].RT - Res.MSMatches[0].RT > Program.Processor.MaxRTWidth)
                {
                    return(null);
                }

                fs = First.SecondIsotope / First.FirstIsotope;
                //включаем здесь контроль по соотношению изотопов
                //if (fs < IsoRatio*0.5 || fs > IsoRatio * 2 ){
                //    break;
                //}
                Res.MSMatches.Insert(0, First);

                //пик может распространяться за границы, но апекс должен быть внутри - по крайней мере для метаболитов
                if (Program.Processor.MetaProfile && First.RT < MinRT && First.Score > Best.Score * 1.1)
                {
                    return(null);
                }
            }
            if (Program.Processor.MetaProfile && Res.MSMatches[Res.MSMatches.Count - 1].RT - Res.MSMatches[0].RT < Program.Processor.MinRTWidth)
            {
                return(null);
            }

            Res.Estimate(IsoRatio);
            Res.CleanUp();

            return(Res);
        }