示例#1
0
        public override TimeIntensitiesGroup Truncate(float newStartTime, float newEndTime)
        {
            InterpolationParams interpolationParams;

            if (InterpolationParams == null)
            {
                interpolationParams = null;
            }
            else
            {
                var interpolatedTimes = GetInterpolatedTimes();
                int startIndex        = CollectionUtil.BinarySearch(interpolatedTimes, newStartTime);
                if (startIndex < 0)
                {
                    startIndex = ~startIndex - 1;
                }
                int endIndex = CollectionUtil.BinarySearch(interpolatedTimes, newEndTime);
                if (endIndex < 0)
                {
                    endIndex = ~endIndex;
                }
                startIndex          = Math.Max(startIndex, 0);
                endIndex            = Math.Min(Math.Max(startIndex, endIndex), interpolatedTimes.Count - 1);
                interpolationParams = InterpolationParams
                                      .ChangeStartTime(interpolatedTimes[startIndex])
                                      .ChangeEndTime(interpolatedTimes[endIndex])
                                      .ChangeNumPoints(endIndex - startIndex + 1);
            }
            return(new RawTimeIntensities(
                       TransitionTimeIntensities.Select(timeIntensities => timeIntensities.Truncate(newStartTime, newEndTime)),
                       interpolationParams));
        }
示例#2
0
 public ImmutableList <float> GetInterpolatedTimes()
 {
     if (InterpolationParams == null)
     {
         return(TransitionTimeIntensities.First().Times);
     }
     return(ImmutableList.ValueOf(InterpolationParams.GetEvenlySpacedTimesFloat()));
 }
示例#3
0
        public static RawTimeIntensities FromChromatogramGroupData(ChromatogramGroupData chromatogramGroupData)
        {
            var timeIntensitiesList = new List <TimeIntensities>();
            var timeLists           = chromatogramGroupData.TimeLists.Select(timeList => ImmutableList.ValueOf(timeList.Times)).ToArray();
            var scanIdLists         = chromatogramGroupData.ScanIdLists
                                      .Select(scanIdList => ImmutableList.ValueOf(scanIdList.ScanIds)).ToArray();

            foreach (var chromatogram in chromatogramGroupData.Chromatograms)
            {
                IEnumerable <float> massErrors = null;
                if (chromatogram.MassErrors100X.Count > 0)
                {
                    massErrors = chromatogram.MassErrors100X.Select(error => error / 100.0f);
                }
                else if (chromatogram.MassErrorsDeprecated.Count > 0)
                {
                    massErrors = chromatogram.MassErrorsDeprecated;
                }
                var timeIntensities = new TimeIntensities(timeLists[chromatogram.TimeListIndex - 1],
                                                          chromatogram.Intensities,
                                                          massErrors,
                                                          chromatogram.ScanIdListIndex == 0 ? null : scanIdLists[chromatogram.ScanIdListIndex - 1]);
                timeIntensitiesList.Add(timeIntensities);
            }
            InterpolationParams interpolationParams;

            if (chromatogramGroupData.InterpolatedNumPoints == 0)
            {
                interpolationParams = null;
            }
            else
            {
                interpolationParams = new InterpolationParams(chromatogramGroupData.InterpolatedStartTime, chromatogramGroupData.InterpolatedEndTime, chromatogramGroupData.InterpolatedNumPoints, chromatogramGroupData.InterpolatedDelta)
                                      .ChangeInferZeroes(chromatogramGroupData.InferZeroes);
            }
            var rawTimeIntensities = new RawTimeIntensities(timeIntensitiesList, interpolationParams);

            if (chromatogramGroupData.TimeIntervals != null)
            {
                var startTimes = chromatogramGroupData.TimeIntervals.StartTimes;
                var endTimes   = chromatogramGroupData.TimeIntervals.EndTimes;

                var timeIntervals = TimeIntervals.FromIntervals(Enumerable.Range(0, startTimes.Count)
                                                                .Select(i => new KeyValuePair <float, float>(startTimes[i], endTimes[i])));
                rawTimeIntensities = rawTimeIntensities.ChangeTimeIntervals(timeIntervals);
            }

            return(rawTimeIntensities);
        }
示例#4
0
 public RawTimeIntensities(IEnumerable <TimeIntensities> transitionTimeIntensities, InterpolationParams interpolationParams)
     : base(transitionTimeIntensities)
 {
     InterpolationParams = interpolationParams;
 }