コード例 #1
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 List <UMCLight> ApplyNetMassFunctionToAligneeDatasetFeatures(List <UMCLight> data)
        {
            var sortedData = data.OrderBy(x => x.Id).ToList();

            IEnumerable <UMCLight> featureData;

            if (_aligningToMassTagDb)
            {
                featureData = _lcmsWarp.GetFeatureCalibratedMassesAndAlignedNets();
            }
            else
            {
                featureData = _lcmsWarp.GetFeatureCalibratedMassesAndAlignedNets(_minReferenceDatasetScan,
                                                                                 _maxReferenceDatasetScan, _minReferenceDatasetTime, _maxReferenceDatasetTime);
            }

            // Update sortedData using featureData

            var i = 0;

            foreach (var point in featureData.OrderBy(x => x.Id))
            {
                while (i < data.Count - 1 && sortedData[i].Id < point.Id)
                {
                    i++;
                }

                while (i > 0 && sortedData[i].Id > point.Id)
                {
                    i--;
                }

                if (sortedData[i].Id != point.Id)
                {
                    Console.WriteLine("Possible code bug; id {0} not found in sortedData: ", point.Id);
                    sortedData.Add(point);
                    continue;
                }

                if (this._options.AlignType == LcmsWarpAlignmentType.NET_MASS_WARP)
                {
                    sortedData[i].MassMonoisotopicAligned = point.MassMonoisotopicAligned;
                }
                else
                {
                    sortedData[i].MassMonoisotopicAligned = sortedData[i].MassMonoisotopic;
                }

                sortedData[i].MassMonoisotopicOriginal = point.MassMonoisotopicOriginal;

                sortedData[i].NetAligned = point.NetAligned;
                sortedData[i].NetStart   = point.NetStart;
                sortedData[i].NetEnd     = point.NetEnd;
                sortedData[i].DriftTime  = point.DriftTime;
                if (!_aligningToMassTagDb)
                {
                    sortedData[i].ScanAligned      = point.ScanAligned;
                    sortedData[i].DriftTimeAligned = point.DriftTimeAligned;
                }

                i++;
            }

            return(sortedData);
        }
コード例 #2
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);
                    }
                }
            }
        }