示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uimf"></param>
        /// <param name="frameNumber"></param>
        /// <param name="xicMz"></param>
        /// <param name="tolerance"></param>
        /// <param name="getMsms"></param>
        /// <returns></returns>
        private IEnumerable <KeyValuePair <double, double> > GetXicInfo(
            DataReader uimf,
            int frameNumber,
            double xicMz,
            double tolerance,
            bool getMsms)
        {
            const DataReader.ToleranceType Tolerance = DataReader.ToleranceType.PPM;

            var frametype = getMsms ? DataReader.FrameType.MS2 : DataReader.FrameType.MS1;

            if (!uimf.DoesContainBinCentricData())
            {
                Console.WriteLine(uimf.UimfFilePath + " Does not have bin centric data which is required to get XiC");
                Console.WriteLine("starting to create it, this may take some time");
                var fileName = uimf.UimfFilePath;
                uimf.Dispose(); // why is this being disposed -- this is INSIDE a using statement! SAP 4/4/2016

                using (var dataWriter = new DataWriter(fileName))
                {
                    dataWriter.CreateBinCentricTables();
                }

                uimf = new DataReader(fileName); // WHY IS THIS BEING SET?! This is inside a using statement!
                Console.WriteLine("Finished Creating bin centric tables for " + uimf.UimfFilePath);
            }

            var data = new List <KeyValuePair <double, double> >();

            try
            {
                var xic       = uimf.GetXic(xicMz, tolerance, frametype, Tolerance);
                var frameData = xic.Where(point => point.ScanLc == frameNumber - 1);



                // I think this is more readable with a regular loop than a very long linq query
                foreach (var intensityPoint in frameData)
                {
                    var driftTime = uimf.GetDriftTime(intensityPoint.ScanLc + 1, intensityPoint.ScanIms, true);
                    data.Add(new KeyValuePair <double, double>(driftTime, intensityPoint.Intensity));
                }
            }
            catch (Exception)
            {
                Console.Error.WriteLine("Unable to get XiC on first attempt for " + uimf.UimfFilePath);
            }



            return(data);
        }
 // 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));
 }
 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);
        }
示例#7
0
        public IDictionary <int, IEnumerable <FeatureBlob> > GetFeatures(IEnumerable <int> targetBinList, double tolerance, DataReader.FrameType frameType, DataReader.ToleranceType toleranceType)
        {
            var resultDictionary = new Dictionary <int, IEnumerable <FeatureBlob> >();

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

                var targetMz = uimfUtil.GetMzFromBin(targetBin);

                // 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(targetBin, featureList);

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

            return(resultDictionary);
        }