Example #1
0
        public List <XYPair> GetIMSScanProfileFromRawData(DataReader uimfReader, UIMFData.FrameType frameType, double binWidth, double calibrationSlope, double calibrationIntercept)
        {
            GetMinAndMaxScanLCAndScanIMSAndMSFeatureRep(
                out var scanLCMinimum, out var scanLCMaximum,
                out var scanIMSMinimum, out var scanIMSMaximum, out var msFeatureRep);

            // double currentFWHM = msFeatureRep.Fwhm;
            // var currentMonoMZ = msFeatureRep.MassMonoisotopic/msFeatureRep.Charge + 1.0072649;
            var mzMostAbundantIsotope = msFeatureRep.MassMostAbundantIsotope / msFeatureRep.Charge + 1.00727649;


            ////[gord] the following commented-out code sets the m/z range too wide. Can be removed later
            //List<double> startMZ = new List<double>();
            //List<double> endMZ = new List<double>();

            //// Set ranges over which to look for the original data in the UIMF.
            //double charge = Convert.ToDouble(this.Charge);
            //for (int i = 0; i < 3; i++)
            //{
            //    startMZ.Add(currentMonoMZ + (1.003 * i / charge) - (0.5 * currentFWHM));
            //    endMZ.Add(currentMonoMZ + (1.003 * i / charge) + (0.5 * currentFWHM));
            //}

            //double minMZ = startMZ[0];
            //double maxMZ = endMZ[endMZ.Count - 1];

            //double midPointMZ = (maxMZ + minMZ) / 2;
            //double wideToleranceInMZ = midPointMZ - minMZ;

            var frameMinimum = ScanLCMap.Mapping[scanLCMinimum];
            var frameMaximum = ScanLCMap.Mapping[scanLCMaximum];


            int[] scanValues      = null;
            int[] intensityValues = null;

            var sigma         = msFeatureRep.Fwhm / 2.35;
            var toleranceInMZ = 2 * sigma;     //  this is a +/- value;  so    4* sigma = 95% of a normal distribution

            //Before: a wide m/z was used when generating the drift time profile.
            //uimfReader.GetDriftTimeProfile(frameIndexMinimum, frameIndexMaximum, frameType, scanIMSMinimum, scanIMSMaximum, midPointMZ, wideToleranceInMZ, ref scanValues, ref intensityValues);

            //now:  a narrow m/z range is used when generating the drift time profile
            uimfReader.GetDriftTimeProfile(frameMinimum, frameMaximum, frameType, scanIMSMinimum, scanIMSMaximum, mzMostAbundantIsotope, toleranceInMZ, ref scanValues, ref intensityValues);

            var imsScanProfile = intensityValues.Select((t, i) => new XYPair(scanIMSMinimum + i, t)).ToList();

            ConformationDetection.PadXYPairsWithZeros(ref imsScanProfile, 5);

            return(imsScanProfile);
        }
 public List <IntensityPoint> GetXic(int targetBin, UIMFData.FrameType frameType)
 {
     return(UimfReader.GetXic(targetBin, frameType));
 }
 // ReSharper disable once UnusedMember.Global
 public List <IntensityPoint> GetXic(double targetMz, double tolerance, UIMFData.FrameType frameType, int scanLcMin, int scanLcMax, int scanImsMin, int scanImsMax, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXic(targetMz, tolerance, scanLcMin, scanLcMax, scanImsMin, scanImsMax, frameType, toleranceType));
 }
 public List <IntensityPoint> GetXic(double targetMz, double tolerance, UIMFData.FrameType frameType, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXic(targetMz, tolerance, frameType, toleranceType));
 }
 // ReSharper disable once UnusedMember.Global
 public double[,] GetXicAsArray(int targetBin, UIMFData.FrameType frameType)
 {
     return(UimfReader.GetXicAsArray(targetBin, frameType));
 }
 public double[,] GetXicAsArray(double targetMz, double tolerance, UIMFData.FrameType frameType, int scanLcMin, int scanLcMax, int scanImsMin, int scanImsMax, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXicAsArray(targetMz, tolerance, scanLcMin, scanLcMax, scanImsMin, scanImsMax, frameType, toleranceType));
 }
 public double[,] GetXicAsArray(double targetMz, double tolerance, UIMFData.FrameType frameType, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXicAsArray(targetMz, tolerance, frameType, toleranceType));
 }
        public IDictionary <double, IEnumerable <FeatureBlobStatistics> > GetFeatureStatistics(IEnumerable <double> targetMzList, double tolerance, UIMFData.FrameType frameType, DataReader.ToleranceType toleranceType)
        {
            var resultDictionary = new Dictionary <double, IEnumerable <FeatureBlobStatistics> >();

            Parallel.ForEach(targetMzList, m_parallelOptions, targetMz =>
            {
                // Grab a UIMF Util object from the stack
                m_uimfUtilStack.TryPop(out var uimfUtil);

                // Do Feature Finding
                var intensityBlock = uimfUtil.GetXic(targetMz, tolerance, frameType, toleranceType);
                var pointList      = WaterShedMapUtil.BuildWatershedMap(intensityBlock);
                m_smoother.Smooth(ref pointList);
                var featureList = FeatureDetection.DoWatershedAlgorithm(pointList);

                // Add result to dictionary
                resultDictionary.Add(targetMz, featureList.Select(featureBlob => featureBlob.CalculateStatistics()).ToArray());

                // Push the UIMF Util object back onto the stack when we are done with it
                m_uimfUtilStack.Push(uimfUtil);
            });

            return(resultDictionary);
        }