private SourceInfo[] getSourceInfo(FileInfo fileInfo, bool getDetails) { var sourceInfoList = new List <SourceInfo>(); sourceInfoList.Add(new SourceInfo()); sourceInfoList[0].type = getSourceType(fileInfo); sourceInfoList[0].name = fileInfo.Name; sourceInfoList[0].hasDetails = getDetails; sourceInfoList[0].size = (UInt64)fileInfo.Length; sourceInfoList[0].dateModified = fileInfo.LastWriteTime; if (sourceInfoList[0].type != String.Empty) { if (!getDetails) { return(sourceInfoList.ToArray()); } try { ReaderList readerList = ReaderList.FullReaderList; var readerConfig = new ReaderConfig { simAsSpectra = Properties.Settings.Default.SimAsSpectra, srmAsSpectra = Properties.Settings.Default.SrmAsSpectra, combineIonMobilitySpectra = Properties.Settings.Default.CombineIonMobilitySpectra, ignoreZeroIntensityPoints = Properties.Settings.Default.IgnoreZeroIntensityPoints, acceptZeroLengthSpectra = Properties.Settings.Default.AcceptZeroLengthSpectra, allowMsMsWithoutPrecursor = false }; MSDataList msInfo = new MSDataList(); readerList.read(fileInfo.FullName, msInfo, readerConfig); foreach (MSData msData in msInfo) { SourceInfo sourceInfo = new SourceInfo(); sourceInfo.type = sourceInfoList[0].type; sourceInfo.name = sourceInfoList[0].name; if (msInfo.Count > 1) { sourceInfo.name += " (" + msData.run.id + ")"; } sourceInfo.populateFromMSData(msData); sourceInfoList.Add(sourceInfo); } } catch { sourceInfoList[0].spectra = 0; sourceInfoList[0].type = "Invalid " + sourceInfoList[0].type; } foreach (SourceInfo sourceInfo in sourceInfoList) { sourceInfo.size = (UInt64)fileInfo.Length; sourceInfo.dateModified = fileInfo.LastWriteTime; } return(sourceInfoList.ToArray()); } return(null); }
private SourceInfo[] getSourceInfo(FileInfo fileInfo, bool getDetails) { var sourceInfoList = new List <SourceInfo>(); sourceInfoList.Add(new SourceInfo()); sourceInfoList[0].type = getSourceType(fileInfo); sourceInfoList[0].name = fileInfo.Name; sourceInfoList[0].hasDetails = getDetails; sourceInfoList[0].size = (UInt64)fileInfo.Length; sourceInfoList[0].dateModified = fileInfo.LastWriteTime; if (sourceInfoList[0].type != String.Empty) { if (!getDetails) { return(sourceInfoList.ToArray()); } try { ReaderList readerList = ReaderList.FullReaderList; var readerConfig = new ReaderConfig { simAsSpectra = Program.SimAsSpectra, srmAsSpectra = Program.SrmAsSpectra }; MSDataList msInfo = new MSDataList(); readerList.read(fileInfo.FullName, msInfo, readerConfig); foreach (MSData msData in msInfo) { SourceInfo sourceInfo = new SourceInfo(); sourceInfo.type = sourceInfoList[0].type; sourceInfo.name = sourceInfoList[0].name; if (msInfo.Count > 1) { sourceInfo.name += " (" + msData.run.id + ")"; } sourceInfo.populateFromMSData(msData); sourceInfoList.Add(sourceInfo); } } catch { sourceInfoList[0].spectra = 0; sourceInfoList[0].type = "Invalid " + sourceInfoList[0].type; } foreach (SourceInfo sourceInfo in sourceInfoList) { sourceInfo.size = (UInt64)fileInfo.Length; sourceInfo.dateModified = fileInfo.LastWriteTime; } return(sourceInfoList.ToArray()); } return(null); }
void processFile(string filename, Config config, ReaderList readers) { // read in data file using (var msdList = new MSDataList()) { string msg = String.Format("Opening file \"{0}\" for read...", filename); if (LogUpdate != null) { LogUpdate(msg, _info); } if (StatusUpdate != null) { StatusUpdate(msg, ProgressBarStyle.Marquee, _info); } readers.read(filename, msdList); foreach (var msd in msdList) { var outputFilename = config.outputFilename(filename, msd); if (filename == outputFilename) { throw new ArgumentException("Output filepath is the same as input filepath"); } if (StatusUpdate != null) { StatusUpdate("Waiting...", ProgressBarStyle.Marquee, _info); } // only one thread lock (calculateSHA1Mutex) { if (LogUpdate != null) { LogUpdate("Calculating SHA1 checksum...", _info); } if (StatusUpdate != null) { StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info); } MSDataFile.calculateSHA1Checksums(msd); } if (LogUpdate != null) { LogUpdate("Processing...", _info); } if (StatusUpdate != null) { StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info); } SpectrumListFactory.wrap(msd, config.Filters); if ((msd.run.spectrumList == null) || msd.run.spectrumList.empty()) { if ((msd.run.chromatogramList != null) && !msd.run.chromatogramList.empty()) { msg = "Note: input contains only chromatogram data."; switch (config.WriteConfig.format) { case MSDataFile.Format.Format_MZ5: case MSDataFile.Format.Format_mzML: break; default: msg += " The selected output format can only represent spectra. Consider using mzML instead."; break; } } else { msg = "Note: input contains no spectra or chromatogram data."; } if (LogUpdate != null) { LogUpdate(msg, _info); } if (StatusUpdate != null) { StatusUpdate(msg, ProgressBarStyle.Continuous, _info); } } if (StatusUpdate != null && msd.run.spectrumList != null) { StatusUpdate(String.Format("Processing ({0} of {1})", DataGridViewProgressCell.MessageSpecialValue.CurrentValue, DataGridViewProgressCell.MessageSpecialValue.Maximum), ProgressBarStyle.Continuous, _info); } // write out the new data file var ilr = new IterationListenerRegistry(); ilr.addListener(this, 100); msg = String.Format("Writing \"{0}\"...", outputFilename); if (LogUpdate != null) { LogUpdate(msg, _info); } if (StatusUpdate != null) { StatusUpdate(msg, ProgressBarStyle.Continuous, _info); } MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr); ilr.removeListener(this); } } }
void processFile(string filename, Config config, ReaderList readers, Map <string, int> usedOutputFilenames) { // read in data file using (var msdList = new MSDataList()) { string msg = String.Format("Opening file \"{0}\" for read...", filename); var stripCredentialsMatch = Regex.Match(filename, "https?://([^:]+:[^@]+@).*", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); if (stripCredentialsMatch.Success) { msg = msg.Replace(stripCredentialsMatch.Groups[1].Value, ""); } LogUpdate?.Invoke(msg, _info); StatusUpdate?.Invoke(msg, ProgressBarStyle.Marquee, _info); readers.read(filename, msdList, config.ReaderConfig); foreach (var msd in msdList) { try { var outputFilename = config.outputFilename(filename, msd); string deduplicatedFilename = outputFilename; StatusUpdate?.Invoke("Waiting...", ProgressBarStyle.Marquee, _info); // only one thread lock (_calculateSHA1Mutex) { // if output name is same as input name, add a suffix if (filename == outputFilename) { ++usedOutputFilenames[outputFilename]; } if (usedOutputFilenames.Contains(deduplicatedFilename)) { deduplicatedFilename = deduplicatedFilename.Replace(Path.GetExtension(outputFilename), String.Format(" ({0}).{1}", usedOutputFilenames[outputFilename] + 1, Path.GetExtension(outputFilename))); } ++usedOutputFilenames[outputFilename]; LogUpdate?.Invoke("Calculating SHA1 checksum...", _info); StatusUpdate?.Invoke("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info); MSDataFile.calculateSHA1Checksums(msd); } var ilr = new IterationListenerRegistry(); ilr.addListenerWithTimer(this, 1); LogUpdate?.Invoke("Processing...", _info); StatusUpdate?.Invoke("Processing...", ProgressBarStyle.Marquee, _info); SpectrumListFactory.wrap(msd, config.Filters, ilr); config.WriteConfig.useWorkerThreads = msd.run.spectrumList.benefitsFromWorkerThreads(); if ((msd.run.spectrumList == null) || msd.run.spectrumList.empty()) { if ((msd.run.chromatogramList != null) && !msd.run.chromatogramList.empty()) { msg = "Note: input contains only chromatogram data."; switch (config.WriteConfig.format) { case MSDataFile.Format.Format_MZ5: case MSDataFile.Format.Format_mzML: break; default: msg += " The selected output format can only represent spectra. Consider using mzML instead."; break; } } else { msg = "Note: input contains no spectra or chromatogram data."; } LogUpdate?.Invoke(msg, _info); StatusUpdate?.Invoke(msg, ProgressBarStyle.Continuous, _info); } if (StatusUpdate != null && msd.run.spectrumList != null) { StatusUpdate(String.Format("Processing ({0} of {1})", DataGridViewProgressCell.MessageSpecialValue.CurrentValue, DataGridViewProgressCell.MessageSpecialValue.Maximum), ProgressBarStyle.Continuous, _info); } // write out the new data file msg = String.Format("Writing \"{0}\"...", deduplicatedFilename); LogUpdate?.Invoke(msg, _info); StatusUpdate?.Invoke(msg, ProgressBarStyle.Continuous, _info); MSDataFile.write(msd, deduplicatedFilename, config.WriteConfig, ilr); ilr.removeListener(this); } finally { msd.Dispose(); } } } }
void processFile(string filename, Config config, ReaderList readers) { if (LogUpdate != null) { LogUpdate("Opening file...", _info); } if (StatusUpdate != null) { StatusUpdate("Opening file...", ProgressBarStyle.Marquee, _info); } // read in data file using (var msdList = new MSDataList()) { readers.read(filename, msdList); foreach (var msd in msdList) { var outputFilename = config.outputFilename(filename, msd); if (filename == outputFilename) { throw new ArgumentException("Output filepath is the same as input filepath"); } if (LogUpdate != null) { LogUpdate("Calculating SHA1 checksum...", _info); } if (StatusUpdate != null) { StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info); } // only one thread lock (calculateSHA1Mutex) MSDataFile.calculateSHA1Checksums(msd); if (LogUpdate != null) { LogUpdate("Processing...", _info); } if (StatusUpdate != null) { StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info); } SpectrumListFactory.wrap(msd, config.Filters); if (StatusUpdate != null && msd.run.spectrumList != null) { StatusUpdate(String.Format("Processing ({0} of {1})", DataGridViewProgressCell.MessageSpecialValue.CurrentValue, DataGridViewProgressCell.MessageSpecialValue.Maximum), ProgressBarStyle.Continuous, _info); } // write out the new data file IterationListenerRegistry ilr = null; ilr = new IterationListenerRegistry(); ilr.addListener(this, 100); MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr); } } }
void processFile(string filename, Config config, ReaderList readers) { // read in data file using (var msdList = new MSDataList()) { string msg = String.Format("Opening file \"{0}\" for read...",filename); if (LogUpdate != null) LogUpdate(msg, _info); if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info); readers.read(filename, msdList); foreach (var msd in msdList) { var outputFilename = config.outputFilename(filename, msd); if (filename == outputFilename) throw new ArgumentException("Output filepath is the same as input filepath"); if (StatusUpdate != null) StatusUpdate("Waiting...", ProgressBarStyle.Marquee, _info); // only one thread lock (calculateSHA1Mutex) { if (LogUpdate != null) LogUpdate("Calculating SHA1 checksum...", _info); if (StatusUpdate != null) StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info); MSDataFile.calculateSHA1Checksums(msd); } if (LogUpdate != null) LogUpdate("Processing...", _info); if (StatusUpdate != null) StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info); SpectrumListFactory.wrap(msd, config.Filters); if ((msd.run.spectrumList == null) || msd.run.spectrumList.empty()) { if ((msd.run.chromatogramList != null) && !msd.run.chromatogramList.empty()) { msg = "Note: input contains only chromatogram data."; switch (config.WriteConfig.format) { case MSDataFile.Format.Format_MZ5: case MSDataFile.Format.Format_mzML: break; default: msg += " The selected output format can only represent spectra. Consider using mzML instead."; break; } } else msg = "Note: input contains no spectra or chromatogram data."; if (LogUpdate != null) LogUpdate(msg, _info); if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info); } if (StatusUpdate != null && msd.run.spectrumList != null) StatusUpdate(String.Format("Processing ({0} of {1})", DataGridViewProgressCell.MessageSpecialValue.CurrentValue, DataGridViewProgressCell.MessageSpecialValue.Maximum), ProgressBarStyle.Continuous, _info); // write out the new data file var ilr = new IterationListenerRegistry(); ilr.addListener(this, 100); msg = String.Format("Writing \"{0}\"...", outputFilename); if (LogUpdate != null) LogUpdate(msg, _info); if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info); MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr); ilr.removeListener(this); } } }