public void Dispose() { if (ScanProvider != null) { ScanProvider.Dispose(); } ScanProvider = null; }
/// <summary> /// Return a collisional cross section for this ion mobility at this mz, if reader supports this /// </summary> public double?CCSFromIonMobility(IonMobilityValue ionMobility, double mz, int charge) { if (ScanProvider == null) { return(null); } return(ScanProvider.CCSFromIonMobility(ionMobility, mz, charge)); }
public void UpdateScanProvider(IScanProvider scanProvider, int transitionIndex, int scanIndex) { ScanProvider.SetScanProvider(scanProvider); if (scanProvider != null) { Source = scanProvider.Transitions[transitionIndex].Source; Assume.IsTrue(Source == ScanProvider.Source); TransitionIndex = transitionIndex; ScanIndex = scanIndex; FileName = scanProvider.DataFilePath.GetFileName(); } else { MsDataSpectra = null; FileName = null; } }
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); }
/// <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); }
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; }