private void SetLcMsMatches(double peakMz, int scanNum)
        {
            var xicThisPeak = _run.GetPrecursorExtractedIonChromatogram(peakMz, _tolerance, scanNum);

            if (xicThisPeak.Count < 2)
            {
                return;
            }

            for (var charge = _maxCharge; charge >= _minCharge; charge--)
            {
                // check whether next isotope peak exists
                var nextIsotopeMz  = peakMz + Constants.C13MinusC12 / charge;
                var xicNextIsotope = _run.GetPrecursorExtractedIonChromatogram(nextIsotopeMz, _tolerance, scanNum);
                if (!xicNextIsotope.Any())
                {
                    continue;
                }

                var mostAbundantIsotopeMass        = (peakMz - Constants.Proton) * charge;
                var averagineIsoEnv                = Averagine.GetIsotopomerEnvelope(mostAbundantIsotopeMass);
                var approxMostAbundantIsotopeIndex = averagineIsoEnv.MostAbundantIsotopeIndex;
                var monoIsotopicMass               = mostAbundantIsotopeMass - approxMostAbundantIsotopeIndex * Constants.C13MinusC12;

                _lcMsMatchMap.SetMatches(monoIsotopicMass, xicThisPeak[0].ScanNum, xicThisPeak[xicThisPeak.Count - 1].ScanNum);
            }
        }
Пример #2
0
        private void Read(string msDeconvFileName)
        {
            var curScan = 0;
            var isMs1   = false;
            var minMass = double.MaxValue;
            var maxMass = 0.0;

            var featureCountUnfiltered = 0;
            var featureCountFiltered   = 0;

            foreach (var line in File.ReadLines(msDeconvFileName))
            {
                if (line.StartsWith("SCANS="))
                {
                    curScan = Convert.ToInt32(line.Substring(line.LastIndexOf('=') + 1));
                    isMs1   = _run.GetMsLevel(curScan) == 1;
                }
                else if (isMs1 && line.Length > 0)
                {
                    var token = line.Split();
                    if (token.Length != 3)
                    {
                        continue;
                    }

                    featureCountUnfiltered++;

                    var charge = Convert.ToInt32(token[2]);
                    if (charge == 1)
                    {
                        continue;
                    }

                    var monoMass = Convert.ToDouble(token[0]);

                    if (minMass > monoMass)
                    {
                        minMass = monoMass;
                    }

                    if (maxMass < monoMass)
                    {
                        maxMass = monoMass;
                    }

                    featureCountFiltered++;

                    var minScan = _run.GetPrevScanNum(curScan, 1);
                    var maxScan = _run.GetNextScanNum(curScan, 1);
                    _lcMsMatchMap.SetMatches(monoMass, minScan, maxScan);
                }
            }

            Console.Write(@"{0}/{1} features loaded...", featureCountFiltered, featureCountUnfiltered);

            _lcMsMatchMap.CreateSequenceMassToMs2ScansMap(_run, _massTolerance, minMass, maxMass);
        }
Пример #3
0
        private void Read(string isosFileName)
        {
            var icrToolsparser = new TsvFileParser(isosFileName, ',');
            var monoMassArr    = icrToolsparser.GetData("monoisotopic_mw").Select(Convert.ToDouble).ToArray();
            var scanArray      = icrToolsparser.GetData("scan_num").Select(s => Convert.ToInt32(s)).ToArray();
            var chargeArray    = icrToolsparser.GetData("charge").Select(s => Convert.ToInt32(s)).ToArray();

            var fitStringArr = icrToolsparser.GetData("fit");
            var fitArray     = fitStringArr == null ? null : icrToolsparser.GetData("fit").Select(Convert.ToDouble).ToArray();

            var featureCountFiltered = 0;

            var minMass = double.MaxValue;
            var maxMass = 0.0;

            for (var i = 0; i < monoMassArr.Length; i++)
            {
                if (fitArray != null && fitArray[i] > _fitScoreThreshold || chargeArray[i] <= 1)
                {
                    continue;
                }

                featureCountFiltered++;

                var scan     = scanArray[i];
                var monoMass = monoMassArr[i];
                if (minMass > monoMass)
                {
                    minMass = monoMass;
                }
                if (maxMass < monoMass)
                {
                    maxMass = monoMass;
                }

                var minScan = _run.GetPrevScanNum(scan, 1);
                var maxScan = _run.GetNextScanNum(scan, 1);
                _lcMsMatchMap.SetMatches(monoMass, minScan, maxScan);
            }

            Console.Write(@"{0}/{1} features loaded...", featureCountFiltered, monoMassArr.Length);

            _lcMsMatchMap.CreateSequenceMassToMs2ScansMap(_run, _massTolerance, minMass, maxMass);
        }
Пример #4
0
        private void SetLcMsMatches(double peakMz, int scanNum, IList <Peak> precursorSpecWindow, IList <Peak> nextMs1SpecWindow)
        {
            var xicThisPeak = _run.GetPrecursorExtractedIonChromatogram(peakMz, _tolerance, scanNum);

            if (xicThisPeak.Count < 2)
            {
                return;
            }

            for (var charge = _maxCharge; charge >= _minCharge; charge--)
            {
                // check whether next isotope peak exists
                var nextIsotopeMz  = peakMz + Constants.C13MinusC12 / charge;
                var xicNextIsotope = _run.GetPrecursorExtractedIonChromatogram(nextIsotopeMz, _tolerance, scanNum);
                if (!xicNextIsotope.Any())
                {
                    continue;
                }
                if (xicThisPeak.GetCorrelation(xicNextIsotope) < _mostAbundantPlusOneIsotopeCorrThreshold)
                {
                    continue;
                }

                var mostAbundantIsotopeMass        = (peakMz - Constants.Proton) * charge;
                var averagineIsoEnv                = Averagine.GetIsotopomerEnvelope(mostAbundantIsotopeMass);
                var approxMostAbundantIsotopeIndex = averagineIsoEnv.MostAbundantIsotopeIndex;
                var monoIsotopicMass               = mostAbundantIsotopeMass - approxMostAbundantIsotopeIndex * Constants.C13MinusC12;

                // Isotope correlation
                var averagineIsotopeProfile = Averagine.GetTheoreticalIsotopeProfile(monoIsotopicMass, charge);
                var precursorIsotopeCorr    = precursorSpecWindow != null?PeakListUtils.GetPearsonCorrelation(precursorSpecWindow, averagineIsotopeProfile, _comparer) : 0;

                var nextMs1IsotopeCorr = nextMs1SpecWindow != null?PeakListUtils.GetPearsonCorrelation(nextMs1SpecWindow, averagineIsotopeProfile, _comparer) : 0;

                var isotopeCorr = Math.Max(precursorIsotopeCorr, nextMs1IsotopeCorr);
                if (isotopeCorr < _isotopeCorrThresholdThreshold)
                {
                    continue;
                }

                if (_chargeCorrThresholdThreshold > 0.0)
                {
                    var mzChargePlusOne   = Ion.GetIsotopeMz(monoIsotopicMass, charge + 1, approxMostAbundantIsotopeIndex);
                    var xicPlusOneCharge  = _run.GetPrecursorExtractedIonChromatogram(mzChargePlusOne, _tolerance, scanNum);
                    var corrPlusOneCharge = xicPlusOneCharge.Count >= 3 ? xicThisPeak.GetCorrelation(xicPlusOneCharge) : 0;

                    double corrMinusOneCharge;
                    if (charge > 1)
                    {
                        var mzChargeMinusOne  = Ion.GetIsotopeMz(monoIsotopicMass, charge - 1, approxMostAbundantIsotopeIndex);
                        var xicMinusOneCharge = _run.GetPrecursorExtractedIonChromatogram(mzChargeMinusOne, _tolerance, scanNum);
                        corrMinusOneCharge = xicMinusOneCharge.Count >= 3 ? xicThisPeak.GetCorrelation(xicMinusOneCharge) : 0;
                    }
                    else
                    {
                        corrMinusOneCharge = 0.0;
                    }

                    var chargeCorr = Math.Max(corrPlusOneCharge, corrMinusOneCharge);
                    if (chargeCorr < _chargeCorrThresholdThreshold)
                    {
                        continue;
                    }
                }

                _lcMsMatchMap.SetMatches(monoIsotopicMass, xicThisPeak[0].ScanNum, xicThisPeak[xicThisPeak.Count - 1].ScanNum);
            }
        }