コード例 #1
0
        // Returns false on cancellation
        private bool ProcessFile(MsDataFileUri filePath)
        {
            var results = _document.Settings.MeasuredResults;

            if (!results.MSDataFilePaths.Contains(filePath))
            {
                return(true); // Nothing to do
            }
            if (_progressStatus != null)
            {
                _progressStatus = _progressStatus.ChangeMessage(filePath.GetFileName());
            }
            _currentDisplayedTransitionGroupDocNode = null;
            var tolerance = (float)_document.Settings.TransitionSettings.Instrument.MzMatchTolerance;

            foreach (var pair in _document.MoleculePrecursorPairs)
            {
                var nodePep   = pair.NodePep;
                var nodeGroup = pair.NodeGroup;
                var libKey    = nodeGroup.GetLibKey(nodePep);
                // Across all replicates for this precursor, note the ion mobility at max intensity for this mz
                for (var i = 0; i < results.Chromatograms.Count; i++)
                {
                    if (_progressMonitor != null && _progressMonitor.IsCanceled)
                    {
                        return(false);
                    }

                    ChromatogramGroupInfo[] chromGroupInfos;
                    results.TryLoadChromatogram(i, nodePep, nodeGroup, tolerance, true, out chromGroupInfos);
                    foreach (var chromInfo in chromGroupInfos.Where(c => Equals(filePath, c.FilePath)))
                    {
                        if (!ProcessChromInfo(filePath, chromInfo, pair, nodeGroup, tolerance, libKey))
                        {
                            return(false); // User cancelled
                        }
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        private bool ProcessMSLevel(MsDataFileUri filePath, int msLevel, IEnumerable <ChromatogramInfo> transitionPointSets,
                                    ChromatogramGroupInfo chromInfo, double?apexRT, TransitionGroupDocNode nodeGroup, LibKey libKey, float tolerance)
        {
            var           transitions = new List <TransitionFullScanInfo>();
            var           chromSource = (msLevel == 1) ? ChromSource.ms1 : ChromSource.fragment;
            IList <float> times       = null;

            foreach (var tranPointSet in transitionPointSets.Where(t => t.Source == chromSource))
            {
                transitions.Add(new TransitionFullScanInfo
                {
                    //Name = tranPointSet.Header.,
                    Source          = chromSource,
                    TimeIntensities = tranPointSet.TimeIntensities,
                    PrecursorMz     = chromInfo.PrecursorMz,
                    ProductMz       = tranPointSet.ProductMz,
                    ExtractionWidth = tranPointSet.ExtractionWidth,
                    //Id = nodeTran.Id
                });
                times = tranPointSet.Times;
            }

            if (!transitions.Any())
            {
                return(true); // Nothing to do at this ms level
            }

            IScanProvider scanProvider = new ScanProvider(_documentFilePath,
                                                          filePath,
                                                          chromSource, times, transitions.ToArray(),
                                                          _document.Settings.MeasuredResults,
                                                          () => _document.Settings.MeasuredResults.LoadMSDataFileScanIds(filePath));

            // Across all spectra at the peak retention time, find the one with max total
            // intensity for the mz's of interest (ie the isotopic distribution) and note its ion mobility.
            var scanIndex = MsDataFileScanHelper.FindScanIndex(times, apexRT.Value);

            _msDataFileScanHelper.UpdateScanProvider(scanProvider, 0, scanIndex);
            _msDataFileScanHelper.MsDataSpectra = null; // Reset
            scanIndex = _msDataFileScanHelper.GetScanIndex();
            _msDataFileScanHelper.ScanProvider.SetScanForBackgroundLoad(scanIndex);
            lock (this)
            {
                while (_msDataFileScanHelper.MsDataSpectra == null && _dataFileScanHelperException == null)
                {
                    if (_progressMonitor != null && _progressMonitor.IsCanceled)
                    {
                        return(false);
                    }
                    Monitor.Wait(this, 500); // Let background loader do its thing
                }
            }
            if (_dataFileScanHelperException != null)
            {
                throw new IOException(TextUtil.LineSeparate(Resources.DriftTimeFinder_HandleLoadScanException_Problem_using_results_to_populate_drift_time_library__, _dataFileScanHelperException.Message), _dataFileScanHelperException);
            }
            if (_progressMonitor != null && !ReferenceEquals(nodeGroup, _currentDisplayedTransitionGroupDocNode))
            {
                // Do this after scan load so first group after file switch doesn't seem laggy
                _progressStatus = _progressStatus.ChangeMessage(TextUtil.LineSeparate(filePath.GetFileName(), nodeGroup.ToString())).
                                  UpdatePercentCompleteProgress(_progressMonitor, _currentStep++, _totalSteps);
                _currentDisplayedTransitionGroupDocNode = nodeGroup;
            }
            EvaluateBestIonMobilityValue(msLevel, libKey, tolerance, transitions);
            return(true);
        }
コード例 #3
0
ファイル: CommandLine.cs プロジェクト: lgatto/proteowizard
        public bool ImportResultsFile(MsDataFileUri replicateFile, string replicateName, DateTime? importBefore, DateTime? importOnOrAfter,
            OptimizableRegression optimize, bool disableJoining = false)
        {
            // Skip if file write time is after importBefore or before importAfter
            try
            {
                var fileLastWriteTime = replicateFile.GetFileLastWriteTime();
                if (importBefore != null && importBefore < fileLastWriteTime)
                {
                    _out.WriteLine(Resources.CommandLine_ImportResultsFile_File_write_date__0__is_after___import_before_date__1___Ignoring___,
                        fileLastWriteTime, importBefore);
                    return true;
                }
                else if (importOnOrAfter != null && importOnOrAfter >= fileLastWriteTime)
                {
                    _out.WriteLine(Resources.CommandLine_ImportResultsFile_File_write_date__0__is_before___import_on_or_after_date__1___Ignoring___, fileLastWriteTime, importOnOrAfter);
                    return true;
                }
            }
            catch (Exception e)
            {
                _out.WriteLine(Resources.CommandLine_ImportResultsInDir_Error__Could_not_get_last_write_time_for_file__0__, replicateFile);
                _out.WriteLine(e);
                return false;
            }

            _out.WriteLine(Resources.CommandLine_ImportResultsFile_Adding_results___);

            // Hack for un-readable RAW files from Thermo instruments.
            if(!CanReadFile(replicateFile))
            {
                _out.WriteLine(Resources.CommandLine_ImportResultsFile_Warning__Cannot_read_file__0____Ignoring___, replicateFile);
                return true;
            }

            //This function will also detect whether the replicate exists in the document
            ProgressStatus status;
            SrmDocument newDoc;
            IProgressMonitor progressMonitor = new CommandProgressMonitor(_out, new ProgressStatus(string.Empty));

            try
            {
                if (disableJoining)
                    _doc = _doc.ChangeSettingsNoDiff(_doc.Settings.ChangeIsResultsJoiningDisabled(true));

                newDoc = ImportResults(_doc,_skylineFile, replicateName, replicateFile, optimize, progressMonitor, out status);
            }
            catch (Exception x)
            {
                _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile);
                _out.WriteLine(x.Message);
                return false;
            }

            status = status ?? new ProgressStatus(string.Empty).Complete();
            if (status.IsError && status.ErrorException != null)
            {
                if (status.ErrorException is MissingDataException)
                {
                    _out.WriteLine(Resources.CommandLine_ImportResultsFile_Warning__Failed_importing_the_results_file__0____Ignoring___, replicateFile);
                    _out.WriteLine(status.ErrorException.Message);
                    return true;
                }
                _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile);
                _out.WriteLine(status.ErrorException.Message);
                return false;
            }
            if (!status.IsComplete || ReferenceEquals(_doc, newDoc))
            {
                _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile);
                return false;
            }

            _doc = newDoc;

            _out.WriteLine(Resources.CommandLine_ImportResultsFile_Results_added_from__0__to_replicate__1__, replicateFile.GetFileName(), replicateName);
            //the file was imported successfully
            _importCount++;
            return true;
        }
コード例 #4
0
ファイル: Chromatogram.cs プロジェクト: lgatto/proteowizard
 public static string GetFileName(MsDataFileUri msDataFileUri)
 {
     return msDataFileUri.GetFileName();
 }
コード例 #5
0
        private bool ProcessMSLevel(MsDataFileUri filePath, int msLevel, IEnumerable<ChromatogramInfo> transitionPointSets,
            ChromatogramGroupInfo chromInfo, double? apexRT, TransitionGroupDocNode nodeGroup, LibKey libKey, float tolerance)
        {
            var transitions = new List<TransitionFullScanInfo>();
            var chromSource = (msLevel == 1) ? ChromSource.ms1 : ChromSource.fragment;
            foreach (var tranPointSet in transitionPointSets.Where(t => t.Source == chromSource))
            {
                transitions.Add(new TransitionFullScanInfo
                {
                    //Name = tranPointSet.Header.,
                    Source = chromSource,
                    ScanIndexes = chromInfo.ScanIndexes,
                    PrecursorMz = chromInfo.PrecursorMz,
                    ProductMz = tranPointSet.ProductMz,
                    ExtractionWidth = tranPointSet.ExtractionWidth,
                    //Id = nodeTran.Id
                });
            }
            var chorusUrl = filePath as ChorusUrl;
            IScanProvider scanProvider;
            if (null == chorusUrl)
            {
                scanProvider = new ScanProvider(_documentFilePath,
                    filePath,
                    chromSource, chromInfo.Times, transitions.ToArray(),
                    () => _document.Settings.MeasuredResults.LoadMSDataFileScanIds(filePath));
            }
            else
            {
                scanProvider = new ChorusScanProvider(_documentFilePath,
                    chorusUrl,
                    chromSource, chromInfo.Times, transitions.ToArray());
            }

            // Across all spectra at the peak retention time, find the one with max total
            // intensity for the mz's of interest (ie the isotopic distribution) and note its drift time.
            var scanIndex = chromInfo.ScanIndexes != null
                ? MsDataFileScanHelper.FindScanIndex(chromInfo, apexRT.Value)
                : -1;
            _msDataFileScanHelper.UpdateScanProvider(scanProvider, 0, scanIndex);
            _msDataFileScanHelper.MsDataSpectra = null; // Reset
            scanIndex = _msDataFileScanHelper.GetScanIndex();
            _msDataFileScanHelper.ScanProvider.SetScanForBackgroundLoad(scanIndex);
            lock (this)
            {
                while (_msDataFileScanHelper.MsDataSpectra == null && _dataFileScanHelperException == null)
                {
                    if (_progressMonitor != null && _progressMonitor.IsCanceled)
                        return false;
                    Monitor.Wait(this, 500); // Let background loader do its thing
                }
            }
            if (_dataFileScanHelperException != null)
            {
                throw new IOException(TextUtil.LineSeparate(Resources.DriftTimeFinder_HandleLoadScanException_Problem_using_results_to_populate_drift_time_library__, _dataFileScanHelperException.Message), _dataFileScanHelperException);
            }
            if (_progressMonitor != null && !ReferenceEquals(nodeGroup, _currentDisplayedTransitionGroupDocNode))
            {
                // Do this after scan load so first group after file switch doesn't seem laggy
                _progressStatus = _progressStatus.ChangeMessage(TextUtil.LineSeparate(filePath.GetFileName(), nodeGroup.ToString())).
                                     UpdatePercentCompleteProgress(_progressMonitor, _currentStep++, _totalSteps);
                _currentDisplayedTransitionGroupDocNode = nodeGroup;
            }
            EvaluateBestDriftTime(msLevel, libKey, tolerance, transitions);
            return true;
        }
コード例 #6
0
        // Returns false on cancellation
        private bool ProcessFile(MsDataFileUri filePath)
        {
            var results = _document.Settings.MeasuredResults;
            if (!results.MSDataFilePaths.Contains(filePath))
                return true; // Nothing to do
            if (_progressStatus != null)
            {
                _progressStatus = _progressStatus.ChangeMessage(filePath.GetFileName());
            }
            _currentDisplayedTransitionGroupDocNode = null;
            var tolerance = (float)_document.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            foreach (var pair in _document.MoleculePrecursorPairs)
            {
                var nodePep = pair.NodePep;
                var nodeGroup = pair.NodeGroup;
                var libKey = new LibKey(nodePep.RawTextId, nodeGroup.PrecursorCharge);
                // Across all replicates for this precursor, note the drift time at max intensity for this mz
                for (var i = 0; i < results.Chromatograms.Count; i++)
                {
                    if (_progressMonitor != null && _progressMonitor.IsCanceled)
                        return false;

                    ChromatogramGroupInfo[] chromGroupInfos;
                    results.TryLoadChromatogram(i, nodePep, nodeGroup, tolerance, true, out chromGroupInfos);
                    foreach (var chromInfo in chromGroupInfos.Where(c => filePath == c.FilePath))
                    {
                        if (!ProcessChromInfo(filePath, chromInfo, pair, nodeGroup, tolerance, libKey))
                            return false; // User cancelled
                    }
                }
            }
            return true;
        }
コード例 #7
0
 public static string GetFileName(MsDataFileUri msDataFileUri)
 {
     return(msDataFileUri.GetFileName());
 }