public void FirstSearch(List <QPeptide> Peptides) { double RTPercDelta = Program.Processor.RTErrorProc / 100.0; double RTMinutesDelta = Program.Processor.RTErrorMinutes; double rtMAX, rtMIN; int Progress = 0; for (int i1 = 0; i1 < Peptides.Count; i1++) { QPeptide data = Peptides[i1]; if ((int)(((double)i1 / (double)Peptides.Count) * 100.0) > Progress) { Progress = (int)(((double)i1 / (double)Peptides.Count) * 100.0); iLog.RepProgress(Progress); } if (data.Sequence != null) { data.TheorIsotopeRatio = AveragineIsotopicScore((data.MascotMZ - 1) * data.Charge); //data.TheorIsotopeRatio = IsotopicScore(data.Sequence); } else { data.TheorIsotopeRatio = AveragineIsotopicScore((data.MascotMZ - 1) * data.Charge); } rtMAX = data.MascotRT * (1 + RTPercDelta) + RTMinutesDelta; rtMIN = data.MascotRT * (1 - RTPercDelta) - RTMinutesDelta; data.Match = MSFile.FindBestScore(data.MascotMZ, data.Charge, data.TheorIsotopeRatio, rtMIN, rtMAX); } }
public void LoadMascots(List <QPeptide> Mascots) { iLog.Log("Loading Mascot Peptides"); iLog.RepProgress(0); SQLiteCommand Select = new SQLiteCommand( "Select MascotScan, MascotMZ, MascotScore, MascotRT, TheorIsoRatio, Charge, " + "IPI, ipis, Sequence, Peptides, ModDesc, ModMass, [Case] From Mascots " + "Order by IPI", con); SQLiteDataReader Reader = Select.ExecuteReader(); while (Reader.Read()) { QPeptide Pept = new QPeptide(); Pept.MascotScan = Reader.GetInt32(0); Pept.MascotMZ = Reader.GetDouble(1); Pept.MascotScore = Reader.GetDouble(2); Pept.MascotRT = Reader.GetDouble(3); Pept.TheorIsotopeRatio = Reader.GetDouble(4); Pept.Charge = Reader.GetInt32(5); Pept.IPI = Reader.GetString(6); //Pept.IPIs = Reader.GetString(7); Pept.Sequence = Reader.GetString(8); Pept.peptides = Reader.GetInt32(9); Pept.ModDesk = Reader.GetString(10); Pept.ModMass = Reader.GetDouble(11); Pept.Case = Reader.GetString(12); Mascots.Add(Pept); } }
public void Run() { Log.RepProgress(0); for (int i = 0; i < AlList.Count; i++) { ThreadProc(AlList[i]); //AlList[i].Run(); Log.RepProgress(100 * i / AlList.Count); } }
public void LoadMascots(List <QProtein> Proteins, List <QPeptide> Mascots) { iLog.Log("Loading Mascot Peptides"); iLog.RepProgress(0); SQLiteCommand Select = new SQLiteCommand( "Select MascotScan, MascotMZ, MascotScore, MascotRT, TheorIsoRatio, Charge, " + "IPI, ipis, Sequence, Peptides, ModDesc, ModMass, [Case]" + (Bands < 0?", -1":", BandID") + " From Mascots " + "Order by IPI", con); SQLiteDataReader Reader = Select.ExecuteReader(); Reader.Read(); for (int i = 0; i < Proteins.Count; i++) { while (Reader["IPI"].ToString() == Proteins[i].ipi) { QPeptide Pept = new QPeptide(); Pept.MascotScan = Reader.GetInt32(0); Pept.MascotMZ = Reader.GetDouble(1); Pept.MascotScore = Reader.GetDouble(2); Pept.MascotRT = Reader.GetDouble(3); Pept.TheorIsotopeRatio = Reader.GetDouble(4); Pept.Charge = Reader.GetInt32(5); Pept.IPI = Reader.GetString(6); Pept.IPIs = Utils.IPIStringtoList(Reader.GetString(7)); Pept.Sequence = Reader.GetString(8); Pept.peptides = Reader.GetInt32(9); Pept.ModDesk = Reader.GetString(10); Pept.ModMass = Reader.GetDouble(11); Pept.Case = Reader.IsDBNull(12)?"":Reader.GetString(12); Pept.BandID = Reader.GetInt32(13); Mascots.Add(Pept); Proteins[i].Peptides.Add(Pept); if (!Reader.Read()) { break; } } iLog.RepProgress(i, Proteins.Count); } }
static public void FillMSMSLists( ref List <QPeptide> Mascots, ref List <QPeptide> MSMSList, ref List <QProtein> Proteins, MascotParser mp) { Mascots = new List <QPeptide>(); MSMSList = new List <QPeptide>(); QPeptide data; int Best, i, j, k; SpectrabySeq comp = new SpectrabySeq(); mp.Spectra.Sort(comp); for (i = 0; i < mp.Spectra.Count; i++) { //если нет пептидов if (mp.Spectra[i].Peptides.Count == 0) { data = new QPeptide(mp, i); data.Case = "No peptides identified"; MSMSList.Add(data); continue; } //если у пептидов слишком маленький Score if (mp.Spectra[i].Peptides[0].Score < Convert.ToDouble(Settings.Default.MascotScore)) { data = new QPeptide(mp, i); data.Case = "Peptides identified under score limit"; MSMSList.Add(data); continue; } Best = i; if (Settings.Default.MascotScoreFiltering) { for (j = i + 1; j < mp.Spectra.Count; j++) { if (mp.Spectra[i].Peptides[0].Sequence != mp.Spectra[j].Peptides[0].Sequence) { break; } //определяем идентичность набора модификаций for (k = 0; k < mp.Spectra[i].Peptides[0].ModIndex.GetLength(0); k++) { if (mp.Spectra[i].Peptides[0].ModIndex[k] != mp.Spectra[j].Peptides[0].ModIndex[k]) { break; } } if (k < mp.Spectra[i].Peptides[0].ModIndex.GetLength(0) || mp.Spectra[i].Peptides[0].CModIndex != mp.Spectra[j].Peptides[0].CModIndex || mp.Spectra[i].Peptides[0].NModIndex != mp.Spectra[j].Peptides[0].NModIndex) { break; } //поиск лучшего по Score if (mp.Spectra[j].Peptides[0].Score > mp.Spectra[Best].Peptides[0].Score) { Best = j; } } //отмечаем нелучшие в списке всех MS/MS for (k = i; k < j; k++) { if (k != Best) { data = new QPeptide(mp, k); data.Case = string.Format("Not the best score ({0}) for peptide {1} (Max={2})", mp.Spectra[k].Peptides[0].Score, mp.Spectra[k].Peptides[0].Sequence, mp.Spectra[Best].Peptides[0].Score); MSMSList.Add(data); } } i = j - 1; } //только для лучшего по Score если пептид идентифицирован более одного раза data = new QPeptide(mp, Best); Mascots.Add(data); } //Фильтруем IPI //Спектр не может соответствовать нескольким IPI за исключением случая когда //набор спектров идентифицирующих один IPI является подмножеством (возможно полным) //спектров идентифицирующих другой IPI //собираем набор тех из них которые являются подмножествами других List <string> Processed = new List <string>(); //список в который откладываются List <string> ipiset = new List <string>(); //список всех IPI пептида кроме проверяемого List <string> NotDeps = new List <string>(); string[] dataexipis = null; foreach (QPeptide dataex in Mascots) //для каждого пептида { dataexipis = new string[dataex.IPIs.Count]; dataex.IPIs.CopyTo(dataexipis); foreach (string ipi in dataexipis) { if (!StringContains(ref Processed, ipi)) //если данный ipi еще не находится в списке обработанных { ipiset.Clear(); //составляем множество всех IPI пептида кроме проверяемого ipiset.AddRange(dataex.IPIs); StringRemove(ref ipiset, ipi); foreach (QPeptide chdata in Mascots) //составленный список будем соотносить с полным набором пептидов { if (dataex.MascotRT != chdata.MascotRT && StringContains(ref chdata.IPIs, ipi)) { //в этот момент мы установили что dataex и chdata имеют общий ipi foreach (string ipicheck in ipiset) { //здесь мы отбираем в Nodepts идентификаторы //которые не появляются вместе с ipi //отбор такого идентификатора в NoDepts означает что существует хотя бы один пептид // относящийся к ipi но не относящийся к этому идентификатору //и следовательно ipi не является зависимым от такого идентификатора if (!StringContains(ref chdata.IPIs, ipicheck) && !StringContains(ref NotDeps, ipicheck)) //если есть хотя бы один пептид с проверяемым IPI { NotDeps.Add(ipicheck); //не несущий какго-то из IPI начального списка //то целевой IPI не является зависимым от отсутствующего } } } } //если есть хотя бы один идентификатор который всегда встречается вместе с ipi //то в список Nodepts он никогда не попадет и неполнота списка Nodepts будет признаком //того что ipi зависит от другого идентификатора и должен быть исключен из списка //идентификаторов во всех пептидах if (ipiset.Count != NotDeps.Count) { foreach (QPeptide chdata in Mascots) { StringRemove(ref chdata.IPIs, ipi); } } else { Processed.Add(ipi); } NotDeps.Clear(); } } } iLog.RepProgress(50); //и теперь переносим только непротиворечивые List <QPeptide> OldMascots = Mascots; Mascots = new List <QPeptide>(); for (i = 0; i < OldMascots.Count; i++) { if (OldMascots[i].IPIs.Count == 1) { QPeptide remdata = OldMascots[i]; remdata.IPI = remdata.IPIs[0]; Mascots.Add(remdata); } else { string Mess = string.Format("This entry ambigously defined as part of {0} Proteins: ", OldMascots[i].IPIs.Count); for (j = 0; j < OldMascots[i].IPIs.Count; j++) { Mess = Mess + OldMascots[i].IPIs[j] + ", "; } Mess = Mess.Substring(0, Mess.Length - 2); OldMascots[i].Case = Mess; MSMSList.Add(OldMascots[i]); } } iLog.RepProgress(60); //теперь сортируем по белкам Mascots.Sort(new QPeptide.byIPIs()); //теперь фильтруем не набравшие достаточного количества пептидов iLog.RepProgress(70); QProtein Prot; Proteins = new List <QProtein>(); int Count = 0; string preIPI = ""; //!! здесь нет обработки последенего белка for (i = 0; i <= Mascots.Count; i++) { if (i < Mascots.Count && Mascots[i].IPI == preIPI) { Count++; } else { for (j = i - 1; i - j <= Count; j--) { QPeptide temp = Mascots[j]; temp.peptides = Count; Mascots[j] = temp; } if (Count >= Convert.ToInt32(Settings.Default.PeptperProt)) { Prot = new QProtein(); Prot.Peptides = new List <QPeptide>(); Prot.ipis = Mascots[i - 1].IPIs; Prot.ipi = Mascots[i - 1].IPI; Prot.Est = 0.0; for (j = i - 1; i - j <= Count; j--) { Prot.Peptides.Add(Mascots[j]); } //добываем из файла Маскот описания и имена белка for (j = 0; j < mp.Proteins.Count; j++) { if (mp.Proteins[j].Name == "\"" + Mascots[i - 1].IPI + "\"") { break; } } if (j < mp.Proteins.Count) { Prot.Name = mp.Proteins[j].Name; Prot.Desc = mp.Proteins[j].Descr; } else { Prot.Name = Prot.ipi; Prot.Desc = "This protein is not described in source .dat file. See initial FASTA file for protein description"; } Proteins.Add(Prot); } else { for (j = i - 1; i - j <= Count; j--) { Mascots[j].Case = string.Format("This entry belongs to \"{0}\" protein which have only {1} uniquely identified peptide(s)", Mascots[j].IPI, Count); MSMSList.Add(Mascots[j]); } } Count = 1; if (i < Mascots.Count) { preIPI = Mascots[i].IPI; } } } iLog.RepProgress(80); OldMascots = Mascots; Mascots = new List <QPeptide>(); for (i = 0; i < OldMascots.Count; i++) { if (OldMascots[i].peptides >= Convert.ToInt32(Settings.Default.PeptperProt)) { QPeptide remdata = OldMascots[i]; remdata.Case = string.Format("This entry belongs to \"{0}\" quntified protein", remdata.IPI); Mascots.Add(remdata); MSMSList.Add(remdata); } else { continue; } } iLog.RepProgress(90); //теперь сортируем по белкам и внутри них Mascots.Sort(new QPeptide.byMascotSN()); //и указываем теоретические отношения первых изотопов iLog.RepProgress(100); }
public int LoadIndex(string FileName) { this.RawFileName = FileName; RawFile = new XRawfile(); RawFile.Open(FileName); RawFile.SetCurrentController(0, 1); Spectra = 0; RawFile.GetNumSpectra(ref Spectra); if (Spectra <= 0) { return(0); } int i, lastfull = 0, total = 0; double TotalEsi = 0.0; ms2index = new int[Spectra + 1]; IndexDir = new int[Spectra + 1]; IndexRev = new int[Spectra + 1]; RawSpectra = new RawData[Spectra + 1]; Buf = new MZData[1000000]; ESICurrents = new double[Spectra + 1]; TimeStamps = new double[Spectra + 1]; TimeCoefs = new double[Spectra + 1]; string Filter = null; LowRT = 0.0; HighRT = 0.0; for (i = 1; i <= Spectra; i++) { iLog.RepProgress((int)(100.0 * ((double)i / (double)Spectra))); RawFile.GetFilterForScanNum(i, ref Filter); //YL - для спектров ms-only if ((Filter.IndexOf(" ms ") != -1) && (Filter.IndexOf("FTMS") != -1)) //is a FULL MS { TimeStamps[i] = RawSpectra[lastfull].RT; IndexDir[lastfull] = i; IndexRev[i] = lastfull; lastfull = i; ms2index[i] = lastfull; ++total; RawFile.RTFromScanNum(i, ref RawSpectra[i].RT); TotalRT = RawSpectra[i].RT; TimeStamps[i] = RawSpectra[i].RT - TimeStamps[i]; object Labels = null; object Values = null; int ArraySize = 0; double RT = 0.0; RawFile.GetStatusLogForScanNum(i, ref RT, ref Labels, ref Values, ref ArraySize); for (int k = 0; k < ArraySize; k++) { if ((Labels as Array).GetValue(k).ToString().Contains("Source Current")) { ESICurrents[i] = Convert.ToDouble((Values as Array).GetValue(k).ToString()); TotalEsi += ESICurrents[i]; } } } else { ms2index[i] = lastfull; } Filter = null; } IndexDir[lastfull] = -1; TotalRT = RawSpectra[lastfull].RT; AverageTimeStamp = TotalRT / total; //пересчитаем временные коэффициэнты for (i = IndexDir[0]; IndexDir[i] != -1; i = IndexDir[i]) { TimeCoefs[i] = (TimeStamps[i] + TimeStamps[IndexDir[i]]) / (2.0 * AverageTimeStamp); ESICurrents[i] = ESICurrents[i] / (TotalEsi / (double)total); } TimeCoefs[i] = 1.0; return(Spectra); }