protected bool processMS2(Spectra spec) { performanceEvaluator.countMS2(); log.Debug(spec); IDs id = performDatabaseSearch(spec); Boolean isExcluded = false; if (id != null) { Peptide pep = getPeptideFromIdentification(id); isExcluded = exclusionList.containsPeptide(pep); } if (isExcluded) { #if SIMULATION //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded."); evaluateExclusion(id); WriterClass.LogScanTime("Excluded", (int)spec.getIndex()); #endif performanceEvaluator.countExcludedSpectra(); excludedSpectra.Add(spec.getScanNum()); return(false); } else { performanceEvaluator.countAnalyzedSpectra(); //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed."); evaluateIdentification(id); includedSpectra.Add(spec.getScanNum()); // calibrate peptide if the observed retention time doesn't match the predicted //WriterClass.LogScanTime("Processed", (int)spec.getIndex()); return(true); } }
protected bool processMS2(Spectra spec) { performanceEvaluator.countMS2(); log.Debug(spec); IDs id = performDatabaseSearch(spec); // check if mass is on exclusion list Boolean isExcluded = false; if (id != null) { Peptide pep = getPeptideFromIdentification(id); isExcluded = exclusionList.containsPeptide(pep); //checks if the mass should've been excluded, //in a real experiment, this should never equal to true //since the mass should not have been scanned in the first place //if MS exclusion table was updated correctly through API if (!peptideRT.Keys.Contains(pep.getSequence())) { peptideRT.Add(pep.getSequence(), spec.getStartTime()); } } if (isExcluded) { #if SIMULATION //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded."); evaluateExclusion(id); WriterClass.LogScanTime("Excluded", (int)spec.getIndex()); #endif performanceEvaluator.countExcludedSpectra(); excludedSpectra.Add(spec.getScanNum()); return(false); } else { performanceEvaluator.countAnalyzedSpectra(); //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed."); evaluateIdentification(id); includedSpectra.Add(spec.getScanNum()); // calibrate peptide if the observed retention time doesn't match the predicted //WriterClass.LogScanTime("Processed", (int)spec.getIndex()); return(true); } }
protected void processMS1(Spectra spec) { log.Debug("MS1 scan, unused"); performanceEvaluator.countMS1(); includedSpectra.Add(spec.getScanNum()); }
public InfoContainer(bool common, Spectra spec) { table = new Dictionary <string, string>(); String msLevel = "MS"; if (spec.getMSLevel() == 2) { msLevel = "MS2"; } if (common) { table.Add(GlobalVar.MSLevelHeader, msLevel); table.Add(GlobalVar.PrecursorChargeHeader, spec.getPrecursorCharge().ToString()); table.Add(GlobalVar.PrecursorMZHeader, spec.getPrecursorMz().ToString()); table.Add(GlobalVar.ScanNumHeader, spec.getScanNum().ToString()); table.Add(GlobalVar.ScanTimeHeader, spec.getStartTime().ToString()); } else { table.Add("specificInfo1", "aa"); table.Add("specificInfo2", "pp"); } Names = table.Keys; }
public static void CometSingleSearchTest() { String idx = "C:\\Coding\\2019LavalleeLab\\GitProjectRealTimeMS\\TestData\\PreComputedFiles\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx"; //String idx = "C:\\temp\\comet_2019015\\comet_source_2019015\\IDXMake\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx"; String param = "C:\\Coding\\2019LavalleeLab\\temp2\\ExampleDataSet\\2019.comet.params"; CometSingleSearch.InitializeComet(idx, param); CometSingleSearch.QualityCheck(); Program.ExitProgram(1); String dataRoot = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Data\\"; String outputRoot = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Output\\"; //String mzmlPath = dataRoot+"60minMZMLShrink.csv"; String mzmlPath = dataRoot + "8001.ms2.txt"; String dbPath = dataRoot + "tinyDB.fasta.idx"; // String outputPath = outputRoot + "output.txt"; String paramsPath = dataRoot + "comet.params"; MZMLFile mzml = Loader.parseMS2File(mzmlPath); //MZMLFile mzml = null; CometSingleSearch.InitializeComet(dbPath, paramsPath); var watch = System.Diagnostics.Stopwatch.StartNew(); int counter = 0; Console.WriteLine("Starting comet search"); WriterClass.initiateWriter(outputPath); for (int i = 0; i < 1; i++) { if (i % 1 == 0) { Spectra spec = mzml.getSpectraArray()[i]; if (spec.getMSLevel() != 2) { continue; } Console.WriteLine("scanNum {0} RT {2} Mass {2} MSLevel {3}", spec.getScanNum(), spec.getStartTime(), spec.getCalculatedPrecursorMass(), spec.getMSLevel()); IDs id = null; if (CometSingleSearch.Search(spec, out id)) { String outLine = String.Format("{0}\t{1}\txcorr\t{2}\tdcn\t{3}", id.getScanNum(), id.getPeptideSequence(), id.getXCorr(), id.getDeltaCN()); Console.WriteLine(outLine); WriterClass.writeln(outLine); } else { Console.WriteLine("Spectrum cannot be matched\n"); } counter++; } } watch.Stop(); Console.WriteLine("Comet search of " + counter + " spectra took " + watch.ElapsedMilliseconds + " milliseconds"); WriterClass.CloseWriter(); }
protected virtual bool processMS2(Spectra spec) { performanceEvaluator.countMS2(); log.Debug(spec); // check if mass is on exclusion list double spectraMass = spec.getCalculatedPrecursorMass(); Boolean isExcluded = exclusionList.isExcluded(spectraMass); //checks if the mass should've been excluded, //in a real experiment, this should never equal to true //since the mass should not have been scanned in the first place //if MS exclusion table was updated correctly through API if (isExcluded) { #if (SIMULATION) IDs id = performDatabaseSearch(spec); log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded."); evaluateExclusion(id); WriterClass.LogScanTime("Excluded", (int)spec.getIndex()); #endif performanceEvaluator.countExcludedSpectra(); excludedSpectra.Add(spec.getScanNum()); return(false); } else { IDs id = performDatabaseSearch(spec); performanceEvaluator.countAnalyzedSpectra(); log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed."); evaluateIdentification(id); includedSpectra.Add(spec.getScanNum()); // calibrate peptide if the observed retention time doesn't match the predicted //WriterClass.LogScanTime("Processed", (int)spec.getIndex()); return(true); } }
private void setUpRandomlyExcludedMS2_NoneDDA(List <Spectra> ms2SpectraArray, int numExcluded, int numAnalyzed, int maximumNumberOfMS2Spectra) { ms2SpectraArray = CloneList(ms2SpectraArray); //just removes the reference to the original variable, so any operation to the new list doesn't mess with the original list up outside of this function randomlyExcludedScans = new List <int>(); Random r = new Random(); while (ms2SpectraArray.Count > numAnalyzed) { int pos = r.Next(ms2SpectraArray.Count); Spectra spectraToBeExcluded = ms2SpectraArray[pos]; randomlyExcludedScans.Add(spectraToBeExcluded.getScanNum()); ms2SpectraArray.RemoveAt(pos); } }
protected bool processMS2(Spectra spec) { log.Debug(spec); performanceEvaluator.countMS2(); //IDs id = performDatabaseSearch(spec); bool isExcluded = randomlyExcludedScans.Contains(spec.getScanNum()); if (isExcluded) { log.Debug("MS2 spectra was randomly excluded"); performanceEvaluator.countExcludedSpectra(); //evaluateExclusion(id); excludedSpectra.Add(spec.getScanNum()); return(false); } else { log.Debug("MS2 spectra was analyzed"); performanceEvaluator.countAnalyzedSpectra(); //evaluateIdentification(id); includedSpectra.Add(spec.getScanNum()); return(true); } }
protected IDs performDatabaseSearch(Spectra spec) { IDs id = null; if (CometSingleSearch.Search(spec, out id)) { log.Debug("MS2 scan was identified."); log.Debug(id); performanceEvaluator.countMS2Identified(); PSMTSVReaderWriter.WritePSM(id); } else { // scan cannot be matched to a peptide log.Debug("MS2 scan {0} was not identified by a comet search", spec.getScanNum()); performanceEvaluator.countMS2Unidentified(); } return(id); }
/* * Alex Stuff: Accounted for DDA * Goes through the spectra array and randomly excludes numExcluded of these * scans */ private void setUpRandomlyExcludedMS2(List <Spectra> spectraArray, int numExcluded, int numAnalyzed, int maximumNumberOfMS2Spectra) { List <List <Spectra> > groupedByMS1 = GroupedByMS1(spectraArray); Dictionary <int, List <Spectra> > ms1ScanNumberToRemainingMS2 = new Dictionary <int, List <Spectra> >(); List <Spectra> spectraEligibleForExclusion = new List <Spectra>(); foreach (List <Spectra> groupedSpectra in groupedByMS1) { int ms1ScanNum = groupedSpectra[0].getScanNum(); // remove the MS1 spectra groupedSpectra.RemoveAt(0); // keep adding MS2 until max number of MS2 added or no more MS2 int numMS2Added = 0; while (groupedSpectra.Count != 0) { Spectra s = groupedSpectra[0]; groupedSpectra.RemoveAt(0); spectraEligibleForExclusion.Add(s); if (++numMS2Added >= maximumNumberOfMS2Spectra) { break; } } ms1ScanNumberToRemainingMS2.Add(ms1ScanNum, groupedSpectra); } // Keep adding randomly selected spectra to randomly excluded list randomlyExcludedScans = new List <int>(); Random r = new Random(); while (spectraEligibleForExclusion.Count > numAnalyzed) { int pos = r.Next(spectraEligibleForExclusion.Count); Spectra randomlyExcludedSpectra = spectraEligibleForExclusion[pos]; spectraEligibleForExclusion.RemoveAt(pos); randomlyExcludedScans.Add(randomlyExcludedSpectra.getScanNum()); /* update spectraEligibleForExclusion */ int specArrIndex = spectraArray.IndexOf(randomlyExcludedSpectra); Spectra parentMS1 = null; // find the parent MS1 spectra by backtracking in spectraArray while (specArrIndex >= 0) { Spectra prevSpectra = spectraArray[specArrIndex]; if (prevSpectra.getMSLevel() == 1) { parentMS1 = prevSpectra; break; } } // add newly eligible MS2 to candidate list List <Spectra> ms2RemainingToAdd = ms1ScanNumberToRemainingMS2[parentMS1.getScanNum()]; if (ms2RemainingToAdd.Count != 0) { Spectra specToAdd = ms2RemainingToAdd[0]; spectraEligibleForExclusion.Add(specToAdd); ms2RemainingToAdd.RemoveAt(0); } } }
//Called by DataProcessor, entry point to Alex's program public bool evaluate(Spectra spec) { currentTime = spec.getStartTime(); updateExclusionList(spec); if (spec.getMSLevel() == 1) { log.Debug("Evaluating ms1 scan"); processMS1(spec); } else if (spec.getMSLevel() == 2) { log.Debug("evaluating ms2 scan"); if (spec.getIndex() % GlobalVar.ScansPerOutput == 0) { #if SIMULATION double progressPercent = spec.getIndex() / GlobalVar.ExperimentTotalScans * 100; log.Info("Progress: {0:F2}% Processing ID: {1}\t ScanNum: {2} \t Excluded: {3}", progressPercent, spec.getIndex(), spec.getScanNum(), excludedSpectra.Count); #else log.Info("Progress: {0}\t{1} excluded------------------------", spec.getIndex(), excludedSpectra.Count); log.Info("ExclusionListSize: {0}\tRTOffset: {1}", exclusionList.getExclusionList().Count, RetentionTime.getRetentionTimeOffset()); #endif } return(processMS2(spec)); } else { log.Debug("unrecognized msScan"); } return(true); }
public static void parseMZML() { String mzmlPath = "/Users/lavalleelab/Desktop/JoshLab/Temp/60minMZML.csv"; MZMLFile mzml = Loader.parseMZMLCSV(mzmlPath); for (int i = 0; i < 7000; i++) { if (i % 500 == 0) { Spectra spec = mzml.getSpectraArray()[i]; Console.WriteLine("ID {0} scanNum{1} RT{2} Mass{3} MSLevel{4}", spec.getIndex(), spec.getScanNum(), spec.getStartTime(), spec.getCalculatedPrecursorMass(), spec.getMSLevel()); } } }