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); }
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; }