Esempio n. 1
0
        /// <summary>
        /// User clicked on a chromatogram.
        /// </summary>
        public void FireClickedChromatogram(GraphPane graphPane)
        {
            if (ClickedChromatogram == null)
                return;

            var clickedItem = (ChromGraphItem) _closestCurve.Tag;
            if (clickedItem.TransitionNode == null)
                return;
            var chromatogramGroupInfo = clickedItem.Chromatogram;

            double displayTime = graphPane.CurveList[FULLSCAN_TRACKING_INDEX][0].X;
            var retentionTime = clickedItem.GetNearestDisplayTime(displayTime);
            if (retentionTime.IsZero)
                return;
            int scanIndex = MsDataFileScanHelper.FindScanIndex(chromatogramGroupInfo, retentionTime.MeasuredTime);
            var transitions = new List<TransitionFullScanInfo>(graphPane.CurveList.Count);
            int transitionIndex = 0;
            foreach (var curve in GetCurveList(graphPane))
            {
                var graphItem = (ChromGraphItem) curve.Tag;
                if (ReferenceEquals(curve, _closestCurve))
                    transitionIndex = transitions.Count;
                var fullScanInfo = graphItem.FullScanInfo;
                transitions.Add(new TransitionFullScanInfo
                {
                    Name = fullScanInfo.ScanName,
                    Source = fullScanInfo.ChromInfo.Source,
                    ScanIndexes = fullScanInfo.ChromInfo.ScanIndexes,
                    Color = curve.Color,
                    PrecursorMz = fullScanInfo.ChromInfo.PrecursorMz,
                    ProductMz = fullScanInfo.ChromInfo.ProductMz,
                    ExtractionWidth = fullScanInfo.ChromInfo.ExtractionWidth,
                    IonMobilityValue = fullScanInfo.ChromInfo.IonMobilityValue,
                    IonMobilityExtractionWidth = fullScanInfo.ChromInfo.IonMobilityExtractionWidth,
                    Id = graphItem.TransitionNode.Id
                });
            }
            IScanProvider scanProvider;
            var chorusUrl = FilePath as ChorusUrl;
            if (null == chorusUrl)
            {
                var measuredResults = DocumentUI.Settings.MeasuredResults;
                scanProvider = new ScanProvider(_documentContainer.DocumentFilePath, FilePath,
                    chromatogramGroupInfo.Source, chromatogramGroupInfo.Times, transitions.ToArray(),
                    () => measuredResults.LoadMSDataFileScanIds(FilePath));
            }
            else
            {
                scanProvider = new ChorusScanProvider(_documentContainer.DocumentFilePath, chorusUrl,
                    chromatogramGroupInfo.Source, chromatogramGroupInfo.Times, transitions.ToArray());
            }
            var e = new ClickedChromatogramEventArgs(
                scanProvider,
                transitionIndex,
                scanIndex);
            ClickedChromatogram(this, e);
        }
Esempio n. 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;
            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;
        }