public RemoteChromDataProvider(SrmDocument document, IRetentionTimePredictor retentionTimePredictor, ChromFileInfo chromFileInfo, ProgressStatus progressStatus, int startPercent,
     int endPercent, ILoadMonitor loader)
     : base(chromFileInfo, progressStatus, startPercent, endPercent, loader)
 {
     _document = document;
     ChorusUrl chorusUrl = (ChorusUrl)chromFileInfo.FilePath;
     _chorusAccount = chorusUrl.FindChorusAccount(Settings.Default.ChorusAccountList);
     var chromatogramRequestProviders = new List<ChromatogramRequestProvider>();
     foreach (bool firstPass in new[] {true, false})
     {
         if (null == retentionTimePredictor && !firstPass)
         {
             continue;
         }
         var chromatogramRequestProvider = new ChromatogramRequestProvider(document, chorusUrl,
             retentionTimePredictor, firstPass);
         if (0 == chromatogramRequestProvider.ChromKeys.Count)
         {
             continue;
         }
         chromatogramRequestProviders.Add(chromatogramRequestProvider);
     }
     _chromatogramRequestProviders = chromatogramRequestProviders.ToArray();
     _chromTaskLists = new ChromTaskList[_chromatogramRequestProviders.Length];
 }
Example #2
0
 private BlibDb(String path)
 {
     FilePath = path;
     SessionFactory = BlibSessionFactoryFactory.CreateSessionFactory(path, false);
     DatabaseLock = new ReaderWriterLock();
     _progressStatus = new ProgressStatus(string.Empty);
 }
Example #3
0
        public const string EXE_BLIB_FILTER = "BlibFilter"; // Not L10N
        public bool Filter(string sourceFile, string destinationFile, IProgressMonitor progressMonitor, ref ProgressStatus status)
        {
            // ReSharper disable NonLocalizedString
            var argv = new List<string>
                           {
                               "-b true",
                               "\"" + sourceFile + "\"",
                               "\"" + destinationFile + "\""
                           };
            // ReSharper restore NonLocalizedString


            var psiBlibFilter = new ProcessStartInfo(EXE_BLIB_FILTER)
            {
                CreateNoWindow = true,
                UseShellExecute = false,
                WorkingDirectory = Path.GetDirectoryName(destinationFile) ?? string.Empty,
                Arguments = string.Join(" ", argv.ToArray()), // Not L10N
                RedirectStandardOutput = true,
                RedirectStandardError = true
            };
            var processRunner = new ProcessRunner();
            processRunner.Run(psiBlibFilter, null, progressMonitor, ref status);
            return status.IsComplete;
        }
Example #4
0
 public static void RunProcess(this ProcessStartInfo psi, string stdin, string messagePrefix, IProgressMonitor progress, ref ProgressStatus status)
 {
     var processRunner = new ProcessRunner
                             {
                                 StatusPrefix = messagePrefix,
                             };
     processRunner.Run(psi, stdin, progress, ref status);
 }
Example #5
0
        public ChromCacheJoiner(string cachePath, IPooledStream streamDest,
            IList<string> cacheFilePaths, ILoadMonitor loader, ProgressStatus status,
            Action<ChromatogramCache, Exception> completed)
            : base(cachePath, loader, status, completed)
        {
            _destinationStream = streamDest;

            CacheFilePaths = cacheFilePaths;
        }
 public static ProgressMonitorImpl NewProgressMonitorImpl(ProgressStatus currentStatus, Func<int, bool> updateProgress)
 {
     return new ProgressMonitorImpl(
         () => !updateProgress.Invoke(currentStatus.PercentComplete),
         status => {
             currentStatus = status;
             updateProgress(status.PercentComplete);
         });
 }
Example #7
0
 protected ChromCacheWriter(string cachePath, ILoadMonitor loader, ProgressStatus status,
     Action<ChromatogramCache, Exception> completed)
 {
     CachePath = cachePath;
     _fs = new FileSaver(CachePath);
     _fsScans = new FileSaver(CachePath + ChromatogramCache.SCANS_EXT, true);
     _fsPeaks = new FileSaver(CachePath + ChromatogramCache.PEAKS_EXT, true);
     _fsScores = new FileSaver(CachePath + ChromatogramCache.SCORES_EXT, true);
     _loader = loader;
     _status = status;
     _completed = completed;
 }
Example #8
0
        public ChromatogramDataProvider(MsDataFileImpl dataFile,
            ChromFileInfo fileInfo,
            ProgressStatus status,
            int startPercent,
            int endPercent,
            IProgressMonitor loader)
            : base(fileInfo, status, startPercent, endPercent, loader)
        {
            _dataFile = dataFile;

            if (_dataFile.IsThermoFile)
            {
                _readMaxMinutes = 4;
            }

            int len = dataFile.ChromatogramCount;
            _chromIndices = new int[len];

            bool fixCEOptForShimadzu = dataFile.IsShimadzuFile;
            int indexPrecursor = -1;
            double lastPrecursor = 0;
            for (int i = 0; i < len; i++)
            {
                int index;
                string id = dataFile.GetChromatogramId(i, out index);

                if (!ChromKey.IsKeyId(id))
                    continue;

                var chromKey = ChromKey.FromId(id, fixCEOptForShimadzu);
                if (chromKey.Precursor != lastPrecursor)
                {
                    lastPrecursor = chromKey.Precursor;
                    indexPrecursor++;
                }
                var ki = new KeyValuePair<ChromKey, int>(chromKey, index);
                _chromIndices[index] = indexPrecursor;
                _chromIds.Add(ki);
            }

            // Shimadzu can't do the necessary product m/z stepping for itself.
            // So, they provide the CE values in their IDs and we need to adjust
            // product m/z values for them to support CE optimization.
            if (fixCEOptForShimadzu)
                FixCEOptForShimadzu();

            if (_chromIds.Count == 0)
                throw new NoSrmDataException(dataFile.FilePath);

            SetPercentComplete(50);
        }
 public ChorusResponseChromDataProvider(SrmDocument document, ChromFileInfo chromFileInfo, ProgressStatus progressStatus, int startPercent,
     int endPercent, ILoadMonitor loader)
     : base(chromFileInfo, progressStatus, startPercent, endPercent, loader)
 {
     ChromatogramCache.RawData rawData;
     MsDataFilePath msDataFilePath = (MsDataFilePath) chromFileInfo.FilePath;
     IPooledStream stream = loader.StreamManager.CreatePooledStream(msDataFilePath.FilePath, false);
     ChromatogramCache.LoadStructs(stream.Stream, out rawData);
     var chromCacheFile = rawData.ChromCacheFiles[0];
     rawData.ChromCacheFiles = new[]
     {
         new ChromCachedFile(chromFileInfo.FilePath, chromCacheFile.Flags, chromCacheFile.FileWriteTime,
             chromCacheFile.RunStartTime, chromCacheFile.MaxRetentionTime, chromCacheFile.MaxIntensity,
             chromCacheFile.InstrumentInfoList),
     };
     var cache = new ChromatogramCache("cachePath", rawData, stream); // Not L10N
     _cachedChromatogramDataProvider = new CachedChromatogramDataProvider(cache, document,
         chromFileInfo.FilePath, chromFileInfo, null, progressStatus, startPercent, endPercent, loader);
 }
 public CachedChromatogramDataProvider(ChromatogramCache cache,
     SrmDocument document,
     MsDataFileUri dataFilePath,
     ChromFileInfo fileInfo,
     bool? singleMatchMz,
     ProgressStatus status,
     int startPercent,
     int endPercent,
     ILoadMonitor loader)
     : base(fileInfo, status, startPercent, endPercent, loader)
 {
     _cache = cache;
     _fileIndex = cache.CachedFiles.IndexOf(f => Equals(f.FilePath, dataFilePath));
     _chromKeyIndices = cache.GetChromKeys(dataFilePath).OrderBy(v => v.LocationPoints).ToArray();
     _cache.GetStatusDimensions(dataFilePath, out _maxRetentionTime, out _maxIntensity);
     _singleMatchMz = singleMatchMz.HasValue
                          ? singleMatchMz.Value
                          // Unfortunately, before the single matching status was
                          // written into the cache file, we can only guess about its
                          // status based on the overall document settings
                          : document.Settings.TransitionSettings.FullScan.IsEnabled;
 }
Example #11
0
 public UpdateProgressResponse UpdateProgress(ProgressStatus status)
 {
     return UpdateProgressResponse.normal;
 }
Example #12
0
        //Throws DatabaseOpeningException
        public static IrtDb GetIrtDb(string path, IProgressMonitor loadMonitor)
        {
            var status = new ProgressStatus(string.Format(Resources.IrtDb_GetIrtDb_Loading_iRT_database__0_, path));
            if (loadMonitor != null)
                loadMonitor.UpdateProgress(status);

            try
            {
                if (path == null)
                    throw new DatabaseOpeningException(Resources.IrtDb_GetIrtDb_Database_path_cannot_be_null);

                if (!File.Exists(path))
                    throw new DatabaseOpeningException(String.Format(Resources.IrtDb_GetIrtDb_The_file__0__does_not_exist_, path));

                string message;
                Exception xInner = null;
                try
                {
                    //Check for a valid SQLite file and that it has our schema
                    //Allow only one thread at a time to read from the same path
                    using (var sessionFactory = GetSessionFactory(path))
                    {
                        lock (sessionFactory)
                        {
                            return new IrtDb(path, sessionFactory).Load(loadMonitor, status);
                        }
                    }
                }
                catch (UnauthorizedAccessException x)
                {
                    message = string.Format(Resources.IrtDb_GetIrtDb_You_do_not_have_privileges_to_access_the_file__0_, path);
                    xInner = x;
                }
                catch (DirectoryNotFoundException x)
                {
                    message = string.Format(Resources.IrtDb_GetIrtDb_The_path_containing__0__does_not_exist, path);
                    xInner = x;
                }
                catch (FileNotFoundException x)
                {
                    message = string.Format(Resources.IrtDb_GetIrtDb_The_file__0__could_not_be_created_Perhaps_you_do_not_have_sufficient_privileges, path);
                    xInner = x;
                }
                catch (SQLiteException x)
                {
                    message = string.Format(Resources.IrtDb_GetIrtDb_The_file__0__is_not_a_valid_iRT_database_file, path);
                    xInner = x;
                }
                catch (Exception x)
                {
                    message = string.Format(Resources.IrtDb_GetIrtDb_The_file__0__could_not_be_opened, path);
                    xInner = x;
                }

                throw new DatabaseOpeningException(message, xInner);
            }
            catch (DatabaseOpeningException x)
            {
                if (loadMonitor == null)
                    throw;
                loadMonitor.UpdateProgress(status.ChangeErrorException(x));
                return null;
            }
        }
Example #13
0
        public void ExportChromatograms(string chromatogramsFile, bool precursors, bool products, bool basePeaks, bool tics)
        {
            _out.WriteLine(Resources.CommandLine_ExportChromatograms_Exporting_chromatograms_file__0____, chromatogramsFile);

            var chromExtractors = new List<ChromExtractor>();
            if (tics)
                chromExtractors.Add(ChromExtractor.summed);
            if (basePeaks)
                chromExtractors.Add(ChromExtractor.base_peak);

            var chromSources = new List<ChromSource>();
            if (precursors)
                chromSources.Add(ChromSource.ms1);
            if (products)
                chromSources.Add(ChromSource.fragment);

            if (chromExtractors.Count == 0 && chromSources.Count == 0)
            {
                _out.WriteLine(Resources.CommandLine_ExportChromatograms_Error__At_least_one_chromatogram_type_must_be_selected);
                return;
            }

            var filesToExport = Document.Settings.HasResults
                ? Document.Settings.MeasuredResults.MSDataFilePaths.Select(f => f.GetFileName()).ToList()
                : new List<string>();
            if (filesToExport.Count == 0)
            {
                _out.WriteLine(Resources.CommandLine_ExportChromatograms_Error__The_document_must_have_imported_results);
                return;
            }

            try
            {
                var chromExporter = new ChromatogramExporter(Document);
                using (var saver = new FileSaver(chromatogramsFile))
                using (var writer = new StreamWriter(saver.SafeName))
                {
                    var status = new ProgressStatus(string.Empty);
                    IProgressMonitor broker = new CommandProgressMonitor(_out, status);
                    chromExporter.Export(writer, broker, filesToExport, LocalizationHelper.CurrentCulture, chromExtractors, chromSources);
                    writer.Close();
                    broker.UpdateProgress(status.Complete());
                    saver.Commit();
                    _out.WriteLine(Resources.CommandLine_ExportChromatograms_Chromatograms_file__0__exported_successfully_, chromatogramsFile);
                }
            }
            catch (Exception x)
            {
                _out.WriteLine(Resources.CommandLine_ExportChromatograms_Error__Failure_attempting_to_save_chromatograms_file__0_, chromatogramsFile);
                _out.WriteLine(x.Message);
            }
        }
        public SrmDocument Import(TextReader reader, IProgressMonitor progressMonitor, long lineCount, bool isMinutes, bool removeMissing = false, bool changePeaks = true)
        {
            var status = new ProgressStatus(Resources.PeakBoundaryImporter_Import_Importing_Peak_Boundaries);
            double timeConversionFactor = isMinutes ? 1.0 : 60.0;
            int linesRead = 0;
            int progressPercent = 0;
            var docNew = (SrmDocument) Document.ChangeIgnoreChangingChildren(true);
            var docReference = docNew;
            var sequenceToNode = new Dictionary<Tuple<string, bool>, IList<IdentityPath>>();
            var fileNameToFileMatch = new Dictionary<string, ChromSetFileMatch>();
            var trackAdjustedResults = new HashSet<ResultsKey>();
            var modMatcher = new ModificationMatcher();
            // Make the dictionary of modified peptide strings to doc nodes and paths
            for (int i = 0; i < Document.MoleculeCount; ++i)
            {
                IdentityPath peptidePath = Document.GetPathTo((int) SrmDocument.Level.Molecules, i);
                PeptideDocNode peptideNode = (PeptideDocNode) Document.FindNode(peptidePath);
                var peptidePair = new Tuple<string, bool>(peptideNode.RawTextId, peptideNode.IsDecoy);
                IList<IdentityPath> idPathList;
                // Each (sequence, isDecoy) pair can be associated with more than one peptide,
                // to handle the case of duplicate peptides in the doucment.
                if (sequenceToNode.TryGetValue(peptidePair, out idPathList))
                {
                    idPathList.Add(peptidePath);
                    sequenceToNode[peptidePair] = idPathList;
                }
                else
                {
                    idPathList = new List<IdentityPath> { peptidePath };
                    sequenceToNode.Add(peptidePair, idPathList);
                }
            }

            // Add annotations as possible columns
            var allFieldNames = new List<string[]>(FIELD_NAMES);
            allFieldNames.AddRange(from def in Document.Settings.DataSettings.AnnotationDefs
                                   where def.AnnotationTargets.Contains(AnnotationDef.AnnotationTarget.precursor_result)
                                   select new[] { def.Name });

            string line = reader.ReadLine();
            linesRead++;
            int[] fieldIndices;
            int fieldsTotal;
            // If we aren't changing peaks, allow start and end time to be missing
            var requiredFields = changePeaks ? REQUIRED_FIELDS : REQUIRED_NO_CHROM;
            char correctSeparator = ReadFirstLine(line, allFieldNames, requiredFields, out fieldIndices, out fieldsTotal);

            while ((line = reader.ReadLine()) != null)
            {
                linesRead++;
                if (progressMonitor != null)
                {
                    if (progressMonitor.IsCanceled)
                        return Document;
                    int progressNew = (int) (linesRead*100/lineCount);
                    if (progressPercent != progressNew)
                    {
                        progressMonitor.UpdateProgress(status = status.ChangePercentComplete(progressNew));
                        progressPercent = progressNew;
                    }
                }
                var dataFields = new DataFields(fieldIndices, line.ParseDsvFields(correctSeparator), allFieldNames);
                if (dataFields.Length != fieldsTotal)
                {
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Line__0__field_count__1__differs_from_the_first_line__which_has__2_,
                        linesRead, dataFields.Length, fieldsTotal));
                }
                string modifiedPeptideString = dataFields.GetField(Field.modified_peptide);
                modMatcher.CreateMatches(Document.Settings,
                                        new List<string> {modifiedPeptideString},
                                        Settings.Default.StaticModList,
                                        Settings.Default.HeavyModList);
                // Convert the modified peptide string into a standardized form that
                // converts unimod, names, etc, into masses, eg [+57.0]
                var nodeForModPep = modMatcher.GetModifiedNode(modifiedPeptideString);
                if (nodeForModPep == null)
                {
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Peptide_has_unrecognized_modifications__0__at_line__1_, modifiedPeptideString, linesRead));
                }
                nodeForModPep = nodeForModPep.ChangeSettings(Document.Settings, SrmSettingsDiff.ALL);
                modifiedPeptideString = nodeForModPep.RawTextId; // Modified sequence, or custom ion name
                string fileName = dataFields.GetField(Field.filename);
                bool isDecoy = dataFields.IsDecoy(linesRead);
                var peptideIdentifier = new Tuple<string, bool>(modifiedPeptideString, isDecoy);
                int charge;
                bool chargeSpecified = dataFields.TryGetCharge(linesRead, out charge);
                string sampleName = dataFields.GetField(Field.sample_name);

                double? startTime = null;
                double? endTime = null;
                if (changePeaks)
                {
                    startTime = dataFields.GetTime(Field.start_time, Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_start_time_, linesRead);
                    if (startTime.HasValue)
                        startTime = startTime / timeConversionFactor;
                    endTime = dataFields.GetTime(Field.end_time, Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_end_time_, linesRead);
                    if (endTime.HasValue)
                        endTime = endTime / timeConversionFactor;
                }

                // Error if only one of startTime and endTime is null
                if (startTime == null && endTime != null)
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_start_time_on_line__0_, linesRead));
                if (startTime != null && endTime == null)
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_end_time_on_line__0_, linesRead));
                // Add filename to second dictionary if not yet encountered
                ChromSetFileMatch fileMatch;
                if (!fileNameToFileMatch.TryGetValue(fileName, out fileMatch))
                {
                    fileMatch = Document.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(fileName));
                    fileNameToFileMatch.Add(fileName, fileMatch);
                }
                if (fileMatch == null)
                {
                    UnrecognizedFiles.Add(fileName);
                    continue;
                }
                var chromSet = fileMatch.Chromatograms;
                string nameSet = chromSet.Name;
                ChromFileInfoId[] fileIds;
                if (sampleName == null)
                {
                    fileIds = chromSet.MSDataFileInfos.Select(x => x.FileId).ToArray();
                }
                else
                {
                    var sampleFile = chromSet.MSDataFileInfos.FirstOrDefault(info => Equals(sampleName, info.FilePath.GetSampleName()));
                    if (sampleFile == null)
                    {
                        throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Sample__0__on_line__1__does_not_match_the_file__2__, sampleName, linesRead, fileName));
                    }
                    fileIds = new[] {sampleFile.FileId};
                }
                // Look up the IdentityPath of peptide in first dictionary
                IList<IdentityPath> pepPaths;
                if (!sequenceToNode.TryGetValue(peptideIdentifier, out pepPaths))
                {
                    UnrecognizedPeptides.Add(modifiedPeptideString);
                    continue;
                }

                // Define the annotations to be added
                var annotations = dataFields.GetAnnotations();
                AnnotationsAdded = annotations.Keys.ToList();

                // Loop over all the transition groups in that peptide to find matching charge,
                // or use all transition groups if charge not specified
                bool foundSample = false;
                foreach (var pepPath in pepPaths)
                {
                    var nodePep = (PeptideDocNode)docNew.FindNode(pepPath);
                    for(int i = 0; i < nodePep.Children.Count; ++i)
                    {
                        var groupRelPath = nodePep.GetPathTo(i);
                        var groupNode = (TransitionGroupDocNode) nodePep.FindNode(groupRelPath);
                        if (!chargeSpecified || charge == groupNode.TransitionGroup.PrecursorCharge)
                        {
                            var groupFileIndices =
                                new HashSet<int>(groupNode.ChromInfos.Select(x => x.FileId.GlobalIndex));
                            // Loop over the files in this groupNode to find the correct sample
                            // Change peak boundaries for the transition group
                            foreach (var fileId in fileIds)
                            {
                                if (groupFileIndices.Contains(fileId.GlobalIndex))
                                {
                                    var groupPath = new IdentityPath(pepPath, groupNode.Id);
                                    // Attach annotations
                                    docNew = docNew.AddPrecursorResultsAnnotations(groupPath, fileId, annotations);
                                    // Change peak
                                    var filePath = chromSet.GetFileInfo(fileId).FilePath;
                                    if (changePeaks)
                                    {
                                        docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                            null, startTime, endTime, UserSet.IMPORTED, null, false);
                                    }
                                    // For removing peaks that are not in the file, if removeMissing = true
                                    trackAdjustedResults.Add(new ResultsKey(fileId.GlobalIndex, groupNode.Id));
                                    foundSample = true;
                                }
                            }
                        }
                    }
                }
                if (!foundSample)
                {
                    UnrecognizedChargeStates.Add(new UnrecognizedChargeState(charge, fileName, modifiedPeptideString));
                }
            }
            // Remove peaks from the document that weren't in the file.
            if (removeMissing)
                docNew = RemoveMissing(docNew, trackAdjustedResults, changePeaks);
            // If nothing has changed, return the old Document before ChangeIgnoreChangingChildren was turned off
            if (!ReferenceEquals(docNew, docReference))
                Document = (SrmDocument) Document.ChangeIgnoreChangingChildren(false).ChangeChildrenChecked(docNew.Children);
            return Document;
        }
Example #15
0
        UpdateProgressResponse IProgressMonitor.UpdateProgress(ProgressStatus status)
        {
            UpdateProgress(status);

            return UpdateProgressResponse.normal;
        }
Example #16
0
        private void UpdateProgress(ProgressStatus status)
        {
            if (status.PercentComplete != -1)
            {
                // Stop the waiting thread if it is running.
                _waiting = false;
                if(_waitingThread != null && _waitingThread.IsAlive)
                {
                    _waitingThread.Join();
                }
            }

            var currentTime = DateTime.Now;
            // Show progress at least every 2 seconds and at 100%, if any other percentage
            // output has been shown.
            if ((currentTime - _lastOutput).Seconds < 2 && !status.IsError && (status.PercentComplete != 100 || _lastOutput == _waitStart))
            {
                return;
            }

            bool writeMessage = !string.IsNullOrEmpty(status.Message) &&
                                (_lastMessage == null || !ReferenceEquals(status.Message, _lastMessage));

            if (status.IsError)
            {
                _out.WriteLine(Resources.CommandLine_GeneralException_Error___0_, status.ErrorException.Message);
                writeMessage = false;
            }
            else if (status.PercentComplete == -1)
            {
                _out.Write(Resources.CommandWaitBroker_UpdateProgress_Waiting___);
                _waiting = true;
                // Start a thread that will indicate "waiting" progress to the console every few seconds.
                _waitingThread = new Thread(Wait){IsBackground = true};
                _waitingThread.Start();
            }
            else if (_currentProgress != null && status.PercentComplete != _currentProgress.PercentComplete)
            {
                // If writing a message at the same time as updating percent complete,
                // put them both on the same line
                if (writeMessage)
                    _out.WriteLine("{0}% - {1}", status.PercentComplete, status.Message); // Not L10N
                else
                    _out.WriteLine("{0}%", status.PercentComplete); // Not L10N
            }
            else if (writeMessage)
            {
                _out.WriteLine(status.Message);
            }

            if (writeMessage)
                _lastMessage = status.Message;
            _lastOutput = currentTime;
            _currentProgress = status;
        }
Example #17
0
        private void ExportLiveReport(string reportName, string reportFile, char reportColSeparator, bool reportInvariant)
        {
            var viewContext = DocumentGridViewContext.CreateDocumentGridViewContext(_doc, reportInvariant
                ? DataSchemaLocalizer.INVARIANT
                : SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewInfo = viewContext.GetViewInfo(PersistedViews.MainGroup.Id.ViewName(reportName));
            if (null == viewInfo)
            {
                _out.WriteLine(Resources.CommandLine_ExportLiveReport_Error__The_report__0__does_not_exist__If_it_has_spaces_in_its_name__use__double_quotes__around_the_entire_list_of_command_parameters_, reportName);
                return;
            }
            _out.WriteLine(Resources.CommandLine_ExportLiveReport_Exporting_report__0____, reportName);

            try
            {
                using (var saver = new FileSaver(reportFile))
                {
                    if (!saver.CanSave())
                    {
                        _out.WriteLine(Resources.CommandLine_ExportLiveReport_Error__The_report__0__could_not_be_saved_to__1__, reportName, reportFile);
                        _out.WriteLine(Resources.CommandLine_ExportLiveReport_Check_to_make_sure_it_is_not_read_only_);
                    }

                    var status = new ProgressStatus(string.Empty);
                    IProgressMonitor broker = new CommandProgressMonitor(_out, status);

                    using (var writer = new StreamWriter(saver.SafeName))
                    {
                        viewContext.Export(broker, ref status, viewInfo, writer,
                            new DsvWriter(reportInvariant ? CultureInfo.InvariantCulture : LocalizationHelper.CurrentCulture, reportColSeparator));
                    }

                    broker.UpdateProgress(status.Complete());
                    saver.Commit();
                    _out.WriteLine(Resources.CommandLine_ExportLiveReport_Report__0__exported_successfully_to__1__, reportName, reportFile);
                }
            }
            catch (Exception x)
            {
                _out.WriteLine(Resources.CommandLine_ExportLiveReport_Error__Failure_attempting_to_save__0__report_to__1__, reportName, reportFile);
                _out.WriteLine(x.Message);
            }
        }
Example #18
0
        public CommandProgressMonitor(TextWriter outWriter, ProgressStatus status)
        {
            _out = outWriter;
            _waitStart = _lastOutput = DateTime.Now;

            UpdateProgress(status);
        }
Example #19
0
        private static void ConvertBrukerToMzml(string filePathBruker,
            string outputPath, IProgressMonitor monitor, ProgressStatus status)
        {
            // We use CompassXport, if it is installed, to convert a Bruker raw file to mzML.  This solves two
            // issues: the Bruker reader can't be called on any thread other than the main thread, and there
            // is no 64-bit version of the reader.  So we start CompassXport in its own 32-bit process,
            // and use it to convert the raw data to mzML in a temporary file, which we read back afterwards.
            var key = Registry.LocalMachine.OpenSubKey(KEY_COMPASSXPORT, false);
            string compassXportExe = (key != null) ? (string)key.GetValue(string.Empty) : null;
            if (compassXportExe == null)
                throw new IOException(Resources.VendorIssueHelper_ConvertBrukerToMzml_CompassXport_software_must_be_installed_to_import_Bruker_raw_data_files_);

            // CompassXport arguments
            // ReSharper disable NonLocalizedString
            var argv = new[]
                           {
                               "-a \"" + filePathBruker + "\"",     // input file (directory)
                               "-o \"" + outputPath + "\"",         // output file (directory)
                               "-mode 2",                           // mode 2 (mzML)
                               "-raw 0"                             // export line spectra (profile data is HUGE and SLOW!)
                           };
            // ReSharper restore NonLocalizedString

            // Start CompassXport in its own process.
            var psi = new ProcessStartInfo(compassXportExe)
            {
                CreateNoWindow = true,
                UseShellExecute = false,
                // Common directory includes the directory separator
                WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty,
                Arguments = string.Join(" ", argv), // Not L10N
                RedirectStandardError = true,
                RedirectStandardOutput = true,
            };
            var proc = new Process { StartInfo = psi };
            proc.Start();

            // CompassXport starts by calculating a hash of the input file.  This takes a long time, and there is
            // no intermediate output during this time.  So we set the progress bar some fraction of the way and
            // let it sit there and animate while we wait for the start of spectra processing.
            const int hashPercent = 25; // percentage of import time allocated to calculating the input file hash

            int spectrumCount = 0;

            var sbOut = new StringBuilder();
            var reader = new ProcessStreamReader(proc);
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                if (monitor.IsCanceled)
                {
                    proc.Kill();
                    throw new LoadCanceledException(status.Cancel());
                }

                sbOut.AppendLine(line);
                line = line.Trim();

                // The main part of conversion starts with the hash calculation.
                if (line.StartsWith("Calculating hash")) // Not L10N
                {
                    status = status.ChangeMessage(Resources.VendorIssueHelper_ConvertBrukerToMzml_Calculating_hash_of_input_file)
                        .ChangePercentComplete(hashPercent);
                    monitor.UpdateProgress(status);
                    continue;
                }

                // Determine how many spectra will be converted so we can track progress.
                var match = Regex.Match(line, @"Converting (\d+) spectra"); // Not L10N
                if (match.Success)
                {
                    spectrumCount = int.Parse(match.Groups[1].Value);
                    continue;
                }

                // Update progress as each spectra batch is converted.
                match = Regex.Match(line, @"Spectrum \d+ - (\d+)"); // Not L10N
                if (match.Success)
                {
                    var spectrumEnd = int.Parse(match.Groups[1].Value);
                    var percentComplete = hashPercent + (100-hashPercent)*spectrumEnd/spectrumCount;
                    status = status.ChangeMessage(line).ChangePercentComplete(percentComplete);
                    monitor.UpdateProgress(status);
                }
            }

            while (!proc.WaitForExit(200))
            {
                if (monitor.IsCanceled)
                {
                    proc.Kill();
                    throw new LoadCanceledException(status.Cancel());
                }
            }

            if (proc.ExitCode != 0)
            {
                throw new IOException(TextUtil.LineSeparate(string.Format(Resources.VendorIssueHelper_ConvertBrukerToMzml_Failure_attempting_to_convert__0__to_mzML_using_CompassXport_,
                    filePathBruker), string.Empty, sbOut.ToString()));
            }
        }
Example #20
0
            public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status, TextWriter writer)
            {
                if (shouldCancel)
                {
                    status.Cancel();
                    progress.UpdateProgress(status = status.Cancel());
                    return;
                }

                if (!string.IsNullOrEmpty(stringToWriteToWriter))
                {
                    writer.WriteLine(stringToWriteToWriter);
                }
                status.ChangePercentComplete(100);
                progress.UpdateProgress(status);
            }
Example #21
0
        public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status, TextWriter writer)
        {
            // Make sure required streams are redirected.
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError = true;

            var proc = Process.Start(psi);
            if (proc == null)
                throw new IOException(string.Format("Failure starting {0} command.", psi.FileName)); // Not L10N
            if (stdin != null)
            {
                try
                {
                    proc.StandardInput.Write(stdin);
                }
                finally
                {
                    proc.StandardInput.Close();
                }
            }

            var reader = new ProcessStreamReader(proc);
            StringBuilder sbError = new StringBuilder();
            int percentLast = 0;
            string line;
            while ((line = reader.ReadLine(progress)) != null)
            {
                if (writer != null && !line.StartsWith(HideLinePrefix))
                    writer.WriteLine(line);

                if (progress == null || line.ToLowerInvariant().StartsWith("error")) // Not L10N
                {
                    sbError.AppendLine(line);
                }
                else // if (progress != null)
                {
                    if (progress.IsCanceled)
                    {
                        proc.Kill();
                        progress.UpdateProgress(status = status.Cancel());
                        return;
                    }

                    if (line.EndsWith("%")) // Not L10N
                    {
                        double percent;
                        string[] parts = line.Split(' ');
                        string percentPart = parts[parts.Length - 1];
                        if (double.TryParse(percentPart.Substring(0, percentPart.Length - 1), out percent))
                        {
                            percentLast = (int) percent;
                            status = status.ChangePercentComplete(percentLast);
                            if (percent >= 100 && status.SegmentCount > 0)
                                status = status.NextSegment();
                            progress.UpdateProgress(status);
                        }
                    }
                    else if (MessagePrefix == null || line.StartsWith(MessagePrefix))
                    {
                        // Remove prefix, if there is one.
                        if (MessagePrefix != null)
                            line = line.Substring(MessagePrefix.Length);

                        status = status.ChangeMessage(line);
                        progress.UpdateProgress(status);
                    }
                }
            }
            proc.WaitForExit();
            int exit = proc.ExitCode;
            if (exit != 0)
            {
                line = proc.StandardError.ReadLine();
                if (line != null)
                    sbError.AppendLine(line);
                if (sbError.Length == 0)
                    throw new IOException("Error occurred running process."); // Not L10N
                throw new IOException(sbError.ToString());
            }
            // Make to complete the status, if the process succeeded, but never
            // printed 100% to the console
            if (percentLast < 100)
            {
                status = status.ChangePercentComplete(100);
                if (status.SegmentCount > 0)
                    status = status.NextSegment();
                if (progress != null)
                    progress.UpdateProgress(status);
            }
        }
Example #22
0
            public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status, TextWriter writer)
            {
                if (shouldCancel)
                {
                    status.Cancel();
                    progress.UpdateProgress(status = status.Cancel());
                    return;
                }

                if (!string.IsNullOrEmpty(stringToWriteToWriter))
                    writer.WriteLine(stringToWriteToWriter);
                status.ChangePercentComplete(100);
                progress.UpdateProgress(status);
            }
Example #23
0
 private IrtDb Load(IProgressMonitor loadMonitor, ProgressStatus status)
 {
     var result = ChangeProp(ImClone(this), im => im.LoadPeptides(im.GetPeptides()));
     // Not really possible to show progress, unless we switch to raw reading
     if (loadMonitor != null)
         loadMonitor.UpdateProgress(status.ChangePercentComplete(100));
     return result;
 }
Example #24
0
 public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status)
 {
     Run(psi, stdin, progress, ref status, null);
 }
Example #25
0
        public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status)
        {
            // Make sure required streams are redirected.
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError  = true;

            var proc = Process.Start(psi);

            if (proc == null)
            {
                throw new IOException(string.Format("Failure starting {0} command.", psi.FileName));
            }
            if (stdin != null)
            {
                try
                {
                    proc.StandardInput.Write(stdin);
                }
                finally
                {
                    proc.StandardInput.Close();
                }
            }

            var           reader      = new ProcessStreamReader(proc);
            StringBuilder sbError     = new StringBuilder();
            int           percentLast = 0;
            string        line;

            while ((line = reader.ReadLine()) != null)
            {
                if (progress == null || line.ToLower().StartsWith("error"))
                {
                    sbError.AppendLine(line);
                }
                else // if (progress != null)
                {
                    if (progress.IsCanceled)
                    {
                        proc.Kill();
                        progress.UpdateProgress(status = status.Cancel());
                        return;
                    }

                    if (line.EndsWith("%"))
                    {
                        double   percent;
                        string[] parts       = line.Split(' ');
                        string   percentPart = parts[parts.Length - 1];
                        if (double.TryParse(percentPart.Substring(0, percentPart.Length - 1), out percent))
                        {
                            percentLast = (int)percent;
                            status      = status.ChangePercentComplete(percentLast);
                            if (percent >= 100 && status.SegmentCount > 0)
                            {
                                status = status.NextSegment();
                            }
                            progress.UpdateProgress(status);
                        }
                    }
                    else if (MessagePrefix == null || line.StartsWith(MessagePrefix))
                    {
                        // Remove prefix, if there is one.
                        if (MessagePrefix != null)
                        {
                            line = line.Substring(MessagePrefix.Length);
                        }

                        status = status.ChangeMessage(line);
                        progress.UpdateProgress(status);
                    }
                }
            }
            proc.WaitForExit();
            int exit = proc.ExitCode;

            if (exit != 0)
            {
                line = proc.StandardError.ReadLine();
                if (line != null)
                {
                    sbError.AppendLine(line);
                }
                if (sbError.Length == 0)
                {
                    throw new IOException("Error occurred running process.");
                }
                throw new IOException(sbError.ToString());
            }
            // Make to complete the status, if the process succeeded, but never
            // printed 100% to the console
            else if (percentLast < 100)
            {
                status = status.ChangePercentComplete(100);
                if (status.SegmentCount > 0)
                {
                    status = status.NextSegment();
                }
                if (progress != null)
                {
                    progress.UpdateProgress(status);
                }
            }
        }
        // ReSharper restore NonLocalizedString
        /// <summary>
        /// Executes an export for all chromatograms in the document
        /// with file names matching one of the files in filesToExport
        /// writer = location to write the chromatogram data to
        /// longWaitBroker = progress bar (can be null)
        /// filesToExport = file names for which to write chromatograms
        /// cultureInfo = local culture
        /// chromExtractors = list of special chromatogram types to include (base peak, etc)
        /// chromSources = type of ions to include (precursor, product)
        /// </summary>
        public void Export(TextWriter writer,
            IProgressMonitor longWaitBroker,
            IList<string> filesToExport,
            CultureInfo cultureInfo,
            IList<ChromExtractor> chromExtractors,
            IList<ChromSource> chromSources)
        {
            int currentReplicates = 0;
            int totalReplicates = _chromatogramSets.Count;
            var status = new ProgressStatus(string.Empty);
            FormatHeader(writer, FIELD_NAMES);
            foreach (var chromatograms in _chromatogramSets)
            {
                if (longWaitBroker != null)
                {
                    int percentComplete = currentReplicates++ * 100 / totalReplicates;
                    if (percentComplete < 100)
                    {
                        longWaitBroker.UpdateProgress(status = status.ChangeMessage(string.Format(Resources.ChromatogramExporter_Export_Exporting_Chromatograms_for__0_,
                                                                                    chromatograms.Name)).ChangePercentComplete(percentComplete));
                    }
                }
                foreach (var extractor in chromExtractors)
                {
                    ChromatogramGroupInfo[] arrayChromSpecial;
                    if (!_measuredResults.TryLoadAllIonsChromatogram(chromatograms, extractor, true, out arrayChromSpecial))
                    {
                        // TODO: need error determination here
                        continue;
                    }
                    foreach (var chromInfo in arrayChromSpecial)
                    {
                        string fileName = chromInfo.FilePath.GetFileName();
                        // Skip the files that have not been selected for export
                        if (!filesToExport.Contains(fileName))
                            continue;
                        IList<float> times = chromInfo.Times;
                        IList<float> intensities = chromInfo.IntensityArray[0];
                        float tic = CalculateTic(times, intensities);
                        string extractorName = GetExtractorName(extractor);
                        string[] fieldArray =
                        {
                            fileName,
                            TextUtil.EXCEL_NA,
                            TextUtil.EXCEL_NA,
                            TextUtil.EXCEL_NA,
                            extractorName,
                            TextUtil.EXCEL_NA,
                            TextUtil.EXCEL_NA,
                            System.Convert.ToString(tic, cultureInfo)
                        };
                        FormatChromLine(writer, fieldArray, times, intensities, cultureInfo);

                    }
                }
                foreach (var peptideNode in Document.Molecules)
                {
                    foreach (TransitionGroupDocNode groupNode in peptideNode.Children)
                        ExportGroupNode(peptideNode, groupNode, chromatograms, filesToExport, chromSources, writer, cultureInfo);
                }
            }
        }
Example #27
0
        public SrmSettingsChangeMonitor(IProgressMonitor progressMonitor, string formatString,
            IDocumentContainer documentContainer = null, SrmDocument startDocument = null)
        {
            _progressMonitor = progressMonitor;
            _documentContainer = documentContainer;
            _startDocument = startDocument;
            if (_startDocument == null && documentContainer != null)
                _startDocument = documentContainer.Document;

            if (!formatString.Contains('{'))
                _status = new ProgressStatus(formatString);
            else
            {
                _formatString = formatString;
                // Set status string to empty, since it should be reset very quickly
                _status = new ProgressStatus(string.Empty);
            }
        }
Example #28
0
 public void Run(ProcessStartInfo psi, string stdin, IProgressMonitor progress, ref ProgressStatus status)
 {
     Run(psi, stdin, progress,ref status, null);
 }
Example #29
0
 public void Dispose()
 {
     if (_seenGroupCount + _seenMoleculeCount > 0)
         _progressMonitor.UpdateProgress(_status = _status.Complete());
 }
Example #30
0
 private string GetReportRows(SrmDocument document, ViewSpec viewSpec, IProgressMonitor progressMonitor)
 {
     var container = new MemoryDocumentContainer();
     container.SetDocument(document, container.Document);
     var dataSchema = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
     var viewContext = new DocumentGridViewContext(dataSchema);
     var status = new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
         viewSpec.Name));
     var writer = new StringWriter();
     if (viewContext.Export(progressMonitor, ref status, viewContext.GetViewInfo(null, viewSpec), writer,
         new DsvWriter(CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV)))
     {
         return writer.ToString();
     }
     return null;
 }
Example #31
0
 public void ProcessGroup(PeptideGroupDocNode nodeGroup)
 {
     bool messageChange = _formatString != null;
     if (messageChange)
         _status = _status.ChangeMessage(string.Format(_formatString, nodeGroup.Name));
     int? percentComplete = ProgressStatus.ThreadsafeIncementPercent(ref _seenGroupCount, GroupCount);
     UpdateProgress(percentComplete, messageChange);
 }
Example #32
0
        // ReSharper restore NonLocalizedString
        public static List<string> ConvertPilotFiles(IList<string> inputFiles, IProgressMonitor progress, ProgressStatus status)
        {
            string groupConverterExePath = null;
            var inputFilesPilotConverted = new List<string>();

            for (int index = 0; index < inputFiles.Count; index++)
            {
                string inputFile = inputFiles[index];
                if (!inputFile.EndsWith(BiblioSpecLiteBuilder.EXT_PILOT))
                {
                    inputFilesPilotConverted.Add(inputFile);
                    continue;
                }
                string outputFile = Path.ChangeExtension(inputFile, BiblioSpecLiteBuilder.EXT_PILOT_XML);
                // Avoid re-converting files that have already been converted
                if (File.Exists(outputFile))
                {
                    // Avoid duplication, in case the user accidentally adds both .group and .group.xml files
                    // for the same results
                    if (!inputFiles.Contains(outputFile))
                        inputFilesPilotConverted.Add(outputFile);
                    continue;
                }

                string message = string.Format(Resources.VendorIssueHelper_ConvertPilotFiles_Converting__0__to_xml, Path.GetFileName(inputFile));
                int percent = index * 100 / inputFiles.Count;
                progress.UpdateProgress(status = status.ChangeMessage(message).ChangePercentComplete(percent));

                if (groupConverterExePath == null)
                {
                    var key = Registry.LocalMachine.OpenSubKey(KEY_PROTEIN_PILOT, false);
                    if (key != null)
                    {
                        string proteinPilotCommandWithArgs = (string)key.GetValue(string.Empty);

                        var proteinPilotCommandWithArgsSplit =
                            proteinPilotCommandWithArgs.Split(new[] { "\" \"" }, StringSplitOptions.RemoveEmptyEntries);     // Remove " "%1" // Not L10N
                        string path = Path.GetDirectoryName(proteinPilotCommandWithArgsSplit[0].Trim(new[] { '\\', '\"' })); // Remove preceding "
                        if (path != null)
                        {
                            var groupFileExtractorPath = Path.Combine(path, EXE_GROUP_FILE_EXTRACTOR);
                            if (File.Exists(groupFileExtractorPath))
                            {
                                groupConverterExePath = groupFileExtractorPath;
                            }
                            else
                            {
                                var group2XmlPath = Path.Combine(path, EXE_GROUP2_XML);
                                if (File.Exists(group2XmlPath))
                                {
                                    groupConverterExePath = group2XmlPath;
                                }
                                else
                                {
                                    string errorMessage = string.Format(Resources.VendorIssueHelper_ConvertPilotFiles_Unable_to_find__0__or__1__in_directory__2____Please_reinstall_ProteinPilot_software_to_be_able_to_handle__group_files_,
                                        EXE_GROUP_FILE_EXTRACTOR, EXE_GROUP2_XML, path);
                                    throw new IOException(errorMessage);
                                }
                            }
                        }
                    }

                    if (groupConverterExePath == null)
                    {
                        throw new IOException(Resources.VendorIssueHelper_ConvertPilotFiles_ProteinPilot_software__trial_or_full_version__must_be_installed_to_convert___group__files_to_compatible___group_xml__files_);
                    }
                }

                // run group2xml
                // ReSharper disable NonLocalizedString
                var argv = new[]
                               {
                                   "XML",
                                   "\"" + inputFile + "\"",
                                   "\"" + outputFile + "\""
                               };
                // ReSharper restore NonLocalizedString

                var psi = new ProcessStartInfo(groupConverterExePath)
                              {
                                  CreateNoWindow = true,
                                  UseShellExecute = false,
                                  // Common directory includes the directory separator
                                  WorkingDirectory = Path.GetDirectoryName(groupConverterExePath) ?? string.Empty,
                                  Arguments = string.Join(" ", argv.ToArray()), // Not L10N
                                  RedirectStandardError = true,
                                  RedirectStandardOutput = true,
                              };

                var sbOut = new StringBuilder();
                var proc = new Process {StartInfo = psi};
                proc.Start();

                var reader = new ProcessStreamReader(proc);
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (progress.IsCanceled)
                    {
                        proc.Kill();
                        throw new LoadCanceledException(status.Cancel());
                    }

                    sbOut.AppendLine(line);
                }

                while (!proc.WaitForExit(200))
                {
                    if (progress.IsCanceled)
                    {
                        proc.Kill();
                        return inputFilesPilotConverted;
                    }
                }

                if (proc.ExitCode != 0)
                {
                    throw new IOException(TextUtil.LineSeparate(string.Format(Resources.VendorIssueHelper_ConvertPilotFiles_Failure_attempting_to_convert_file__0__to__group_xml_,
                                                        inputFile), string.Empty, sbOut.ToString()));
                }

                inputFilesPilotConverted.Add(outputFile);
            }
            progress.UpdateProgress(status.ChangePercentComplete(100));
            return inputFilesPilotConverted;
        }
Example #33
0
        /// <summary>
        /// This function will add the given replicate, from dataFile, to the given document. If the replicate
        /// does not exist, it will be added. If it does exist, it will be appended to.
        /// </summary>
        public static SrmDocument ImportResults(SrmDocument doc, string docPath, string replicate, MsDataFileUri dataFile,
            OptimizableRegression optimize, IProgressMonitor progressMonitor, out ProgressStatus status)
        {
            using (var docContainer = new ResultsMemoryDocumentContainer(null, docPath) {ProgressMonitor = progressMonitor})
            {
                // Make sure library loading happens, which may not happen, if the doc
                // parameter is used as the baseline document.
                docContainer.SetDocument(doc, null);

                SrmDocument docAdded;
                do
                {
                    doc = docContainer.Document;

                    var listChromatograms = new List<ChromatogramSet>();

                    if (doc.Settings.HasResults)
                        listChromatograms.AddRange(doc.Settings.MeasuredResults.Chromatograms);

                    int indexChrom = listChromatograms.IndexOf(chrom => chrom.Name.Equals(replicate));
                    if (indexChrom != -1)
                    {
                        var chromatogram = listChromatograms[indexChrom];
                        var paths = chromatogram.MSDataFilePaths;
                        var listFilePaths = paths.ToList();
                        listFilePaths.Add(dataFile);
                        listChromatograms[indexChrom] = chromatogram.ChangeMSDataFilePaths(listFilePaths);
                    }
                    else
                    {
                        listChromatograms.Add(new ChromatogramSet(replicate, new[] {dataFile.Normalize()},
                            Annotations.EMPTY, optimize));
                    }

                    var results = doc.Settings.HasResults
                                      ? doc.Settings.MeasuredResults.ChangeChromatograms(listChromatograms)
                                      : new MeasuredResults(listChromatograms, doc.Settings.IsResultsJoiningDisabled);

                    docAdded = doc.ChangeMeasuredResults(results);
                }
                while (!docContainer.SetDocument(docAdded, doc, true));

                status = docContainer.LastProgress;

                return docContainer.Document;
            }
        }