Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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();
                    }
                }
            }
        }
Exemple #4
0
        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);
                }
            }
        }