Example #1
0
        /// <summary>
        /// Public constructor for the LCMS Alignment Processor
        /// Initializes a new LCMSWarp object using the LCMS Alignment options
        /// which were passed into the Processor
        /// </summary>
        public LcmsWarpAlignmentProcessor()
        {
            m_lcmsWarp = new LcmsWarp();
            Options    = new LcmsWarpAlignmentOptions();

            ApplyAlignmentOptions();

            AligningToMassTagDb = false;
        }
Example #2
0
        /// <summary>
        /// Method to return the heatmap of the alignment (as a 2D array of doubles) based on
        /// the output scores taht
        /// </summary>
        /// <param name="outputScores"></param>
        /// <param name="xIntervals"></param>
        /// <param name="yIntervals"></param>
        public void GetAlignmentHeatMap(out double[,] outputScores, out double[] xIntervals,
                                        out double[] yIntervals)
        {
            if (m_lcmsWarp == null)
            {
                m_lcmsWarp = new LcmsWarp();
            }

            var alignmentScores   = new List <double>();
            var aligneeIntervals  = new List <double>();
            var baselineIntervals = new List <double>();

            // Original .cpp code did not include the boolean standardize. Hard coding to false for the moment
            // Mike - 3/10/14
            m_lcmsWarp.GetSubsectionMatchScore(ref alignmentScores, ref aligneeIntervals, ref baselineIntervals, true);

            var numBaselineSections = baselineIntervals.Count;
            var numAligneeSections  = aligneeIntervals.Count;

            outputScores = new double[numBaselineSections, numAligneeSections];

            var numTotalSections = alignmentScores.Count;

            if (numTotalSections != numBaselineSections * numAligneeSections)
            {
                throw new ApplicationException("Error in Alignment heatmap scores. Total section is not as expected");
            }

            var aligneeSection  = 0;
            var baselineSection = 0;

            for (var i = 0; i < numTotalSections; i++)
            {
                outputScores[baselineSection, aligneeSection] = alignmentScores[i];
                baselineSection++;
                if (baselineSection != numBaselineSections)
                {
                    continue;
                }
                baselineSection = 0;
                aligneeSection++;
            }

            xIntervals = new double[numAligneeSections];
            for (var i = 0; i < numAligneeSections; i++)
            {
                xIntervals[i] = aligneeIntervals[i];
            }

            yIntervals = new double[numBaselineSections];
            for (var i = 0; i < numBaselineSections; i++)
            {
                yIntervals[i] = baselineIntervals[i];
            }
        }
Example #3
0
        /// <summary>
        /// Public constructor for the LCMS Alignment Processor
        /// Initializes a new LCMSWarp object using the LCMS Alignment options
        /// that are passed into the Processor
        /// </summary>
        /// <remarks>
        /// Store data using SetReferenceDatasetFeatures and SetAligneeDatasets,
        /// then call PerformAlignmentToMsFeatures, which calls either PerformNetWarp or PerformNetMassWarp</remarks>
        public LcmsWarpAlignmentProcessor(LcmsWarpAlignmentOptions options)
        {
            _options  = options;
            _lcmsWarp = new LcmsWarp(_options);

            _lcmsWarp.Progress += lcmsWarp_Progress;

            _currentTaskPercentCompleteAtStart = new Dictionary <CurrentLcmsWarpTask, double>
            {
                { CurrentLcmsWarpTask.Unstarted, 0 },
                { CurrentLcmsWarpTask.GenerateCandidateMatches, 0 },
                { CurrentLcmsWarpTask.GetMatchProbabilities, 10 },
                { CurrentLcmsWarpTask.CalculateAlignmentMatrix, 90 },
                { CurrentLcmsWarpTask.CalculateAlignmentFunction, 93 },
                { CurrentLcmsWarpTask.GetTransformedNets, 96 },
                { CurrentLcmsWarpTask.CalculateAlignmentMatches, 98 },
                { CurrentLcmsWarpTask.Complete, 100 }
            };

            _percentCompleteAtStartOfTask = 0;
            _percentCompleteAtEndOfTask   = 100;

            _aligningToMassTagDb = false;
        }
Example #4
0
        /// <summary>
        /// Takes a List of UMCLight data and applies the NET/Mass Function to the dataset and
        /// aligns it to the baseline. Updates the data in place for the calibrated Masses and
        /// Alignment.
        /// </summary>
        /// <param name="data"></param>
        public void ApplyNetMassFunctionToAligneeDatasetFeatures(ref List <UMCLight> data)
        {
            if (m_lcmsWarp == null)
            {
                m_lcmsWarp = new LcmsWarp();
            }

            var umcIndices          = new List <int>();
            var umcCalibratedMasses = new List <double>();
            var umcAlignedNets      = new List <double>();
            var umcAlignedScans     = new List <int>();
            var umcDriftTimes       = new List <double>();

            if (AligningToMassTagDb)
            {
                m_lcmsWarp.GetFeatureCalibratedMassesAndAlignedNets(ref umcIndices, ref umcCalibratedMasses,
                                                                    ref umcAlignedNets, ref umcDriftTimes);

                for (var i = 0; i < umcIndices.Count; i++)
                {
                    var point = new UMCLight
                    {
                        Id = umcIndices[i],
                        MassMonoisotopicAligned = umcCalibratedMasses[i],
                        NetAligned = umcAlignedNets[i],
                        DriftTime  = umcDriftTimes[i]
                    };

                    if (i < data.Count)
                    {
                        // Update the data without stomping the data that shouldn't change.
                        data[i].MassMonoisotopicAligned = point.MassMonoisotopicAligned;
                        data[i].NetAligned = point.NetAligned;
                        data[i].DriftTime  = point.DriftTime;
                    }
                    else
                    {
                        data.Add(point);
                    }
                }
            }
            else
            {
                m_lcmsWarp.GetFeatureCalibratedMassesAndAlignedNets(ref umcIndices, ref umcCalibratedMasses,
                                                                    ref umcAlignedNets, ref umcAlignedScans,
                                                                    ref umcDriftTimes, m_minReferenceDatasetScan,
                                                                    m_maxReferenceDatasetScan);

                for (var i = 0; i < umcIndices.Count; i++)
                {
                    var point = new UMCLight
                    {
                        Id = umcIndices[i],
                        MassMonoisotopicAligned = umcCalibratedMasses[i],
                        NetAligned  = umcAlignedNets[i],
                        ScanAligned = umcAlignedScans[i],
                        DriftTime   = umcDriftTimes[i]
                    };

                    if (i < data.Count)
                    {
                        // Update the data without stomping the data that shouldn't change.
                        data[i].MassMonoisotopicAligned = point.MassMonoisotopicAligned;
                        data[i].NetAligned  = point.NetAligned;
                        data[i].ScanAligned = point.ScanAligned;
                        data[i].DriftTime   = point.DriftTime;
                    }
                    else
                    {
                        data.Add(point);
                    }
                }
            }
        }