public void LinearRegression(string jobDirectory, string jobList, int numJobs) { var jobDirectoryPath = GetPath(jobDirectory); var jobListPath = GetPath(jobList); var num = 0; var options = new Options(); PeptideCache.Clear(); var dataSets = new List <LcmsDataSet>(); using (var sr = new StreamReader(jobListPath)) { var pathName = sr.ReadLine(); while (pathName != null && num < numJobs) { pathName = Path.Combine(jobDirectoryPath, pathName); var reader = PhrpReaderFactory.Create(pathName, options); dataSets.Add(reader.Read(pathName)); pathName = sr.ReadLine(); num++; } } var processor = new MtdbProcessor(options); processor.Process(dataSets, new BackgroundWorker()); foreach (var set in dataSets) { Assert.AreNotEqual(set.RegressionResult.RSquared, 0); // Set to 1.000001 due to (for some reason) RSquared occasionally // being calculated as 1.00000000000044 Assert.Less(set.RegressionResult.RSquared, 1.000001); } }
public void TestLoadingSingleFile(string jobPath, int expectedEvidences) { PeptideCache.Clear(); var options = new Options(); var jobDirectoryPath = GetPath(jobPath); var pathName = jobDirectoryPath; var reader = PhrpReaderFactory.Create(pathName, options); var data = reader.Read(pathName); Assert.AreEqual(expectedEvidences, data.Evidences.Count); }
public void TrypticEnds(string jobDirectory, string jobList, int numJobs) { var jobDirectoryPath = GetPath(jobDirectory); var jobListPath = GetPath(jobList); var num = 0; var options = new Options(); PeptideCache.Clear(); using (var sr = new StreamReader(jobListPath)) { var pathName = sr.ReadLine(); while (pathName != null && num < numJobs) { pathName = Path.Combine(jobDirectoryPath, pathName); var reader = PhrpReaderFactory.Create(pathName, options); var data = reader.Read(pathName); var resultType = clsPHRPReader.AutoDetermineResultType(pathName); switch (resultType) { case clsPHRPReader.ePeptideHitResultType.XTandem: foreach (XTandemResult evidence in data.Evidences) { Debug.Assert(evidence.NumTrypticEnds >= 0); Debug.Assert(evidence.NumTrypticEnds < 3); } break; case clsPHRPReader.ePeptideHitResultType.Sequest: foreach (SequestResult evidence in data.Evidences) { Debug.Assert(evidence.NumTrypticEnds >= 0); Debug.Assert(evidence.NumTrypticEnds < 3); } break; case clsPHRPReader.ePeptideHitResultType.MSGFDB: foreach (MsgfPlusResult evidence in data.Evidences) { Debug.Assert(evidence.NumTrypticEnds >= 0); Debug.Assert(evidence.NumTrypticEnds < 3); } break; } pathName = sr.ReadLine(); num++; } } }
public void TestLoadingGZippedFile(string txtPath, string gZipPath) { PeptideCache.Clear(); var options = new Options(); var gZipDirectoryPath = GetPath(gZipPath); var txtDirectoryPath = GetPath(txtPath); var gPathName = gZipDirectoryPath; var gReader = PhrpReaderFactory.Create(gPathName, options); var timeStart = DateTime.Now; var gData = gReader.Read(gPathName); var timeEnd = DateTime.Now; Console.WriteLine(string.Format("Reading .gz took {0} seconds", timeEnd - timeStart)); var tPathName = txtDirectoryPath; var tReader = PhrpReaderFactory.Create(tPathName, options); timeStart = DateTime.Now; var tData = tReader.Read(tPathName); timeEnd = DateTime.Now; Console.WriteLine(string.Format("Reading .mzid took {0} seconds", timeEnd - timeStart)); // To ensure that reading the same data gets the same number of evidences Assert.AreEqual(gData.Evidences.Count, tData.Evidences.Count); for (var i = 0; i < gData.Evidences.Count; i++) { var gEv = gData.Evidences[i]; var tEv = tData.Evidences[i]; //Test for each portion of the evidence being identical Assert.AreEqual(gEv.MonoisotopicMass, tEv.MonoisotopicMass); Assert.AreEqual(gEv.Charge, tEv.Charge); Assert.AreEqual(gEv.DelM, tEv.DelM); Assert.AreEqual(gEv.DelMPpm, tEv.DelMPpm); Assert.AreEqual(gEv.ModificationCount, tEv.ModificationCount); Assert.AreEqual(gEv.ModificationDescription, tEv.ModificationDescription); Assert.AreEqual(gEv.Mz, tEv.Mz); Assert.AreEqual(gEv.ObservedMonoisotopicMass, tEv.ObservedMonoisotopicMass); Assert.AreEqual(gEv.ObservedNet, tEv.ObservedNet); Assert.AreEqual(gEv.Scan, tEv.Scan); Assert.AreEqual(gEv.Sequence, tEv.Sequence); Assert.AreEqual(gEv.SpecProb, tEv.SpecProb); } }
public void TestLoadingFiles(string jobDirectory, string jobList, int numJobs, params int[] expectedEvidences) { PeptideCache.Clear(); var options = new Options(); var jobDirectoryPath = GetPath(jobDirectory); var jobListPath = GetPath(jobList); var num = 0; using (var sr = new StreamReader(jobListPath)) { var pathName = sr.ReadLine(); while (pathName != null && num < numJobs) { pathName = Path.Combine(jobDirectoryPath, pathName); var reader = PhrpReaderFactory.Create(pathName, options); var data = reader.Read(pathName); Assert.AreEqual(expectedEvidences[num], data.Evidences.Count); pathName = sr.ReadLine(); num++; } } }