Beispiel #1
0
        public bool Adopt(IScanProvider other)
        {
            if (!Equals(DocFilePath, other.DocFilePath) || !Equals(DataFilePath, other.DataFilePath))
            {
                return(false);
            }
            var scanProvider = other as ScanProvider;

            if (scanProvider == null)
            {
                return(false);
            }
            MeasuredResults thisMeasuredResults, otherMeasuredResults;

            if (!_measuredResultsReference.TryGetTarget(out thisMeasuredResults) ||
                !scanProvider._measuredResultsReference.TryGetTarget(out otherMeasuredResults))
            {
                return(false);
            }
            if (!ReferenceEquals(thisMeasuredResults, otherMeasuredResults))
            {
                return(false);
            }
            _dataFile              = scanProvider._dataFile;
            _msDataFileScanIds     = scanProvider._msDataFileScanIds;
            _getMsDataFileScanIds  = scanProvider._getMsDataFileScanIds;
            scanProvider._dataFile = null;
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve a run of raw spectra with common retention time and changing ion mobility, or a single raw spectrum if no drift info
        /// </summary>
        /// <param name="internalScanIndex">an index in pwiz.Skyline.Model.Results space</param>
        /// <returns>Array of spectra with the same retention time (potentially different ion mobility values for IMS, or just one spectrum)</returns>
        public MsDataSpectrum[] GetMsDataFileSpectraWithCommonRetentionTime(int internalScanIndex)
        {
            var spectra = new List <MsDataSpectrum>();

            if (_getMsDataFileScanIds != null)
            {
                _msDataFileScanIds    = _getMsDataFileScanIds();
                _getMsDataFileScanIds = null;
            }
            int dataFileSpectrumStartIndex = internalScanIndex;

            // For backward compatibility support SKYD files that did not store scan ID bytes
            if (_msDataFileScanIds != null)
            {
                var scanIdText = _msDataFileScanIds.GetMsDataFileSpectrumId(internalScanIndex);
                dataFileSpectrumStartIndex = GetDataFile().GetSpectrumIndex(scanIdText);
                if (dataFileSpectrumStartIndex == -1)
                {
                    // try without combining ion mobility (if it's turned on)
                    dataFileSpectrumStartIndex = GetDataFile(false).GetSpectrumIndex(scanIdText);
                    if (dataFileSpectrumStartIndex == -1)
                    {
                        throw new IOException(string.Format(Resources.ScanProvider_GetScans_The_scan_ID__0__was_not_found_in_the_file__1__, scanIdText, DataFilePath.GetFileName()));
                    }
                }
            }
            var currentSpectrum = GetDataFile().GetSpectrum(dataFileSpectrumStartIndex);

            spectra.Add(currentSpectrum);
            if (currentSpectrum.IonMobility.HasValue)
            {
                // Look for spectra with identical retention time and changing ion mobility values
                while (true)
                {
                    dataFileSpectrumStartIndex++;
                    var nextSpectrum = GetDataFile().GetSpectrum(dataFileSpectrumStartIndex);
                    if (!nextSpectrum.IonMobility.HasValue ||
                        nextSpectrum.RetentionTime != currentSpectrum.RetentionTime)
                    {
                        break;
                    }
                    spectra.Add(nextSpectrum);
                    currentSpectrum = nextSpectrum;
                }
            }
            return(spectra.ToArray());
        }
Beispiel #3
0
        /// <summary>
        /// Retrieve a run of raw spectra with common retention time and changing ion mobility, or a single raw spectrum if no drift info
        /// </summary>
        /// <param name="internalScanIndex">an index in pwiz.Skyline.Model.Results space</param>
        /// <param name="ignoreZeroIntensityPoints">display uses want zero intensity points, data processing uses typically do not</param>
        /// <returns>Array of spectra with the same retention time (potentially different ion mobility values for IMS, or just one spectrum)</returns>
        public MsDataSpectrum[] GetMsDataFileSpectraWithCommonRetentionTime(int internalScanIndex, bool ignoreZeroIntensityPoints)
        {
            var spectra = new List <MsDataSpectrum>();

            if (_measuredResults != null)
            {
                _msDataFileScanIds = _measuredResults.LoadMSDataFileScanIds(DataFilePath, out _cachedFile);
                _measuredResults   = null;
            }
            int dataFileSpectrumStartIndex = internalScanIndex;

            // For backward compatibility support SKYD files that did not store scan ID bytes
            if (_msDataFileScanIds != null)
            {
                var scanIdText = _msDataFileScanIds.GetMsDataFileSpectrumId(internalScanIndex);
                dataFileSpectrumStartIndex = GetDataFile(ignoreZeroIntensityPoints).GetSpectrumIndex(scanIdText);
                // TODO(brendanx): Improve this error message post-UI freeze
//                if (dataFileSpectrumStartIndex == -1)
//                    throw new ArgumentException(string.Format("The stored scan ID {0} was not found in the file {1}.", scanIdText, DataFilePath));
            }
            var currentSpectrum = GetDataFile(ignoreZeroIntensityPoints).GetSpectrum(dataFileSpectrumStartIndex);

            spectra.Add(currentSpectrum);
            if (currentSpectrum.IonMobilities != null)  // Sort combined IMS spectra by m/z order
            {
                ArrayUtil.Sort(currentSpectrum.Mzs, currentSpectrum.Intensities, currentSpectrum.IonMobilities);
            }
            else if (currentSpectrum.IonMobility.HasValue) // Look ahead for uncombined IMS spectra
            {
                // Look for spectra with identical retention time and changing ion mobility values
                while (true)
                {
                    dataFileSpectrumStartIndex++;
                    var nextSpectrum = GetDataFile(ignoreZeroIntensityPoints).GetSpectrum(dataFileSpectrumStartIndex);
                    if (!nextSpectrum.IonMobility.HasValue ||
                        nextSpectrum.RetentionTime != currentSpectrum.RetentionTime)
                    {
                        break;
                    }
                    spectra.Add(nextSpectrum);
                    currentSpectrum = nextSpectrum;
                }
            }
            return(spectra.ToArray());
        }
Beispiel #4
0
        public bool Adopt(IScanProvider other)
        {
            if (!Equals(DocFilePath, other.DocFilePath) || !Equals(DataFilePath, other.DataFilePath))
            {
                return(false);
            }
            var scanProvider = other as ScanProvider;

            if (scanProvider == null)
            {
                return(false);
            }
            _dataFile              = scanProvider._dataFile;
            _msDataFileScanIds     = scanProvider._msDataFileScanIds;
            _getMsDataFileScanIds  = scanProvider._getMsDataFileScanIds;
            scanProvider._dataFile = null;
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Retrieve a run of raw spectra with common retention time and changing ion mobility, or a single raw spectrum if no drift info
        /// </summary>
        /// <param name="internalScanIndex">an index in pwiz.Skyline.Model.Results space</param>
        /// <param name="ignoreZeroIntensityPoints">display uses want zero intensity points, data processing uses typically do not</param>
        /// <returns>Array of spectra with the same retention time (potentially different ion mobility values for IMS, or just one spectrum)</returns>
        public MsDataSpectrum[] GetMsDataFileSpectraWithCommonRetentionTime(int internalScanIndex, bool ignoreZeroIntensityPoints)
        {
            var spectra = new List <MsDataSpectrum>();

            if (_getMsDataFileScanIds != null)
            {
                _msDataFileScanIds    = _getMsDataFileScanIds();
                _getMsDataFileScanIds = null;
            }
            int dataFileSpectrumStartIndex = internalScanIndex;

            // For backward compatibility support SKYD files that did not store scan ID bytes
            if (_msDataFileScanIds != null)
            {
                var scanIdText = _msDataFileScanIds.GetMsDataFileSpectrumId(internalScanIndex);
                dataFileSpectrumStartIndex = GetDataFile(ignoreZeroIntensityPoints).GetSpectrumIndex(scanIdText);
            }
            var currentSpectrum = GetDataFile(ignoreZeroIntensityPoints).GetSpectrum(dataFileSpectrumStartIndex);

            if (currentSpectrum.IonMobilities != null)
            {
                ArrayUtil.Sort(currentSpectrum.Mzs, currentSpectrum.Intensities, currentSpectrum.IonMobilities); // Sort in m/z order
            }
            spectra.Add(currentSpectrum);
            if (currentSpectrum.IonMobilities == null && // No need to look ahead for 3-array IMS representation
                currentSpectrum.IonMobility.HasValue)
            {
                // Look for spectra with identical retention time and changing ion mobility values
                while (true)
                {
                    dataFileSpectrumStartIndex++;
                    var nextSpectrum = GetDataFile(ignoreZeroIntensityPoints).GetSpectrum(dataFileSpectrumStartIndex);
                    if (!nextSpectrum.IonMobility.HasValue ||
                        nextSpectrum.RetentionTime != currentSpectrum.RetentionTime)
                    {
                        break;
                    }
                    spectra.Add(nextSpectrum);
                    currentSpectrum = nextSpectrum;
                }
            }
            return(spectra.ToArray());
        }
Beispiel #6
0
 /// <summary>
 /// Retrieve a run of raw spectra with common retention time and increasing drift times, or a single raw spectrum if no drift info
 /// </summary>
 /// <param name="internalScanIndex">an index in pwiz.Skyline.Model.Results space</param>
 /// <returns>Array of spectra with the same retention time (potentially different drift times for IMS, or just one spectrum)</returns>
 public MsDataSpectrum[] GetMsDataFileSpectraWithCommonRetentionTime(int internalScanIndex)
 {
     var spectra = new List<MsDataSpectrum>();
     if (_getMsDataFileScanIds != null)
     {
         _msDataFileScanIds = _getMsDataFileScanIds();
         _getMsDataFileScanIds = null;
     }
     int dataFileSpectrumStartIndex = internalScanIndex;
     // For backward compatibility support SKYD files that did not store scan ID bytes
     if (_msDataFileScanIds != null)
     {
         var scanIdText = _msDataFileScanIds.GetMsDataFileSpectrumId(internalScanIndex);
         dataFileSpectrumStartIndex = GetDataFile().GetSpectrumIndex(scanIdText);
         if (dataFileSpectrumStartIndex == -1)
             throw new IOException(string.Format(Resources.ScanProvider_GetScans_The_scan_ID__0__was_not_found_in_the_file__1__, scanIdText, DataFilePath.GetFileName()));
     }
     var currentSpectrum = GetDataFile().GetSpectrum(dataFileSpectrumStartIndex);
     spectra.Add(currentSpectrum);
     if (currentSpectrum.DriftTimeMsec.HasValue)
     {
         // Look for spectra with identical retention time and increasing drift time
         while (true)
         {
             dataFileSpectrumStartIndex++;
             var nextSpectrum = GetDataFile().GetSpectrum(dataFileSpectrumStartIndex);
             if (!nextSpectrum.DriftTimeMsec.HasValue ||
                 nextSpectrum.RetentionTime != currentSpectrum.RetentionTime)
             {
                 break;
             }
             spectra.Add(nextSpectrum);
             currentSpectrum = nextSpectrum;
         }
     }
     return spectra.ToArray();
 }
Beispiel #7
0
 public bool Adopt(IScanProvider other)
 {
     if (!Equals(DocFilePath, other.DocFilePath) || !Equals(DataFilePath, other.DataFilePath))
         return false;
     var scanProvider = other as ScanProvider;
     if (scanProvider == null)
         return false;
     _dataFile = scanProvider._dataFile;
     _msDataFileScanIds = scanProvider._msDataFileScanIds;
     _getMsDataFileScanIds = scanProvider._getMsDataFileScanIds;
     scanProvider._dataFile = null;
     return true;
 }