public void loadUIMFIsosResults_loadOneFrameOnly_Test1() { IsosResultUtilities isosUtil = new IsosResultUtilities(); isosUtil.LoadResults(uimfIsos1, DeconTools.Backend.Globals.MSFileType.PNNL_UIMF,500); Assert.AreEqual(1346, isosUtil.Results.Count); UIMFIsosResult uimfTestResult1 = (UIMFIsosResult)isosUtil.Results[3]; Assert.AreEqual(1200, uimfTestResult1.FrameSet.PrimaryFrame); Assert.AreEqual(250, uimfTestResult1.ScanSet.PrimaryScanNumber); Assert.AreEqual(3, uimfTestResult1.IsotopicProfile.ChargeState); Assert.AreEqual(1288, uimfTestResult1.IsotopicProfile.GetAbundance()); //Assert.AreEqual(432.92416, uimfTestResult1.IsotopicProfile.GetMZofMostAbundantPeak()); Assert.AreEqual(0.1458, uimfTestResult1.IsotopicProfile.Score); //Assert.AreEqual(1296.54608, uimfTestResult1.IsotopicProfile.AverageMass); Assert.AreEqual(1295.75229, uimfTestResult1.IsotopicProfile.MonoIsotopicMass); Assert.AreEqual(0.0548, Math.Round(uimfTestResult1.IsotopicProfile.GetFWHM(), 4)); Assert.AreEqual(92, uimfTestResult1.IsotopicProfile.GetSignalToNoise()); //Assert.AreEqual(1200, uimfTestResult1.FrameSet.PrimaryFrame); //250 3 1288 432.92416 0.1458 1296.54608 1295.75229 1295.75229 0.0548 92 }
public void deserializerGetResultsTest3() { ResultCollection results; IsosResultDeSerializer deserializer = new IsosResultDeSerializer(deserializerUIMFTestFile1); int counter = 0; do { counter++; results = deserializer.GetNextSetOfResults(); if (results != null) { StringBuilder sb = new StringBuilder(); foreach (IsosResult result in results.ResultList) { UIMFIsosResult uimfResult = (UIMFIsosResult)result; sb.Append(uimfResult.FrameSet.PrimaryFrame); sb.Append("\t"); sb.Append(uimfResult.ScanSet.PrimaryScanNumber); sb.Append("\t"); sb.Append(uimfResult.IsotopicProfile.GetMZ()); sb.Append("\t"); sb.Append(uimfResult.IsotopicProfile.GetAbundance()); sb.Append("\n"); } Console.WriteLine("----------------------------------------------------------------------"); Console.Write(sb.ToString()); } } while (results != null); Assert.AreEqual(8, counter); }
/// <summary> /// This test ensures that the orig_intens data is the same as the data stored in the IsosResult when there is no summing /// </summary> //[Test] //public void test1_nosumming() //{ // Project.Reset(); // Project project = Project.getInstance(); // UIMFRun run = new UIMFRun(uimfFilepath, 1200, 1200); // project.RunCollection.Add(run); // ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 250, 270, 1, 1); // sscc.Create(); // FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, run.MinFrame, run.MaxFrame, 1, 1); // fscc.Create(); // Task msGen = new UIMF_MSGenerator(200, 2000); // DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(); // detectorParams.PeakBackgroundRatio = 3; // detectorParams.PeakFitType = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC; // detectorParams.SignalToNoiseThreshold = 3; // detectorParams.ThresholdedData = false; // Task peakDetector = new DeconToolsPeakDetector(detectorParams); // Task decon = new HornDeconvolutor(); // Task scanResultsUpdater = new ScanResultUpdater(); // project.TaskCollection.TaskList.Add(msGen); // project.TaskCollection.TaskList.Add(peakDetector); // project.TaskCollection.TaskList.Add(decon); // project.TaskCollection.TaskList.Add(scanResultsUpdater); // TaskController controller = new UIMF_TaskController(project.TaskCollection); // controller.Execute(project.RunCollection); // ResultCollection results = project.RunCollection[0].ResultCollection; // OriginalIntensitiesExtractor origIntensExtractor = new OriginalIntensitiesExtractor(results); // List<OriginalIntensitiesDTO> data = origIntensExtractor.ExtractOriginalIntensities(); // Assert.AreEqual(20, results.ResultList.Count); // Assert.AreEqual(20, data.Count); // //for (int i = 0; i < data.Count; i++) // //{ // // Assert.AreEqual(results.ResultList[i].IsotopicProfile.GetAbundance(), data[i].originalIntensity); // // Assert.AreEqual(results.ResultList[i].IsotopicProfile.GetSummedIntensity(), data[i].totIsotopicOrginalIntens); // //} // StringBuilder sb = new StringBuilder(); // reportOriginalIntensityData(sb, results.ResultList, data); // Console.Write(sb.ToString()); //} private void reportOriginalIntensityData(StringBuilder sb, List <IsosResult> results, List <OriginalIntensitiesDTO> origIntensdata) { int counter = 0; sb.Append("scan\tmz\tabundance\tTIA\torig_intens\torigIntenseTIA\n"); foreach (OriginalIntensitiesDTO item in origIntensdata) { UIMFIsosResult result = (UIMFIsosResult)results[counter]; sb.Append(result.ScanSet.PrimaryScanNumber); sb.Append("\t"); sb.Append(result.IsotopicProfile.GetMZ()); sb.Append("\t"); sb.Append(result.IsotopicProfile.GetAbundance()); sb.Append("\t"); sb.Append(result.IsotopicProfile.GetSummedIntensity()); sb.Append("\t"); sb.Append(item.originalIntensity); sb.Append("\t"); sb.Append(item.totIsotopicOrginalIntens); sb.Append("\n"); counter++; } }
public void uimf_data_preLoaded() // in this case, data is preloaded, preventing re-accessing the same drifttimes over and over { Run run = new UIMFRun(uimfFilepath); FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, 800, 801, 3, 1); fscc.Create(); ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 220, 270, 9, 1); sscc.Create(); ((UIMFRun)run).GetFrameDataAllFrameSets(); // this is the key line... loads data necessary for drift time calc and correction UIMF_MSGenerator msgen = new UIMF_MSGenerator(); DeconToolsPeakDetector peakDet = new DeconToolsPeakDetector(); peakDet.PeakBackgroundRatio = 6; peakDet.SigNoiseThreshold = 3; HornDeconvolutor decon = new HornDeconvolutor(); UIMFDriftTimeExtractor driftTimeExtractor = new UIMFDriftTimeExtractor(); StringBuilder sb = new StringBuilder(); foreach (var frame in ((UIMFRun)run).FrameSetCollection.FrameSetList) { ((UIMFRun)run).CurrentFrameSet = frame; foreach (var scan in run.ScanSetCollection.ScanSetList) { run.CurrentScanSet = scan; msgen.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); decon.Execute(run.ResultCollection); driftTimeExtractor.Execute(run.ResultCollection); } } foreach (var item in run.ResultCollection.ResultList) { UIMFIsosResult isosresult = (UIMFIsosResult)item; sb.Append(isosresult.FrameSet.PrimaryFrame); sb.Append("\t"); sb.Append(isosresult.ScanSet.PrimaryScanNumber); sb.Append("\t"); sb.Append(isosresult.IsotopicProfile.MonoPeakMZ.ToString("0.000")); sb.Append("\t"); sb.Append(isosresult.DriftTime.ToString("0.000")); sb.Append(Environment.NewLine); } Console.Write(sb.ToString()); }
public void uimf_data_not_preLoaded() // in this case the drift time is calculated every time by looking up sqlite data from uimf file { Run run = new UIMFRun(uimfFilepath); FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, 800, 801, 3, 1); fscc.Create(); ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 220, 270, 9, 1); sscc.Create(); UIMF_MSGenerator msgen = new UIMF_MSGenerator(); DeconToolsPeakDetector peakDet = new DeconToolsPeakDetector(); peakDet.PeakBackgroundRatio = 6; peakDet.SigNoiseThreshold = 3; HornDeconvolutor decon = new HornDeconvolutor(); UIMFDriftTimeExtractor driftTimeExtractor = new UIMFDriftTimeExtractor(); StringBuilder sb = new StringBuilder(); foreach (var frame in ((UIMFRun)run).FrameSetCollection.FrameSetList) { ((UIMFRun)run).CurrentFrameSet = frame; foreach (var scan in run.ScanSetCollection.ScanSetList) { run.CurrentScanSet = scan; msgen.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); decon.Execute(run.ResultCollection); driftTimeExtractor.Execute(run.ResultCollection); } } foreach (var item in run.ResultCollection.ResultList) { UIMFIsosResult isosresult = (UIMFIsosResult)item; sb.Append(isosresult.FrameSet.PrimaryFrame); sb.Append("\t"); sb.Append(isosresult.ScanSet.PrimaryScanNumber); sb.Append("\t"); sb.Append(isosresult.IsotopicProfile.MonoPeakMZ.ToString("0.000")); sb.Append("\t"); sb.Append(isosresult.DriftTime.ToString("0.000")); sb.Append(Environment.NewLine); } Console.Write(sb.ToString()); }
public List <IsosResult> convertIMFResultsToUIMFResults(int currentFrame, List <IsosResult> list) { var returnedResults = new List <IsosResult>(); foreach (var result in list) { var uimfResult = new UIMFIsosResult(); uimfResult.ScanSet = new LCScanSetIMS(currentFrame); uimfResult.IsotopicProfile = result.IsotopicProfile; uimfResult.Run = result.Run; uimfResult.ScanSet = result.ScanSet; returnedResults.Add(uimfResult); } return(returnedResults); }
private IsosResult convertTextToIsosResult(List <string> processedData, List <string> headers) { IsosResult result; if (fileType == Globals.MSFileType.PNNL_UIMF) { result = new UIMFIsosResult(); } else { result = new StandardIsosResult(); } result.IsotopicProfile = new IsotopicProfile(); //result.Run = getRunFromIsosFilename(this.importFilename, this.fileType); AM commenting this out since this gives me an error //get ScanSet number from file if (fileType == Globals.MSFileType.PNNL_UIMF) { var imsScanNum = parseIntField(lookup(processedData, headers, "ims_scan_num")); var frame_num = parseIntField(lookup(processedData, headers, "frame_num")); ((UIMFIsosResult)result).DriftTime = parseDoubleField(lookup(processedData, headers, "drift_time")); result.ScanSet = new LCScanSetIMS(frame_num); ((UIMFIsosResult)result).IMSScanSet = new IMSScanSet(imsScanNum); } else { var scan_num = parseIntField(lookup(processedData, headers, "scan_num")); result.ScanSet = new ScanSet(scan_num); } result.IsotopicProfile.ChargeState = parseIntField(lookup(processedData, headers, "charge")); result.IsotopicProfile.MonoIsotopicMass = parseDoubleField(lookup(processedData, headers, "monoisotopic_mw")); result.IsotopicProfile.Score = parseDoubleField(lookup(processedData, headers, "fit")); result.IntensityAggregate = parseFloatField(lookup(processedData, headers, "abundance")); //result.IsotopicProfile.IntensityMostAbundant = parseFloatField(lookup(processedData, headers, "abundance")); result.IsotopicProfile.MonoPeakMZ = parseDoubleField(lookup(processedData, headers, "mz")); result.InterferenceScore = parseDoubleField(lookup(processedData, headers, "interference_score")); result.IsotopicProfile.OriginalIntensity = parseDoubleField(lookup(processedData, headers, "unsummed_intensity")); var saturationFlagString = lookup(processedData, headers, "saturation_flag"); result.IsotopicProfile.IsSaturated = saturationFlagString == "1"; var mz = parseFloatField(lookup(processedData, headers, "mz")); var intensity = parseIntField(lookup(processedData, headers, "mono_abundance")); var peak = new MSPeak(mz, intensity) { Width = parseFloatField(lookup(processedData, headers, "fwhm")), SignalToNoise = parseFloatField(lookup(processedData, headers, "signal_noise")) }; //mono mz isn't available from _isos file AM modification, while this is true, we still need this. var flagString = lookup(processedData, headers, "flag"); if (string.IsNullOrEmpty(flagString)) { } else { var flagNum = parseIntField(flagString); if (flagNum == 1) { result.Flags.Add(new PeakToTheLeftResultFlag()); // TODO: it'll be good to make a factory class for creating flags. } } result.IsotopicProfile.Peaklist.Add(peak); return(result); }
public void test1() { Project.Reset(); Project project = Project.getInstance(); UIMFRun run = new UIMFRun(uimfFilepath, 1200, 1202); project.RunCollection.Add(run); ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 1, 1); sscc.Create(); FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, run.MinFrame, run.MaxFrame, 1, 1); fscc.Create(); Task msGen = new UIMF_MSGenerator(200, 2000); DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(); detectorParams.PeakBackgroundRatio = 3; detectorParams.PeakFitType = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC; detectorParams.SignalToNoiseThreshold = 3; detectorParams.ThresholdedData = false; Task peakDetector = new DeconToolsPeakDetector(detectorParams); Task rapidDecon = new RapidDeconvolutor(); Task scanResultsUpdater = new ScanResultUpdater(); project.TaskCollection.TaskList.Add(msGen); project.TaskCollection.TaskList.Add(peakDetector); project.TaskCollection.TaskList.Add(rapidDecon); project.TaskCollection.TaskList.Add(scanResultsUpdater); Stopwatch sw = new Stopwatch(); sw.Start(); TaskController controller = new UIMF_TaskController(project.TaskCollection); controller.Execute(project.RunCollection); sw.Stop(); Console.WriteLine("Time required (ms) = " + sw.ElapsedMilliseconds); Console.WriteLine("Scans analyzed = " + project.RunCollection[0].ScanSetCollection.ScanSetList.Count); Console.WriteLine("Features found = " + project.RunCollection[0].ResultCollection.ResultList.Count); Assert.AreEqual(1, Project.getInstance().RunCollection.Count); Assert.AreEqual(4, project.TaskCollection.TaskList.Count); Assert.AreEqual(600, project.RunCollection[0].ScanSetCollection.ScanSetList.Count); UIMFRun uimfRun = (UIMFRun)(project.RunCollection[0]); Assert.AreEqual(3, uimfRun.FrameSetCollection.FrameSetList.Count); StringBuilder sb = new StringBuilder(); foreach (IsosResult result in project.RunCollection[0].ResultCollection.ResultList) { Assert.IsInstanceOfType(typeof(UIMFIsosResult), result); UIMFIsosResult uimfResult = (UIMFIsosResult)result; sb.Append(uimfResult.FrameSet.PrimaryFrame); sb.Append("\t"); sb.Append(uimfResult.ScanSet.PrimaryScanNumber); sb.Append("\t"); sb.Append(uimfResult.IsotopicProfile.Peaklist[0].XValue); sb.Append("\t"); sb.Append(uimfResult.IsotopicProfile.GetAbundance()); sb.Append("\t"); //sb.Append(uimfResult.IsotopicProfile. sb.Append(Environment.NewLine); } Console.Write(sb.ToString()); }