Ejemplo n.º 1
0
        /// <summary>
        /// Add the given files to the queue of files to load.
        /// </summary>
        public void Load(
            IList <DataFileReplicates> loadList,
            SrmDocument document,
            string documentFilePath,
            ChromatogramCache cacheRecalc,
            MultiFileLoadMonitor loadMonitor,
            Action <IList <FileLoadCompletionAccumulator.Completion> > complete)
        {
            lock (this)
            {
                // Find non-duplicate paths to load.
                var uniqueLoadList = new List <DataFileReplicates>();
                foreach (var loadItem in loadList)
                {
                    // Ignore a file that is already being loaded (or is queued for loading).
                    if (_loadingPaths.ContainsKey(loadItem.DataFile))
                    {
                        continue;
                    }
                    int idIndex = document.Id.GlobalIndex;
                    _loadingPaths.Add(loadItem.DataFile, idIndex);
                    uniqueLoadList.Add(loadItem);
                }

                if (uniqueLoadList.Count == 0)
                {
                    return;
                }

                int threadCount = GetOptimalThreadCount(_threadCountPreferred, uniqueLoadList.Count, _simultaneousFileOptions);
                _worker.RunAsync(threadCount, @"Load file");

                var accumulator = new FileLoadCompletionAccumulator(complete, threadCount, uniqueLoadList.Count);

                // Add new paths to queue.
                foreach (var loadItem in uniqueLoadList)
                {
                    var loadingStatus = new ChromatogramLoadingStatus(loadItem.DataFile, loadItem.ReplicateList);

                    ChangeStatus(s => s.Add(loadingStatus));

                    // Queue work item to load the file.
                    _worker.Add(new LoadInfo
                    {
                        Path             = loadItem.DataFile,
                        PartPath         = loadItem.PartPath,
                        Document         = document,
                        DocumentFilePath = documentFilePath,
                        CacheRecalc      = cacheRecalc,
                        Status           = loadingStatus,
                        LoadMonitor      = new SingleFileLoadMonitor(loadMonitor, loadItem.DataFile),
                        Complete         = accumulator.Complete
                    });
                }
            }
        }
Ejemplo n.º 2
0
        private void AlignDataRow(int index, CancellationToken cancellationToken)
        {
            var dataRow = _dataRows[index];

            if (dataRow.TargetTimes == null || dataRow.SourceTimes == null)
            {
                return;
            }

            _rowUpdateQueue.Add(() => AlignDataRowAsync(dataRow, index, cancellationToken));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add the given file to the queue of files to load.
        /// </summary>
        public void Load(
            IList <DataFileReplicates> loadList,
            SrmDocument document,
            string documentFilePath,
            ChromatogramCache cacheRecalc,
            MultiFileLoadMonitor loadMonitor,
            Action <ChromatogramCache, IProgressStatus> complete)
        {
            // This may be called on multiple background loader threads simultaneously, but QueueWorker can handle it.
            _worker.RunAsync(_threadCount, "Load file"); // Not L10N

            lock (this)
            {
                // Find non-duplicate paths to load.
                var uniqueLoadList = new List <DataFileReplicates>();
                foreach (var loadItem in loadList)
                {
                    // Ignore a file that is already being loaded (or is queued for loading).
                    if (_loadingPaths.ContainsKey(loadItem.DataFile))
                    {
                        continue;
                    }
                    int idIndex = document.Id.GlobalIndex;
                    _loadingPaths.Add(loadItem.DataFile, idIndex);
                    uniqueLoadList.Add(loadItem);
                }

                if (uniqueLoadList.Count == 0)
                {
                    return;
                }

                // Add new paths to queue.
                foreach (var loadItem in uniqueLoadList)
                {
                    var loadingStatus = new ChromatogramLoadingStatus(loadItem.DataFile, loadItem.ReplicateList);

                    ChangeStatus(s => s.Add(loadingStatus));

                    // Queue work item to load the file.
                    _worker.Add(new LoadInfo
                    {
                        Path             = loadItem.DataFile,
                        PartPath         = loadItem.PartPath,
                        Document         = document,
                        DocumentFilePath = documentFilePath,
                        CacheRecalc      = cacheRecalc,
                        Status           = loadingStatus,
                        LoadMonitor      = new SingleFileLoadMonitor(loadMonitor, loadItem.DataFile),
                        Complete         = complete
                    });
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            _cmdArgs = new CommandArgs();
            if (!_cmdArgs.ParseArgs(args))
                return;

            // Remove all SKYD files
            foreach (var skydFile in Directory.EnumerateFiles(Path.GetDirectoryName(_cmdArgs.FilePath) ?? string.Empty, "*.skyd"))
            {
                try
                {
                    File.Delete(skydFile);
                }
                catch (Exception)
                {
                    Console.Error.WriteLine("Error: Failed to remove existing file {0}", skydFile);
                    return;
                }
            }

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
            _queue = new QueueWorker<List<string>>(Run);
            _queue.RunAsync(_cmdArgs.Processes, "Start Skyline");

            string dataFilter = "*.*";
            if (!string.IsNullOrEmpty(_cmdArgs.DataFilter))
                dataFilter = _cmdArgs.DataFilter;
            string dataDir = ".";
            if (!string.IsNullOrEmpty(_cmdArgs.DataDir))
                dataDir = _cmdArgs.DataDir;
            var fileGroupCurrent = new List<string>();
            var fileGroups = new List<List<string>> {fileGroupCurrent};
            var dataFiles = Directory.EnumerateFiles(dataDir, dataFilter).ToArray();
            int filesPerProcess = (int) Math.Ceiling(((double) dataFiles.Length)/_cmdArgs.Processes);
            foreach (var dataFile in dataFiles)
            {
                if (fileGroupCurrent.Count >= filesPerProcess)
                {
                    fileGroupCurrent = new List<string>();
                    fileGroups.Add(fileGroupCurrent);
                }
                fileGroupCurrent.Add(dataFile);
            }
            _queue.Add(fileGroups, true);

            Console.WriteLine("Elapsed time: " + _stopwatch.Elapsed.ToString(@"mm\:ss"));
        }
Ejemplo n.º 5
0
        public void Complete(ChromatogramCache cache, IProgressStatus status)
        {
            var completedCount = Interlocked.Increment(ref _completedCount);
            var completion     = new Completion(cache, status);

            if (_completionWorker == null)
            {
                _complete(new SingletonList <Completion>(completion));
            }
            else
            {
                _completionWorker.Add(completion);

                if (completedCount == _loadingCount)
                {
                    _completionWorker.DoneAdding();
                }
            }
        }
Ejemplo n.º 6
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            btnStart.Enabled = false;
            _timeColor = lblTime.ForeColor;
            lblTime.ForeColor = Color.Red;

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
            _timer = new Timer {Interval = 500};
            _timer.Tick += (s, e1) => lblTime.Text = _stopwatch.Elapsed.ToString(@"mm\:ss"); // Not L10N
            _timer.Start();

            if (File.Exists(SkydFile))
                File.Delete(SkydFile);

            _log = Log.Replace("#", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
            _dataDir = Path.Combine(RootDir, comboModel.Text);

            _uiIndex = comboUI.SelectedIndex;
            _queue = new QueueWorker<string>(Run) {CompleteAction = RunFinished};
            _queue.RunAsync((int) numericMaxProcesses.Value, "Start Skyline");
            _queue.Add(Directory.EnumerateFiles(_dataDir, comboModel.Text == "wiff" ? "*.wiff" : "*.mz5"));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Collects statistics on how much space savings minimizing will achieve, and (if outStream
        /// is not null) writes out the minimized cache file.
        /// </summary>
        public void Minimize(Settings settings, ProgressCallback progressCallback, Stream outStream,
                             FileStream outStreamScans = null, FileStream outStreamPeaks = null, FileStream outStreamScores = null)
        {
            var  writer = outStream == null ? null : new Writer(ChromatogramCache, settings.CacheFormat, outStream, outStreamScans, outStreamPeaks, outStreamScores);
            var  statisticsCollector = new MinStatisticsCollector(this);
            bool readChromatograms   = settings.NoiseTimeRange.HasValue || writer != null;

            var chromGroupHeaderToIndex = new Dictionary <long, int>(ChromGroupHeaderInfos.Count);

            for (int i = 0; i < ChromGroupHeaderInfos.Count; i++)
            {
                var cghi = ChromGroupHeaderInfos[i];
                chromGroupHeaderToIndex.Add(cghi.LocationPoints, i);
            }
            var chromGroups      = new ChromatogramGroupInfo[ChromGroupHeaderInfos.Count];
            var transitionGroups = new List <TransitionGroupDocNode> [ChromGroupHeaderInfos.Count];

            foreach (var nodePep in Document.Molecules)
            {
                foreach (var nodeGroup in nodePep.TransitionGroups)
                {
                    foreach (var chromGroupInfo in ChromatogramCache.LoadChromatogramInfos(nodePep, nodeGroup, _tolerance, null))
                    {
                        int headerIndex = chromGroupHeaderToIndex[chromGroupInfo.Header.LocationPoints];
                        if (chromGroups[headerIndex] == null)
                        {
                            chromGroups[headerIndex]      = chromGroupInfo;
                            transitionGroups[headerIndex] = new List <TransitionGroupDocNode>();
                        }
                        transitionGroups[headerIndex].Add(nodeGroup);
                    }
                }
            }

            var minimizer = new QueueWorker <MinimizeParams>(null, MinimizeAndWrite);

            minimizer.RunAsync(MINIMIZING_THREADS, @"Minimizing/Writing", MAX_GROUP_READ_AHEAD);

            for (int iHeader = 0; iHeader < ChromGroupHeaderInfos.Count; iHeader++)
            {
                var chromGroupInfo = chromGroups[iHeader];
                IList <TransitionGroupDocNode> transitionGroupDocNodes;
                if (chromGroupInfo == null)
                {
                    chromGroupInfo          = ChromatogramCache.LoadChromatogramInfo(ChromGroupHeaderInfos[iHeader]);
                    transitionGroupDocNodes = new TransitionGroupDocNode[0];
                }
                else
                {
                    transitionGroupDocNodes = transitionGroups[iHeader];
                }

                if (readChromatograms)
                {
                    try
                    {
                        chromGroupInfo.ReadChromatogram(ChromatogramCache, true);
                    }
                    catch (Exception exception)
                    {
                        Trace.TraceWarning(@"Unable to read chromatogram {0}", exception);
                    }
                }

                if (minimizer.Exception != null)
                {
                    break;
                }

                minimizer.Add(new MinimizeParams(writer, settings, chromGroupInfo, transitionGroupDocNodes, progressCallback, statisticsCollector));

                // Null out the ChromGroup in our array so it can be garbage collected.
                chromGroups[iHeader] = null;
            }

            minimizer.DoneAdding(true);
            if (minimizer.Exception != null)
            {
                throw minimizer.Exception;
            }

            statisticsCollector.ReportProgress(progressCallback, true);

            if (writer != null)
            {
                writer.WriteEndOfFile();
            }
        }