public MSMatch(MSMatch MS) { Score = MS.Score; MZ = MS.MZ; RT = MS.RT; FirstIsotope = MS.FirstIsotope; SecondIsotope = MS.SecondIsotope; TimeCoeff = MS.TimeCoeff; if (LowerCharges != null) { LowerCharges = new MSMatch(MS.LowerCharges); } else { LowerCharges = null; } if (UpperCharges != null) { UpperCharges = new MSMatch(MS.UpperCharges); } else { UpperCharges = null; } }
public MSMatch FindMatchwithCharges(int Scan, double MZ, int Charge, double LowMZ, double HighMZ) { //double LowMZ = (MZ * Charge + (float) 1.007277) / (Charge + 1); //double HighMZ = (MZ * Charge - 1.007277) / (Charge - 1); MSMatch First = FindMatch(Scan, MZ, Charge); if (First.Score == 0.0 || First.SecondIsotope == 0.0) { return(First); } MSMatch Ret; if (Charge > 1) { Ret = FindMatch(Scan, HighMZ, Charge - 1); if (Ret.Score != 0.0 && Ret.SecondIsotope > 0.0) { First.LowerCharges = Ret; } } Ret = FindMatch(Scan, LowMZ, Charge + 1); if (Ret.Score != 0.0 && Ret.SecondIsotope > 0.0) { First.UpperCharges = Ret; } return(First); }
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; LongESICoef = Match.LongESICoef; 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; } }
public void LoadMSMatches(List <QPeptide> Peptides) { iLog.Log("Loading Peak Shapes"); iLog.RepProgress(0); for (int f = 0; f < Peptides[0].Matches.GetLength(0); f++) { int FileNumber = FileNumbers[f]; SQLiteCommand Select = new SQLiteCommand( "Select FileNumber, MascotScan, Charge, Score, MZ, RT, FirstIsotope, SecondIsotope, TimeCoeff " + String.Format("From MSMatches Where FileNumber = {0} ", FileNumber) + "Order by MascotScan,RT ", con); SQLiteDataReader Reader = Select.ExecuteReader(); MSMatch[] Charges = new MSMatch[12]; bool flag = true; Reader.Read(); iLog.RepProgress(f * 100 / Peptides[0].Matches.GetLength(0)); for (int i = 0; i < Peptides.Count; i++) { while (Reader.GetInt32(1) < Peptides[i].MascotScan) { flag = Reader.Read(); if (!flag) { break; } } if (!flag) { break; } while (Reader.GetInt32(1) == Peptides[i].MascotScan) { for (int j = 0; j < 12; j++) { Charges[j] = null; } FileNumber = Reader.GetInt32(0); double RT = Reader.GetDouble(5); while (Reader.GetInt32(0) == FileNumber && Reader.GetInt32(1) == Peptides[i].MascotScan && RT == Reader.GetDouble(5)) { int Charge = Reader.GetInt32(2); Charges[Charge] = new MSMatch(); Charges[Charge].Score = Reader.GetDouble(3); Charges[Charge].MZ = Reader.GetDouble(4); Charges[Charge].RT = Reader.GetDouble(5); Charges[Charge].FirstIsotope = Reader.GetDouble(6); Charges[Charge].SecondIsotope = Reader.GetDouble(7); Charges[Charge].TimeCoeff = Reader.GetDouble(8); flag = Reader.Read(); if (!flag) { break; } } if (Charges[Peptides[i].Charge - 1] != null) { Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge - 1]; } if (Charges[Peptides[i].Charge + 1] != null) { Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge + 1]; } Peptides[i].Matches[f].MSMatches.Add(Charges[Peptides[i].Charge]); if (!flag) { break; } } if (!flag) { break; } } } }
public void LoadMSMatches(List <QPeptide> Peptides) { iLog.Log("Loading Peak Shapes"); iLog.RepProgress(0); int FileNumber; int BandID = -1; int SampleID = 0; if (Bands < 0) { FileNumber = FileNumbers.Count; } else { FileNumber = BandList.GetLength(0) * BandList.GetLength(1); } for (int f = 0; f < FileNumber; f++) { int FileID; if (Bands < 0) { FileID = FileNumbers[f]; SampleID = f; } else { FileID = f; BandID = f / SampleNumber; SampleID = f % SampleNumber; } SQLiteCommand Select = new SQLiteCommand( "Select FileNumber, MascotScan, Charge, Score, MZ, RT, FirstIsotope, SecondIsotope, TimeCoeff " + String.Format("From MSMatches Where FileNumber = {0} ", FileID) + "Order by MascotScan,RT ", con); SQLiteDataReader Reader = Select.ExecuteReader(); MSMatch[] Charges = new MSMatch[12]; bool flag = true; Reader.Read(); if (!Reader.HasRows) { break; } iLog.RepProgress(f, FileNumber); for (int i = 0; i < Peptides.Count; i++) { while (Peptides[i].BandID != BandID) { i++; flag = (i < Peptides.Count); if (!flag) { break; } } if (!flag) { break; } while (Reader.GetInt32(1) < Peptides[i].MascotScan) { flag = Reader.Read(); if (!flag) { break; } } if (!flag) { break; } while (Reader.GetInt32(1) == Peptides[i].MascotScan) { for (int j = 0; j < 12; j++) { Charges[j] = null; } //FileNumber = Reader.GetInt32(0); double RT = Reader.GetDouble(5); while (//Reader.GetInt32(0) == FileNumber && Reader.GetInt32(1) == Peptides[i].MascotScan && RT == Reader.GetDouble(5)) { int Charge = Reader.GetInt32(2); Charges[Charge] = new MSMatch(); Charges[Charge].Score = Reader.GetDouble(3); Charges[Charge].MZ = Reader.GetDouble(4); Charges[Charge].RT = Reader.GetDouble(5); Charges[Charge].FirstIsotope = Reader.GetDouble(6); Charges[Charge].SecondIsotope = Reader.GetDouble(7); Charges[Charge].TimeCoeff = Reader.GetDouble(8); flag = Reader.Read(); if (!flag) { break; } } if (Charges[Peptides[i].Charge - 1] != null) { Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge - 1]; } if (Charges[Peptides[i].Charge + 1] != null) { //порпавить в версии 2.6 - должно быть: Charges[Peptides[i].Charge].UpperCharges = Charges[Peptides[i].Charge + 1]; } //Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge+1]; Peptides[i].Matches[SampleID].MSMatches.Add(Charges[Peptides[i].Charge]); if (!flag) { break; } } if (!flag) { break; } } } }
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 (Settings.Default.Deconvolution) //прихватываем другие зарядовые состояния { First = FindMatchwithCharges(Scan, MZ, Charge, LowMZ, HighMZ); } else { First = FindMatch(Scan, MZ, Charge); } //если не найден сам пик или его первый изотоп - сбрасываем if (First.Score == 0.0 || First.SecondIsotope == 0.0) { 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) { 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 (Settings.Default.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) { Res.MSMatches.Add(First); break; } fs = First.SecondIsotope / First.FirstIsotope; //включаем здесь контроль по соотношению изотопов //if (fs < IsoRatio*0.5 || fs > IsoRatio * 2 ){ // break; //} Res.MSMatches.Add(First); } //берем сплошную область вокруг Best - назад for (Scan = IndexRev[BestIndex]; Scan > 0; Scan = IndexRev[Scan]) { if (Settings.Default.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) { Res.MSMatches.Add(First); break; } fs = First.SecondIsotope / First.FirstIsotope; //включаем здесь контроль по соотношению изотопов //if (fs < IsoRatio*0.5 || fs > IsoRatio * 2 ){ // break; //} Res.MSMatches.Insert(0, First); } Res.Estimate(IsoRatio); Res.CleanUp(); return(Res); }
public MSMatch FindMatch(int Scan, double MZ, int Charge) { MSMatch ret = new MSMatch(); ret.Score = 0.0; ret.FirstIsotope = 0.0; ret.SecondIsotope = 0.0; ret.TimeCoeff = RTCorrection?TimeCoefs[Scan]:1; double maxs = 0.0, curs, bestd, tk10low, tk10high; int i, t; int cur = ms2index[Scan]; //ворота по массе double mmi = MZ * ((1000000.0 - Convert.ToDouble(Settings.Default.MassError)) / 1000000.0); double mma = MZ * ((1000000.0 + Convert.ToDouble(Settings.Default.MassError)) / 1000000.0); RawData Peaks = RawSpectra[cur]; ret.RT = Peaks.RT; //Если сразу ясно что мы за пределами поиска int LowerIndex = FindMassAbove(Peaks, mmi); int UpperIndex = FindMassBelow(Peaks, mma); if (UpperIndex == -1 || LowerIndex == -1 || LowerIndex > UpperIndex) { return(ret); } while (LowerIndex <= UpperIndex) //for all masses that match { if (hasPreviousIsotope(Peaks, LowerIndex, Charge)) //skip this mass if Seq turns out Seq's a part of another peak { LowerIndex++; continue; } curs = Peaks.Data[LowerIndex].Intensity; tk10low = 0.0; tk10high = 0.0; for (i = 1; i < 3; ++i) { double maxs2 = Peaks.Data[LowerIndex].Mass + (1.003 / (double)Charge) * (double)i; double mmi2 = maxs2 * ((1000000.0 - Convert.ToDouble(Settings.Default.MassError)) / 1000000.0); double mma2 = maxs2 * ((1000000.0 + Convert.ToDouble(Settings.Default.MassError)) / 1000000.0); int LowerIndex2 = FindMassAbove(Peaks, mmi2); int UpperIndex2 = FindMassBelow(Peaks, mma2); if (LowerIndex2 > UpperIndex2 || LowerIndex2 == -1) //ничего не нашли - ничего и не делаем { continue; } bestd = maxs2; while (LowerIndex2 < UpperIndex2) //если больше одного - ищем самый близкий к целевой массе { if (Math.Abs(maxs2 - Peaks.Data[LowerIndex2].Mass) < bestd) { bestd = Math.Abs(maxs2 - Peaks.Data[LowerIndex2].Mass); t = LowerIndex2; } LowerIndex2++; } if (i == 1) { tk10low = curs; tk10high = Peaks.Data[LowerIndex2].Intensity; } curs += Peaks.Data[LowerIndex2].Intensity; } if (maxs < curs) { maxs = curs; ret.Score = curs; ret.MZ = Peaks.Data[LowerIndex].Mass; ret.RT = Peaks.RT; ret.FirstIsotope = tk10low; ret.SecondIsotope = tk10high; } LowerIndex++; } if (RTCorrection) { ret.Score *= TimeCoefs[Scan]; } if (ESICorrection) { ret.Score = ret.Score / ESICurrents[Scan]; } if (ret.SecondIsotope == 0.0) { ret.Score = 0.0; } return(ret); }