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(); }
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()); } } }
public static MZMLFile parseMSFile(String fileName, int _mslevel) { List <Spectra> spectraArray = new List <Spectra>(); log.Info("Parsing the ms2 file: " + fileName); log.Debug("File path: " + fileName); StreamReader reader = new StreamReader(fileName); String line = reader.ReadLine(); while (line != null) { if (!line.Substring(0, 1).Equals("H")) { break; } line = reader.ReadLine(); } int index = 1; while (!String.IsNullOrEmpty(line)) { int scanNum = 0; int msLevel = _mslevel; int peakCount = 0; double startTime = 0; double precursorMz = 0; int precursorCharge = 0; //parse header while (line != null) { String[] str = line.Split("\t".ToCharArray()); if (str[0].Equals("S")) { scanNum = int.Parse(str[1]); precursorMz = double.Parse(str[3]); } else if (str[0].Equals("I")) { if (str[1].Equals("RTime")) { startTime = double.Parse(str[2]); } } else if (str[0].Equals("Z")) { precursorCharge = int.Parse(str[1]); break; } line = reader.ReadLine(); } line = reader.ReadLine(); List <String[]> peaks = new List <String[]>(); while (!line.Substring(0, 1).Equals("S")) { peaks.Add(line.Split(" ".ToCharArray())); line = reader.ReadLine(); if (String.IsNullOrEmpty(line)) { break; } } peakCount = peaks.Count; double[] peakMz = new double[peakCount]; double[] peakIntensity = new double[peakCount]; for (int i = 0; i < peakCount; i++) { peakMz[i] = double.Parse(peaks[i][0]); peakIntensity[i] = double.Parse(peaks[i][1]); } Spectra spec = new Spectra(index, scanNum, msLevel, peakCount, peakMz, peakIntensity, startTime, precursorMz, precursorCharge); spectraArray.Add(spec); index++; } MZMLFile mzml = new MZMLFile(fileName, spectraArray); return(mzml); }