private void ValidateSelectionIsFolder(string folderName) { bool isDirectory; bool isFile; try { isDirectory = Directory.Exists(folderName); isFile = File.Exists(folderName); } catch (Exception ex) { throw new IOException("Error when accessing datafile. Details: " + ex.Message); } Check.Require(!isFile, "Could not initialize Dataset. Looking for a folder path, but user supplied a file path."); Check.Require(isDirectory, "Could not initialize Dataset. Target dataset folder not found."); }
public BrukerV3Run(string directoryPath) : this() { ValidateSelectionIsFolder(directoryPath); DatasetFileOrDirectoryPath = directoryPath; m_serFileInfo = findSerFile(); m_fidFileInfo = findFIDFile(); if (m_serFileInfo == null && m_fidFileInfo == null) { throw new FileNotFoundException("Run initialization problem. Could not find a 'ser' or 'fid' file within the directory structure."); } string filePathForRawDataReader; if (m_serFileInfo != null) { filePathForRawDataReader = m_serFileInfo.FullName; } else if (m_serFileInfo == null && m_fidFileInfo != null) { filePathForRawDataReader = m_fidFileInfo.FullName; } else { throw new FileNotFoundException("Run initialization problem. Could not find a 'ser' or 'fid' file within the directory structure."); } var fiSettingsFile = findSettingsFile(); if (fiSettingsFile == null) { var fiAcqusFile = findAcqusFile(); if (fiAcqusFile == null) { throw new FileNotFoundException("Run initialization problem. Could not find the settings file ('apexAcquisition.method') within the directory structure."); } SettingsFilePath = fiAcqusFile.FullName; } else { SettingsFilePath = fiSettingsFile.FullName; } // Instantiate the BrukerDataReader // It will read the settings file and define the parameters // Parameters are: CalA, CalB, sampleRate, numValueInScan m_rawDataReader = new DataReader(filePathForRawDataReader, SettingsFilePath); m_rawDataReader.Parameters.Display(); DatasetName = GetDatasetName(DatasetFileOrDirectoryPath); DatasetDirectoryPath = GetDatasetFolderName(DatasetFileOrDirectoryPath); MinLCScan = GetMinPossibleLCScanNum(); MaxLCScan = GetMaxPossibleLCScanNum(); Check.Ensure(m_rawDataReader != null, "BrukerRun could not be initialized. Failed to connect to raw data."); }