예제 #1
0
        /// <summary>
        /// Release a chromatogram if its collector is complete (indicated by retention time).
        /// </summary>
        /// <returns>-1 if chromatogram is not finished yet.</returns>
        public int ReleaseChromatogram(
            int chromatogramIndex, float retentionTime, ChromCollector collector,
            out TimeIntensities timeIntensities)
        {
            int groupIndex = GetGroupIndex(chromatogramIndex);
            var spillFile  = _spillFiles[groupIndex];

            // Not done reading yet.
            if (retentionTime < spillFile.MaxTime || (collector != null && !collector.IsSetTimes))
            {
                timeIntensities = null;
                return(-1);
            }

            // No chromatogram information collected.
            if (collector == null)
            {
                timeIntensities = TimeIntensities.EMPTY;
                return(0);
            }

            if (ReferenceEquals(_cachedSpillFile, spillFile))
            {
                if (spillFile.Stream != null)
                {
                    if (_bytesFromSpillFile == null || spillFile.Stream.Length != _bytesFromSpillFile.Length)
                    {
                        // Need to reread spill file if more bytes were written since the time it was cached.
                        _cachedSpillFile = null;
                    }
                }
            }

            if (!ReferenceEquals(_cachedSpillFile, spillFile))
            {
                _cachedSpillFile    = spillFile;
                _bytesFromSpillFile = null;
                var fileStream = spillFile.Stream;
                if (fileStream != null)
                {
                    fileStream.Seek(0, SeekOrigin.Begin);
                    _bytesFromSpillFile = new byte[fileStream.Length];
                    int bytesRead = fileStream.Read(_bytesFromSpillFile, 0, _bytesFromSpillFile.Length);
                    Assume.IsTrue(bytesRead == _bytesFromSpillFile.Length);
                    // TODO: Would be nice to have something that releases spill files progressively, as they are
                    //       no longer needed.
                    // spillFile.CloseStream();
                }
            }
            collector.ReleaseChromatogram(_bytesFromSpillFile, out timeIntensities);

            return(collector.StatusId);
        }
예제 #2
0
        /// <summary>
        /// Release a chromatogram if its collector is complete (indicated by retention time).
        /// </summary>
        /// <returns>-1 if chromatogram is not finished yet.</returns>
        public int ReleaseChromatogram(
            int chromatogramIndex, float retentionTime, ChromCollector collector,
            out float[] times, out float[] intensities, out float[] massErrors, out int[] scanIds)
        {
            int groupIndex = GetGroupIndex(chromatogramIndex);
            var spillFile  = _spillFiles[groupIndex];

            // Not done reading yet.
            if (retentionTime < spillFile.MaxTime)
            {
                times       = null;
                intensities = null;
                massErrors  = null;
                scanIds     = null;
                return(-1);
            }

            // No chromatogram information collected.
            if (collector == null)
            {
                times       = EMPTY_FLOAT_ARRAY;
                intensities = EMPTY_FLOAT_ARRAY;
                massErrors  = null;
                scanIds     = null;
                return(0);
            }

            if (!ReferenceEquals(_cachedSpillFile, spillFile))
            {
                _cachedSpillFile    = spillFile;
                _bytesFromSpillFile = null;
                var fileStream = spillFile.Stream;
                if (fileStream != null)
                {
                    fileStream.Seek(0, SeekOrigin.Begin);
                    _bytesFromSpillFile = new byte[fileStream.Length];
                    int bytesRead = fileStream.Read(_bytesFromSpillFile, 0, _bytesFromSpillFile.Length);
                    Assume.IsTrue(bytesRead == _bytesFromSpillFile.Length);
                    // TODO: Would be nice to have something that releases spill files progressively, as they are
                    //       no longer needed.
                    // spillFile.CloseStream();
                }
            }
            collector.ReleaseChromatogram(_bytesFromSpillFile, out times, out intensities, out massErrors, out scanIds);

            return(collector.StatusId);
        }