示例#1
0
        public FeatureSet GetFeatures(int targetBin, DataReader.FrameType frameType)
        {
            List <IntensityPoint> intensityPointList = _uimfUtil.GetXic(targetBin, frameType);
            var features = new FeatureSet(intensityPointList);

            return(features);
        }
示例#2
0
        public FeatureSet GetFeatures(double mz, Tolerance tolerance, DataReader.FrameType frameType)
        {
            var intensityBlock = _uimfUtil.GetXic(mz, tolerance.GetValue(), frameType,
                                                  tolerance.GetUnit() == ToleranceUnit.Ppm ? DataReader.ToleranceType.PPM : DataReader.ToleranceType.Thomson);
            var features = new FeatureSet(intensityBlock);

            return(features);
        }
示例#3
0
        public List <XYPair> GetIMSScanProfileFromRawData(DataReader uimfReader, DataReader.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[] intensityVals = 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 intensityVals);

            //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 intensityVals);

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

            ConformationDetection.PadXYPairsWithZeros(ref imsScanProfile, 5);

            return(imsScanProfile);
        }
示例#4
0
        public void Execute()
        {
            //open and close UIMF file

            if (!File.Exists(mTestUIMFFilePath))
            {
                reportProgress("UIMFFile not found. Input file path was: " + mTestUIMFFilePath);
                return;
            }

            var datareader = new DataReader(mTestUIMFFilePath);

            datareader.ErrorEvent += datareader_ErrorEvent;

            //--------------------------------------------------------------------------Get Global parameters

            var gp = datareader.GetGlobalParams();

            reportProgress();
            reportProgress();
            reportProgress("Displaying some global parameters...");
            reportProgress("NumBins= " + gp.Bins);
            reportProgress("NumFrames= " + gp.NumFrames);

            // Get Frame parameters

            int testFrame = 500;

            if (testFrame > gp.NumFrames)
            {
                testFrame = gp.NumFrames / 2;
            }

            var frameList = datareader.GetMasterFrameList();

            if (!frameList.ContainsKey(testFrame))
            {
                testFrame = frameList.Keys.First();
            }
            var frameParams = datareader.GetFrameParams(testFrame);

            reportProgress();
            reportProgress();

            if (frameParams == null)
            {
                reportProgress("Error: cannot continue the test since could not retrieve frame " + testFrame + " or " + (testFrame - 1));
            }

            reportProgress("Displaying frame parameters for frame " + testFrame);
            reportProgress(TestUtilities.FrameParametersToString(frameParams));

            const DataReader.FrameType frameType = DataReader.FrameType.MS1;

            double[] xvals;
            int[]    yvals;

            // Step through 50 frames
            for (var currentFrame = testFrame / 2; currentFrame < testFrame + 50; currentFrame++)
            {
                if (!frameList.ContainsKey(currentFrame))
                {
                    continue;
                }

                // Get a series of mass spectra (all from the same frame, summing 3 scans)
                for (var imsScan = 125; imsScan < 135; imsScan += 1)
                {
                    var imsScanEnd = imsScan + 3;

                    datareader.GetSpectrum(currentFrame, currentFrame, frameType, imsScan, imsScanEnd, out xvals, out yvals);

                    UIMFDataUtilities.ParseOutZeroValues(ref xvals, ref yvals, 639, 640);    //note - this utility is for parsing out the zeros or filtering on m/z

                    if (xvals.Length > 0)
                    {
                        reportProgress();
                        reportProgress();
                        reportProgress(
                            "The following are a few m/z and intensities for the summed mass spectrum from frame " +
                            currentFrame + "; Scans " + imsScan + " to " + imsScanEnd);

                        reportProgress(TestUtilities.displayRawMassSpectrum(xvals, yvals));
                    }
                }
            }

            // Get mass spectrum (summing frames for a given scan range)
            int       frameLower   = testFrame;
            int       frameUpper   = testFrame + 2;
            const int imsScanLower = 125;
            const int imsScanUpper = 131;

            datareader.GetSpectrum(frameLower, frameUpper, frameType, imsScanLower, imsScanUpper, out xvals, out yvals);

            reportProgress();
            reportProgress();
            reportProgress("The following are a few m/z and intensities for the summed mass spectrum from frames: " + frameLower + "-" + frameUpper + "; Scans: " + imsScanLower + "-" + imsScanUpper);

            double startMz    = 639;
            bool   matchFound = xvals.Any(mzValue => startMz <= mzValue && (startMz + 1) >= mzValue);

            if (!matchFound && xvals.Length / 2 > 0)
            {
                startMz = Math.Floor(xvals[xvals.Length / 2]);
            }

            UIMFDataUtilities.ParseOutZeroValues(ref xvals, ref yvals, startMz, startMz + 1);    //note - this utility is for parsing out the zeros or filtering on m/z

            reportProgress(TestUtilities.displayRawMassSpectrum(xvals, yvals));


            // Get LC profile
            int    frameTarget    = testFrame;
            int    imsScanTarget  = 126;
            double targetMZ       = 639.32;
            double toleranceInPPM = 25;

            double toleranceInMZ = toleranceInPPM / 1e6 * targetMZ;

            int[] frameVals     = null;
            int[] intensityVals = null;

            if (frameList.ContainsKey(frameTarget - 25) && frameList.ContainsKey(frameTarget + 25))
            {
                datareader.GetLCProfile(frameTarget - 25, frameTarget + 25, frameType, imsScanTarget - 2, imsScanTarget + 2, targetMZ, toleranceInMZ, out frameVals, out intensityVals);
                reportProgress();
                reportProgress();

                reportProgress("2D Extracted ion chromatogram in the LC dimension. Target m/z= " + targetMZ);
                reportProgress(TestUtilities.display2DChromatogram(frameVals, intensityVals));
            }


            // Get Drift time profile
            frameTarget   = testFrame;
            imsScanTarget = 126;
            targetMZ      = 639.32;
            int[] scanVals = null;

            if (frameList.ContainsKey(frameTarget - 1) && frameList.ContainsKey(frameTarget + 1))
            {
                datareader.GetDriftTimeProfile(frameTarget - 1, frameTarget + 1, frameType, imsScanTarget - 25,
                                               imsScanTarget + 25, targetMZ, toleranceInMZ, ref scanVals,
                                               ref intensityVals);

                reportProgress();
                reportProgress();

                reportProgress("2D Extracted ion chromatogram in the drift time dimension. Target m/z= " + targetMZ);
                reportProgress(TestUtilities.display2DChromatogram(scanVals, intensityVals));
            }

            if (frameList.ContainsKey(frameTarget - 5) && frameList.ContainsKey(frameTarget + 5))
            {
                // Get 3D elution profile
                datareader.Get3DElutionProfile(frameTarget - 5, frameTarget + 5, 0, imsScanTarget - 5, imsScanTarget + 5,
                                               targetMZ, toleranceInMZ, out frameVals, out scanVals, out intensityVals);
                reportProgress();

                reportProgress("3D Extracted ion chromatogram. Target m/z= " + targetMZ);
                reportProgress(TestUtilities.Display3DChromatogram(frameVals, scanVals, intensityVals));
            }
        }
示例#5
0
 public List <IntensityPoint> GetXic(int targetBin, DataReader.FrameType frameType)
 {
     return(UimfReader.GetXic(targetBin, frameType));
 }
示例#6
0
 public List <IntensityPoint> GetXic(double targetMz, double tolerance, DataReader.FrameType frameType, int scanLcMin, int scanLcMax, int scanImsMin, int scanImsMax, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXic(targetMz, tolerance, scanLcMin, scanLcMax, scanImsMin, scanImsMax, frameType, toleranceType));
 }
示例#7
0
 public List <IntensityPoint> GetXic(double targetMz, double tolerance, DataReader.FrameType frameType, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXic(targetMz, tolerance, frameType, toleranceType));
 }
示例#8
0
 public double[,] GetXicAsArray(int targetBin, DataReader.FrameType frameType)
 {
     return(UimfReader.GetXicAsArray(targetBin, frameType));
 }
示例#9
0
 public double[,] GetXicAsArray(double targetMz, double tolerance, DataReader.FrameType frameType, int scanLcMin, int scanLcMax, int scanImsMin, int scanImsMax, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXicAsArray(targetMz, tolerance, scanLcMin, scanLcMax, scanImsMin, scanImsMax, frameType, toleranceType));
 }
示例#10
0
 public double[,] GetXicAsArray(double targetMz, double tolerance, DataReader.FrameType frameType, DataReader.ToleranceType toleranceType)
 {
     return(UimfReader.GetXicAsArray(targetMz, tolerance, frameType, toleranceType));
 }
示例#11
0
        public IDictionary <double, IEnumerable <FeatureBlobStatistics> > GetFeatureStatistics(IEnumerable <double> targetMzList, double tolerance, DataReader.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
                UimfUtil uimfUtil;
                m_uimfUtilStack.TryPop(out 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);
        }
示例#12
0
        public Dictionary <int, FeatureSet> GetFeaturesMultiThreading(int minTargetBin, int maxTargetBin, Tolerance tolerance, DataReader.FrameType frameType)
        {
            var featureDictionary = new Dictionary <int, FeatureSet>();

            var targetMzList = Enumerable.Range(minTargetBin, maxTargetBin - minTargetBin + 1).Select(targetBin => _uimfUtil.GetMzFromBin(targetBin)).ToList();
            var featureStatisticsDictionary = _featureDetectionUtil.GetFeatureStatistics(targetMzList, tolerance.GetValue(), frameType,
                                                                                         tolerance.GetUnit() == ToleranceUnit.Ppm ? DataReader.ToleranceType.PPM : DataReader.ToleranceType.Thomson);

            foreach (var entry in featureStatisticsDictionary)
            {
                var targetBin    = _uimfUtil.GetBinFromMz(entry.Key);
                var featureStats = entry.Value;
                featureDictionary.Add(targetBin, new FeatureSet(featureStats));
            }
            return(featureDictionary);
        }