public void TestSkylineRunnerArgs() { const string skyFile = @"C:\Dummy\path\Test_file.sky"; const string dataFile1 = @"C:\Dummy\path\Test1.raw"; var logger = new TestLogger(); var mainSettings = new MainSettings() { SkylineFilePath = skyFile, ResultsWindowString = MainSettings.ACCUM_TIME_WINDOW.ToString() }; var mainSettingsTab = new MainSettingsTab(null, logger) { Settings = mainSettings }; var accumulationWindow = MainSettingsTab.AccumulationWindow.Get(DateTime.Now, MainSettings.ACCUM_TIME_WINDOW); Assert.AreEqual(accumulationWindow.EndDate.Subtract(accumulationWindow.StartDate).Days + 1, MainSettings.ACCUM_TIME_WINDOW); var expected = string.Format("--in=\"{0}\" --remove-before={1} --import-file=\"{3}\" --import-on-or-after={2} --save", skyFile, accumulationWindow.StartDate.ToShortDateString(), accumulationWindow.StartDate.ToShortDateString(), dataFile1); var importContext = new ImportContext(dataFile1); Assert.IsFalse(importContext.ImportExisting); var args = mainSettingsTab.SkylineRunnerArgs(importContext); Assert.AreEqual(expected, args.Trim()); }
public void TestBackgroundWorker_ProcessNewFiles() { // Create a test directory to monitor var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Assert.IsNotNull(dir); var testDir = Path.Combine(dir, "TestBackgroundWorker"); if (Directory.Exists(testDir)) { Directory.Delete(testDir, true); } Assert.IsFalse(Directory.Exists(testDir)); Directory.CreateDirectory(testDir); Assert.IsTrue(Directory.Exists(testDir)); var appControl = new TestAppControl(); var logger = new TestLogger(); var processControl = new TestProcessControl(logger); var mainSettings = new MainSettings { FolderToWatch = testDir, InstrumentType = "NoInstrument", ResultsWindowString = "31", AcquisitionTimeString = "0" }; // Start the background worker. var backgroundWorker = new AutoQCBackgroundWorker(appControl, processControl, logger); backgroundWorker.Start(mainSettings); Assert.IsTrue(backgroundWorker.IsRunning()); // Create a new file in the test directory. Thread.Sleep(1000); CreateNewFile(testDir, "test1.txt"); // Wait till the the file has been processed. while (!processControl.IsDone()) { Thread.Sleep(500); } Assert.IsTrue(backgroundWorker.IsRunning()); // Create another file in the test directory. Thread.Sleep(1000); CreateNewFile(testDir, "test2.txt"); // Wait till the the file has been processed. // Process4 returns exit code 1 both times. This should stop the program. while (!processControl.IsDone()) { Thread.Sleep(500); } // Assert.IsTrue(appControl.Waiting); Thread.Sleep(2 * AutoQCBackgroundWorker.WAIT_5SEC); Assert.IsTrue(appControl.Stopped); Assert.AreEqual(Regex.Replace(logger.GetLog(), @"\s+", ""), Regex.Replace(GetExpectedLog_ProcessNew(), @"\s+", "")); }
private static IResultFileStatus GetFileStatusChecker(MainSettings mainSettings) { if (mainSettings.InstrumentType.Equals(MainSettings.THERMO)) { return(new XRawFileStatus(mainSettings.AcquisitionTime)); } return(new AcquisitionTimeFileStatus(mainSettings.AcquisitionTime)); }
public void TestGetLastArchivalDate() { var mainSettings = new MainSettings() { SkylineFilePath = @"C:\Dummy\path\Test_file.sky" }; var mainSettingsTab = new MainSettingsTab(null, null) {Settings = mainSettings}; var fsUtil = new TestFileSystemUtil(); Assert.AreEqual(new DateTime(2015, 06, 01), mainSettingsTab.GetLastArchivalDate(fsUtil)); }
public void Validate() { if (string.IsNullOrEmpty(Name)) { throw new ArgumentException("Please enter a name for the configuration."); } MainSettings.ValidateSettings(); PanoramaSettings.ValidateSettings(); }
public static AutoQcConfig GetDefault() { var config = new AutoQcConfig { MainSettings = MainSettings.GetDefault(), PanoramaSettings = PanoramaSettings.GetDefault() }; return(config); }
public AutoQcConfig Copy() { return(new AutoQcConfig { Name = Name, IsEnabled = false, // Disable by default User = PanoramaSettings.PanoramaUserEmail, MainSettings = MainSettings.Copy(), PanoramaSettings = PanoramaSettings.Copy() }); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsEnabled.GetHashCode(); hashCode = (hashCode * 397) ^ (MainSettings != null ? MainSettings.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PanoramaSettings != null ? PanoramaSettings.GetHashCode() : 0); return(hashCode); } }
protected bool Equals(MainSettings other) { return(string.Equals(SkylineFilePath, other.SkylineFilePath) && string.Equals(FolderToWatch, other.FolderToWatch) && IncludeSubfolders == other.IncludeSubfolders && Equals(QcFileFilter, other.QcFileFilter) && ResultsWindow == other.ResultsWindow && string.Equals(InstrumentType, other.InstrumentType) && AcquisitionTime == other.AcquisitionTime && LastAcquiredFileDate.Equals(other.LastAcquiredFileDate)); }
public void WriteXml(XmlWriter writer) { writer.WriteStartElement("autoqc_config"); writer.WriteAttribute(ATTR.name, Name); writer.WriteAttributeIfString(ATTR.user, User); writer.WriteAttributeIfString(ATTR.created, Created.ToShortDateString() + " " + Created.ToShortTimeString()); writer.WriteAttributeIfString(ATTR.modified, Modified.ToShortDateString() + " " + Modified.ToShortTimeString()); MainSettings.WriteXml(writer); PanoramaSettings.WriteXml(writer); writer.WriteEndElement(); }
public void SetUIMainSettings(MainSettings mainSettings) { RunUI(() => { textSkylinePath.Text = mainSettings.SkylineFilePath; textFolderToWatchPath.Text = mainSettings.FolderToWatch; textResultsTimeWindow.Text = mainSettings.ResultsWindowString; textAquisitionTime.Text = mainSettings.AcquisitionTimeString; comboBoxInstrumentType.SelectedItem = mainSettings.InstrumentType; comboBoxInstrumentType.SelectedIndex = comboBoxInstrumentType.FindStringExact(mainSettings.InstrumentType); }); }
public static MainSettings GetDefault() { var settings = new MainSettings { InstrumentType = THERMO, ResultsWindow = ACCUM_TIME_WINDOW, AcquisitionTime = ACQUISITION_TIME, QcFileFilter = FileFilter.GetFileFilter(AllFileFilter.NAME, string.Empty) }; return(settings); }
private MainSettings GetMainSettingsFromUI() { var mainSettings = new MainSettings() { SkylineFilePath = textSkylinePath.Text, FolderToWatch = textFolderToWatchPath.Text, ResultsWindowString = textResultsTimeWindow.Text, InstrumentType = comboBoxInstrumentType.SelectedItem.ToString(), AcquisitionTimeString = textAquisitionTime.Text }; return(mainSettings); }
private MainSettings GetMainSettingsFromUI() { var mainSettings = new MainSettings(); mainSettings.SkylineFilePath = textSkylinePath.Text; mainSettings.FolderToWatch = textFolderToWatchPath.Text; mainSettings.IncludeSubfolders = includeSubfoldersCb.Checked; mainSettings.QcFileFilter = FileFilter.GetFileFilter(comboBoxFileFilter.SelectedItem.ToString(), textQCFilePattern.Text); mainSettings.ResultsWindow = ValidateIntTextField(textResultsTimeWindow.Text, "Results Window"); mainSettings.InstrumentType = comboBoxInstrumentType.SelectedItem.ToString(); mainSettings.AcquisitionTime = ValidateIntTextField(textAquisitionTime.Text, "Acquisition Time"); return(mainSettings); }
public bool IsIntegrateAllChecked(IAutoQcLogger logger, MainSettings mainSettings) { try { using (var stream = new FileStream(mainSettings.SkylineFilePath, FileMode.Open)) { using (XmlReader reader = XmlReader.Create(stream)) { reader.MoveToContent(); var done = false; while (reader.Read() && !done) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "transition_integration") { if (reader.MoveToAttribute("integrate_all")) { bool integrateAll; Boolean.TryParse(reader.Value, out integrateAll); return(integrateAll); } done = true; } break; case XmlNodeType.EndElement: if (reader.Name.Equals("transition_settings")) // We have come too far { done = true; } break; } } } } } catch (Exception e) { logger.LogException(e, "Error reading file {0}.", mainSettings.SkylineFilePath); return(false); } logger.LogError("\"Integrate all\" is not checked for the Skyline document. This setting is under the \"Settings\" menu in Skyline, and should be checked for " + " documents with QC results."); return(false); }
private void SetUIMainSettings(MainSettings mainSettings) { RunUI(() => { textSkylinePath.Text = mainSettings.SkylineFilePath; textFolderToWatchPath.Text = mainSettings.FolderToWatch; includeSubfoldersCb.Checked = mainSettings.IncludeSubfolders; textQCFilePattern.Text = mainSettings.QcFileFilter.Pattern; comboBoxFileFilter.SelectedItem = mainSettings.QcFileFilter.Name(); textResultsTimeWindow.Text = mainSettings.ResultsWindow.ToString(); textAquisitionTime.Text = mainSettings.AcquisitionTime.ToString(); comboBoxInstrumentType.SelectedItem = mainSettings.InstrumentType; comboBoxInstrumentType.SelectedIndex = comboBoxInstrumentType.FindStringExact(mainSettings.InstrumentType); }); }
public void Init(MainSettings mainSettings) { _dataFiles = new ConcurrentQueue <string>(); _retryFiles = new Queue <RawFile>(); _fileStatusChecker = GetFileStatusChecker(mainSettings); _fileWatcher.EnableRaisingEvents = false; _fileWatcher.Filter = GetFileFilter(mainSettings.InstrumentType, out _dataInDirectories); _fileWatcher.Path = mainSettings.FolderToWatch; _acquisitionTimeSetting = mainSettings.AcquisitionTime; }
public static MainSettings InitializeFromDefaults() { var settings = new MainSettings { SkylineFilePath = Settings.Default.SkylineFilePath, FolderToWatch = Settings.Default.FolderToWatch, }; var accumWin = Settings.Default.ResultsWindow; settings.ResultsWindowString = accumWin == 0 ? ACCUM_TIME_WINDOW.ToString() : accumWin.ToString(); var instrumentType = Settings.Default.InstrumentType; settings.InstrumentType = string.IsNullOrEmpty(instrumentType) ? THERMO : instrumentType; var acquisitionTime = Settings.Default.AcquisitionTime; settings.AcquisitionTimeString = acquisitionTime == 0 ? ACQUISITION_TIME.ToString() : acquisitionTime.ToString(); return(settings); }
public void ReadXml(XmlReader reader) { Name = reader.GetAttribute(ATTR.name); // TODO: Configurations shouldn't start automatically when the program starts up. // Remove this attribute from the config XML? IsEnabled = false; // reader.GetBoolAttribute(ATTR.is_enabled); User = reader.GetAttribute(ATTR.user); DateTime dateTime; DateTime.TryParse(reader.GetAttribute(ATTR.created), out dateTime); Created = dateTime; DateTime.TryParse(reader.GetAttribute(ATTR.modified), out dateTime); Modified = dateTime; do { reader.Read(); } while (reader.NodeType != XmlNodeType.Element); var mainSettings = new MainSettings(); mainSettings.ReadXml(reader); MainSettings = mainSettings; do { reader.Read(); } while (reader.NodeType != XmlNodeType.Element); var panoramaSettings = new PanoramaSettings(); panoramaSettings.ReadXml(reader); PanoramaSettings = panoramaSettings; do { reader.Read(); } while (reader.NodeType != XmlNodeType.EndElement); }
public void TestAddArchiveArgs() { var mainSettings = new MainSettings() { SkylineFilePath = @"C:\Dummy\path\Test_file.sky" }; var mainSettingsTab = new MainSettingsTab(null, new TestLogger()) {Settings = mainSettings}; var date = new DateTime(2015, 6, 17); mainSettingsTab.LastArchivalDate = date; var args = mainSettingsTab.GetArchiveArgs(mainSettingsTab.LastArchivalDate, date); Assert.IsNull(args); Assert.AreEqual(date, mainSettingsTab.LastArchivalDate); date = date.AddMonths(1); // 07/17/2015 var archiveArg = string.Format("--share-zip={0}", "Test_file_2015_06.sky.zip"); args = mainSettingsTab.GetArchiveArgs(mainSettingsTab.LastArchivalDate, date); Assert.AreEqual(archiveArg, args); Assert.AreEqual(date, mainSettingsTab.LastArchivalDate); date = date.AddYears(1); // 06/17/2016 archiveArg = string.Format("--share-zip={0}", "Test_file_2015_07.sky.zip"); args = mainSettingsTab.GetArchiveArgs(mainSettingsTab.LastArchivalDate, date); Assert.AreEqual(archiveArg, args); Assert.AreEqual(date, mainSettingsTab.LastArchivalDate); }
public void ReadXml(XmlReader reader) { Name = reader.GetAttribute(ATTR.name); IsEnabled = reader.GetBoolAttribute(ATTR.is_enabled); User = reader.GetAttribute(ATTR.user); DateTime dateTime; DateTime.TryParse(reader.GetAttribute(ATTR.created), out dateTime); Created = dateTime; DateTime.TryParse(reader.GetAttribute(ATTR.modified), out dateTime); Modified = dateTime; do { reader.Read(); } while (reader.NodeType != XmlNodeType.Element); var mainSettings = new MainSettings(); mainSettings.ReadXml(reader); MainSettings = mainSettings; do { reader.Read(); } while (reader.NodeType != XmlNodeType.Element); var panoramaSettings = new PanoramaSettings(); panoramaSettings.ReadXml(reader); PanoramaSettings = panoramaSettings; do { reader.Read(); } while (reader.NodeType != XmlNodeType.EndElement); }
public void Init(MainSettings mainSettings) { _dataFiles = new ConcurrentQueue<string>(); _retryFiles = new Queue<RawFile>(); _fileStatusChecker = GetFileStatusChecker(mainSettings); _fileWatcher.EnableRaisingEvents = false; _fileWatcher.Filter = GetFileFilter(mainSettings.InstrumentType); _fileWatcher.Path = mainSettings.FolderToWatch; _acquisitionTimeSetting = mainSettings.AcquisitionTime; }
private static IResultFileStatus GetFileStatusChecker(MainSettings mainSettings) { if (mainSettings.InstrumentType.Equals(MainSettings.THERMO)) { return new XRawFileStatus(mainSettings.AcquisitionTime); } return new AcquisitionTimeFileStatus(mainSettings.AcquisitionTime); }
public override bool ValidateSettings() { LogOutput("Validating settings..."); var mainSettingsUI = _appControl.GetUIMainSettings(); var error = false; // Path to the Skyline file. var path = mainSettingsUI.SkylineFilePath; if (string.IsNullOrWhiteSpace(path)) { LogErrorOutput("Please specify path to a Skyline file."); error = true; } else if (!File.Exists(path)) { LogErrorOutput("Skyline file {0} does not exist.", path); error = true; } // Path to the folder to monitor for mass spec. results files path = mainSettingsUI.FolderToWatch; if (string.IsNullOrWhiteSpace(path)) { LogErrorOutput("Please specify path to a folder where mass spec. files will be written."); error = true; } else if (!Directory.Exists(path)) { LogErrorOutput("Folder {0} does not exist.", path); error = true; } // Results time window. var accumWin = mainSettingsUI.ResultsWindowString; if (string.IsNullOrWhiteSpace(accumWin)) { LogErrorOutput("Please specify a value for the \"Accumulation time window\"."); error = true; } else { int accumWindow; if (!Int32.TryParse(mainSettingsUI.ResultsWindowString, out accumWindow)) { LogErrorOutput("Invalid value for \"Accumulation time window\": {0}.", mainSettingsUI.ResultsWindowString); error = true; } else if (accumWindow < MainSettings.ACCUM_TIME_WINDOW) { LogErrorOutput("\"Accumulation time window\" cannot be less than {0} days.", MainSettings.ACCUM_TIME_WINDOW); error = true; } } // Expected acquisition time var aquisitionTime = mainSettingsUI.AcquisitionTimeString; if (string.IsNullOrWhiteSpace(aquisitionTime)) { LogErrorOutput("Please specify a value for the \"Expected acquisition time\"."); error = true; } else { int aAcquisitionTime; if (!Int32.TryParse(mainSettingsUI.AcquisitionTimeString, out aAcquisitionTime)) { LogErrorOutput("Invalid value for \"Expected acquisition time\": {0}.", mainSettingsUI.AcquisitionTimeString); error = true; } } if (!error) Settings = mainSettingsUI; return !error; }
public void TestValidateSettings() { var logger = new TestLogger(); var mainControl = new TestAppControl(); var mainSettingsTab = new MainSettingsTab(mainControl, logger); Assert.IsFalse(mainSettingsTab.ValidateSettings()); var log = logger.GetLog(); Assert.IsTrue(log.Contains("Please specify path to a Skyline file.")); Assert.IsTrue(log.Contains("Please specify path to a folder where mass spec. files will be written.")); Assert.IsTrue(log.Contains("Please specify a value for the \"Accumulation time window\".")); const string skyPath = "C:\\dummy\\path\\Test.sky"; const string folderPath = "C:\\dummy\\path"; var accumWindow = "not a number"; var settings = new MainSettings() { SkylineFilePath = skyPath, FolderToWatch = folderPath, ResultsWindowString = "not a number", // ImportExistingFiles = false }; mainControl = new TestAppControl(); mainControl.SetUIMainSettings(settings); mainSettingsTab = new MainSettingsTab(mainControl, logger); logger.Clear(); Assert.IsFalse(mainSettingsTab.ValidateSettings()); log = logger.GetLog(); Assert.IsTrue(log.Contains(string.Format("Skyline file {0} does not exist.", skyPath))); Assert.IsTrue(log.Contains(string.Format("Folder {0} does not exist.", folderPath))); Assert.IsTrue(log.Contains(string.Format("Invalid value for \"Accumulation time window\": {0}.", accumWindow))); accumWindow = "-1"; settings.ResultsWindowString = accumWindow; logger.Clear(); mainSettingsTab = new MainSettingsTab(mainControl, logger); Assert.IsFalse(mainSettingsTab.ValidateSettings()); log = logger.GetLog(); Assert.IsTrue( log.Contains(string.Format("\"Accumulation time window\" cannot be less than {0} days.", MainSettings.ACCUM_TIME_WINDOW))); }
public MainSettingsTab(IAppControl appControl, IAutoQCLogger logger) : base(appControl, logger) { Settings = new MainSettings(); }
private static IResultFileStatus GetFileStatusChecker(MainSettings mainSettings) { return(new AcquisitionTimeFileStatus(mainSettings.AcquisitionTime)); }
public override void InitializeFromDefaultSettings() { Settings = MainSettings.InitializeFromDefaults(); _appControl.SetUIMainSettings(Settings); }
public void TestSkylineRunnerArgsImportExisting() { const string skyFile = @"C:\Dummy\path\Test_file.sky"; const string dataFile1 = @"C:\Dummy\path\Test1.raw"; const string dataFile2 = @"C:\Dummy\path\Test2.raw"; var logger = new TestLogger(); var mainSettings = new MainSettings() { SkylineFilePath = skyFile, ResultsWindowString = MainSettings.ACCUM_TIME_WINDOW.ToString() }; var mainSettingsTab = new MainSettingsTab(null, logger) { Settings = mainSettings }; // Create an import context. var importContext = new ImportContext(new List<string>() { dataFile1, dataFile2 }); Assert.IsTrue(importContext.ImportExisting); // Arguments for the first file. var expected = string.Format("--in=\"{0}\" --import-file=\"{1}\" --save", skyFile, dataFile1); importContext.GetNextFile(); var args = mainSettingsTab.SkylineRunnerArgs(importContext); Assert.AreEqual(expected, args.Trim()); // Arguments for the second file importContext.GetNextFile(); Assert.IsTrue(importContext.ImportingLast()); expected = string.Format("--in=\"{0}\" --import-file=\"{1}\" --save", skyFile, dataFile2); args = mainSettingsTab.SkylineRunnerArgs(importContext); Assert.AreEqual(expected, args.Trim()); Assert.IsNull(importContext.GetNextFile()); }
public void Start(MainSettings mainSettings) { _lastAcquiredFileDate = mainSettings.LastAcquiredFileDate; _fileWatcher.Init(mainSettings); ProcessFiles(); }
public void SetUIMainSettings(MainSettings mainSettings) { _mainSettings = mainSettings; }
public static MainSettings InitializeFromDefaults() { var settings = new MainSettings { SkylineFilePath = Settings.Default.SkylineFilePath, FolderToWatch = Settings.Default.FolderToWatch, }; var accumWin = Settings.Default.ResultsWindow; settings.ResultsWindowString = accumWin == 0 ? ACCUM_TIME_WINDOW.ToString() : accumWin.ToString(); var instrumentType = Settings.Default.InstrumentType; settings.InstrumentType = string.IsNullOrEmpty(instrumentType) ? THERMO : instrumentType; var acquisitionTime = Settings.Default.AcquisitionTime; settings.AcquisitionTimeString = acquisitionTime == 0 ? ACQUISITION_TIME.ToString() : acquisitionTime.ToString(); return settings; }