public void traditionalMSFeatureDataProcessingTest1() { var sourceIsosFile = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31_mass860_noRepair_isos.csv"; var copiedIsosFileName = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31_isos.csv"; File.Copy(sourceIsosFile, copiedIsosFileName, true); var testFile = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\FF_IMS4Filters_NoFlags_20ppm_Min3Pts_4MaxLCGap_NoDaCorr_ConfDtn_2011-05-16_issue947.ini"; var iniReader = new IniReader(testFile); iniReader.UpdateSettings(); var isosReader = new IsosReader(Settings.InputFileName, Settings.OutputDirectory); var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); Assert.AreEqual(2, controller.LcImsMsFeatures.Count()); var testFeature1 = (from n in controller.LcImsMsFeatures where n.Charge == 2 select n).FirstOrDefault(); Assert.IsNotNull(testFeature1); DisplayFeatureStats(testFeature1); }
public void nonSaturatedLowIntensityProcessingTest1() { var sourceIsosFile = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31_lowIntensityCase860_repaired_isos.csv"; var copiedIsosFileName = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31_isos.csv"; File.Copy(sourceIsosFile, copiedIsosFileName, true); var testFile = @"\\protoapps\UserData\Slysz\Data\Redmine_Issues\Issue947_saturationTesting\FF_IMS4Filters_NoFlags_20ppm_Min3Pts_4MaxLCGap_NoDaCorr_ConfDtn_2011-05-16_issue947.ini"; var iniReader = new IniReader(testFile); iniReader.UpdateSettings(); var isosReader = new IsosReader(Settings.InputFileName, Settings.OutputDirectory); var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); Assert.AreEqual(2, controller.LcImsMsFeatures.Count()); var testFeature1 = controller.LcImsMsFeatures.ElementAt(1); Assert.IsNotNull(testFeature1); Assert.AreEqual(20, testFeature1.GetMemberCount()); Assert.AreEqual(0, testFeature1.GetSaturatedMemberCount()); DisplayFeatureStats(testFeature1); }
public void standardFile_conformationDetection_test1() { var testfile = @"\\protoapps\UserData\Slysz\Standard_Testing\LCMSFeatureFinder\UIMF\Parameter_Files\FF_IMS_UseHardCodedFilters_NoFlags_20ppm_Min3Pts_4MaxLCGap_NoDaCorr_ConfDtn_2011-03-21.ini"; var iniReader = new IniReader(testfile); iniReader.CreateSettings(); var isosReader = new IsosReader(Settings.InputFileName, Settings.OutputDirectory); var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); }
/// <summary> /// Runs the necessary steps for LC-IMS-MS Feature Finding. /// </summary> /// <param name="isosReader">The IsosReader object</param> private static bool RunLCIMSMSFeatureFinder(IsosReader isosReader) { try { var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); return(true); } catch (Exception ex) { Logger.LogError("Exception in RunLCIMSMSFeatureFinder", ex); return(false); } }
/// <summary> /// Runs the necessary steps for LC-IMS-MS Feature Finding. /// </summary> /// <param name="isosReader">The IsosReader object</param> private static bool RunLCIMSMSFeatureFinder(IsosReader isosReader) { try { var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); return(true); } catch (Exception e) { Logger.Log(e.Message); Logger.Log(e.StackTrace); return(false); } }
public void deconToolsfiltersAreBeingAppliedTest(string settingsFileName) { var methodName = MethodBase.GetCurrentMethod().Name; // FF_IMS4Filters_NoFlags_20ppm_Min3Pts_4MaxLCGap_NoDaCorr_ConfDtn_2011-05-16.ini references // Sarc_MS2_90_6Apr11_Cheetah_11-02-19_inverse_isos.csv and DeconToolsIsosFilters_IMS4_2011-04-28.txt in folder // \\proto-2\UnitTest_Files\DeconTools_TestFiles\LCMSFeatureFinder var iniFile = Test.GetTestFile(methodName, settingsFileName); if (!iniFile.Exists) { Assert.Ignore("Skipping test " + methodName + " since file not found: " + iniFile.FullName); } Console.WriteLine("Reading settings in " + iniFile.FullName); var iniReader = new IniReader(iniFile.FullName); iniReader.CreateSettings(); if (string.IsNullOrWhiteSpace(Settings.InputDirectory) && iniFile.Directory != null) { Settings.InputDirectory = iniFile.Directory.FullName; } var isosFilePath = Path.Combine(Settings.InputDirectory, Settings.InputFileName); var isosFile = new FileInfo(isosFilePath); if (!isosFile.Exists) { Assert.Ignore("Skipping test " + methodName + " since file not found: " + isosFile.FullName); } var isosReader = new IsosReader(isosFilePath, Settings.OutputDirectory); var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); }
public void RunFeatureFinder(string settingsFileName) { var methodName = MethodBase.GetCurrentMethod().Name; // This Ini file references file Sarc_MS2_90_6Apr11_Cheetah_11-02-19_Excerpt_isos.csv var iniFile = GetTestFile(methodName, settingsFileName); if (!iniFile.Exists) { Assert.Ignore("Skipping test " + methodName + " since file not found: " + iniFile.FullName); } Console.WriteLine("Reading settings in " + iniFile.FullName); var iniReader = new IniReader(iniFile.FullName); iniReader.UpdateSettings(); if (string.IsNullOrWhiteSpace(Settings.InputDirectory) && iniFile.Directory != null) { Settings.InputDirectory = iniFile.Directory.FullName; } if (!string.IsNullOrWhiteSpace(Settings.DeconToolsFilterFileName) && !File.Exists(Settings.DeconToolsFilterFileName) && iniFile.Directory != null) { var updatedPath = Path.Combine(iniFile.Directory.FullName, Path.GetFileName(Settings.DeconToolsFilterFileName)); Settings.DeconToolsFilterFileName = updatedPath; } var isosFilePath = Path.Combine(Settings.InputDirectory, Settings.InputFileName); var isosFile = new FileInfo(isosFilePath); if (!isosFile.Exists) { Assert.Ignore("Skipping test " + methodName + " since file not found: " + isosFile.FullName); } if (isosFile.Directory == null) { Assert.Ignore("Skipping test " + methodName + " since cannot determine the parent directory of: " + isosFile.FullName); } Console.WriteLine("Processing " + isosFile.FullName); if (string.IsNullOrWhiteSpace(Settings.OutputDirectory)) { Settings.OutputDirectory = isosFile.Directory.FullName; } Console.WriteLine("Writing results to " + Settings.OutputDirectory); var isosReader = new IsosReader(isosFile.FullName, Settings.OutputDirectory); var featuresFilePath = Path.Combine(Settings.OutputDirectory, isosFile.Name.Replace("_isos.csv", "_LCMSFeatures.txt")); var filteredIsosFilePath = Path.Combine(Settings.OutputDirectory, isosFile.Name.Replace("_isos.csv", "_Filtered_isos.csv")); var featuresFile = new FileInfo(featuresFilePath); var filteredIsos = new FileInfo(filteredIsosFilePath); if (!featuresFile.Exists) { featuresFile.Delete(); } if (!filteredIsos.Exists) { filteredIsos.Delete(); } var controller = new LCIMSMSFeatureFinderController(isosReader); controller.Execute(); featuresFile.Refresh(); filteredIsos.Refresh(); if (!featuresFile.Exists) { Assert.Fail("LCMSFeatures file not found at " + featuresFile.FullName); } if (!filteredIsos.Exists) { Assert.Fail("_Filtered_isos.csv file not found at " + filteredIsos.FullName); } var lcmsFeatureCount = 0; var filteredIsosCount = 0; var lcmsFeaturesHeaderLine = string.Empty; var filteredIsosHeaderLine = string.Empty; using (var featuresFileReader = new StreamReader(new FileStream(featuresFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { if (!featuresFileReader.EndOfStream) { lcmsFeaturesHeaderLine = featuresFileReader.ReadLine(); } while (!featuresFileReader.EndOfStream) { var dataLine = featuresFileReader.ReadLine(); if (string.IsNullOrWhiteSpace(dataLine)) { continue; } lcmsFeatureCount++; } Console.WriteLine("{0} data lines in {1}", lcmsFeatureCount, featuresFile.Name); } using (var filteredIsosReader = new StreamReader(new FileStream(filteredIsos.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { if (!filteredIsosReader.EndOfStream) { filteredIsosHeaderLine = filteredIsosReader.ReadLine(); } while (!filteredIsosReader.EndOfStream) { var dataLine = filteredIsosReader.ReadLine(); if (string.IsNullOrWhiteSpace(dataLine)) { continue; } filteredIsosCount++; } Console.WriteLine("{0} data lines in {1}", filteredIsosCount, filteredIsos.Name); } Assert.AreEqual(lcmsFeatureCount, filteredIsosCount, "Mismatch between number of LC-IMS-MS features and Filtered_Isos data points"); // Old value: 2046 // Value in March 2020: 2204 Assert.AreEqual(2204, lcmsFeatureCount, "Unexpected number of LC-IMS-features"); if (lcmsFeaturesHeaderLine == null || !lcmsFeaturesHeaderLine.StartsWith("Feature_Index")) { Assert.Fail("LCMSFeatures file header line does not start with Feature_Index"); } if (filteredIsosHeaderLine == null || !filteredIsosHeaderLine.StartsWith("msfeature_id")) { Assert.Fail("LCMSFeatures file header line does not start with msfeature_id"); } }
static int Main(string[] args) { try { if (args.Length < 1) { PrintUsage(); return(-1); } if (args[0].ToUpper().Equals("/X")) { Settings.PrintExampleSettings(); return(0); } if (args[0].ToUpper().Equals("/Y")) { Settings.PrintExampleDeconToolsFilterFile(); return(0); } // Uncomment this to prevent selecting text at the console from pausing program execution // // var handle = Process.GetCurrentProcess().MainWindowHandle; // SetConsoleMode(handle, ENABLE_EXTENDED_FLAGS); var assembly = Assembly.GetExecutingAssembly(); var assemblyVersion = assembly.GetName().Version.ToString(); var iniFilePath = ProcessFileLocation(args[0]); var iniFile = new FileInfo(iniFilePath); if (!iniFile.Exists) { Logger.Log("Error: Ini file not found at " + iniFilePath); System.Threading.Thread.Sleep(1500); return(-2); } var iniReader = new IniReader(iniFile.FullName); iniReader.UpdateSettings(); Logger.Log("LCMSFeatureFinder Version " + assemblyVersion); Logger.Log("Loading settings from INI file: " + iniFile.FullName); Logger.Log("Data Filters - "); Logger.Log(" Minimum LC scan = " + Settings.ScanLCMin); Logger.Log(" Maximum LC scan = " + Settings.ScanLCMax); Logger.Log(" Minimum IMS scan = " + Settings.ScanIMSMin); Logger.Log(" Maximum IMS scan = " + Settings.ScanIMSMax); if (Settings.FilterUsingHardCodedFilters) { Logger.Log(" Filtering using charge/abundance/fitScore/i_score table from file: " + Settings.DeconToolsFilterFileName); } else { Logger.Log(" Maximum isotopic fit score = " + Settings.FitMax); Logger.Log(" Maximum i_score (interference score) = " + Settings.InterferenceScoreMax); Logger.Log(" Minimum intensity = " + Settings.IntensityMin); } if (Settings.FilterFlaggedData) { Logger.Log(" Filtering out flagged data"); } Logger.Log(" Mono mass start = " + Settings.MassMonoisotopicStart); Logger.Log(" Mono mass end = " + Settings.MassMonoisotopicEnd); var isosFile = GetSourceFile(Settings.InputDirectory, Settings.InputFileName); if (!isosFile.Exists) { Logger.Log("Error: Isos file not found at " + isosFile.FullName); System.Threading.Thread.Sleep(1500); return(-3); } var dataType = PeekAtIsosFile(isosFile.FullName); if (dataType < 0) { Logger.Log("Unknown type of Isos file. Exiting."); System.Threading.Thread.Sleep(1500); return(-4); } var uimfFile = GetSourceFile(Settings.InputDirectory, FileUtil.GetUimfFileForIsosFile(Settings.InputFileName)); if (Settings.UseConformationDetection && !uimfFile.Exists && dataType != LC_DATA) { Logger.Log("Error: UIMF file not found at " + uimfFile.FullName); System.Threading.Thread.Sleep(1500); return(-7); } var isosReader = new IsosReader(isosFile.FullName, Settings.OutputDirectory); if (dataType == LC_DATA || Settings.IgnoreIMSDriftTime) { Logger.Log("Total number of MS Features in _isos.csv file = " + isosReader.NumOfUnfilteredMSFeatures); Logger.Log("Total number of MS Features we'll consider = " + isosReader.MSFeatureList.Count); Logger.Log("LC data processing is not currently implemented. Exiting..."); //RunLCMSFeatureFinder(isosReader); Logger.Log("Aborted!"); System.Threading.Thread.Sleep(1500); return(-5); } if (dataType != IMS_DATA) { Logger.Log("Unsupported data type. Exiting..."); Logger.Log("Aborted!"); System.Threading.Thread.Sleep(1500); return(-6); } Logger.Log("Processing LC-IMS-MS Data..."); var success = RunLCIMSMSFeatureFinder(isosReader); if (success) { Logger.Log("Finished!"); System.Threading.Thread.Sleep(750); return(0); } Logger.Log("Processing error; check the log messages"); System.Threading.Thread.Sleep(1500); return(-10); } catch (Exception ex) { Logger.LogError("Exception while processing", ex); System.Threading.Thread.Sleep(1500); return(-11); } finally { Logger.CloseLog(); } }