Exemple #1
0
        public void GetCompositeScores(Sequence sequence, int parentIoncharge, int ms2ScanNum, out double score, out int nMatchedFragments)
        {
            score             = 0d;
            nMatchedFragments = 0;

            var spec = Run.GetSpectrum(ms2ScanNum) as ProductSpectrum;

            if (spec == null)
            {
                return;
            }

            var preFixIonCheck = new bool[sequence.Count + 1];
            var sufFixIonCheck = new bool[sequence.Count + 1];

            var scorer        = new CompositeScorer(spec, Tolerance, MinProductCharge, Math.Min(MaxProductCharge, parentIoncharge + 2), activationMethod: ActivationMethod);
            var cleavages     = sequence.GetInternalCleavages();
            var cleavageIndex = 0;

            foreach (var c in cleavages)
            {
                bool prefixHit;
                bool suffixHit;
                score += scorer.GetFragmentScore(c.PrefixComposition, c.SuffixComposition, out prefixHit, out suffixHit);

                nMatchedFragments += (prefixHit) ? 1 : 0;
                nMatchedFragments += (suffixHit) ? 1 : 0;

                if (prefixHit)
                {
                    preFixIonCheck[cleavageIndex] = true;
                }
                if (suffixHit)
                {
                    sufFixIonCheck[cleavageIndex] = true;
                }

                cleavageIndex++;
            }

            var preContCount = 0;
            var sufContCount = 0;

            for (var i = 0; i < preFixIonCheck.Length - 1; i++)
            {
                if (preFixIonCheck[i] && preFixIonCheck[i + 1])
                {
                    preContCount++;
                }
                if (sufFixIonCheck[i] && sufFixIonCheck[i + 1])
                {
                    sufContCount++;
                }
            }
            score += preContCount * CompositeScorer.ScoreParam.Prefix.ConsecutiveMatch;
            score += sufContCount * CompositeScorer.ScoreParam.Suffix.ConsecutiveMatch;
        }
Exemple #2
0
        public IcScores GetScores(ProductSpectrum spec, string seqStr, Composition composition, int charge, int ms2ScanNum)
        {
            if (spec == null)
            {
                return(null);
            }
            var scorer   = new CompositeScorer(spec, Tolerance, MinProductCharge, Math.Min(MaxProductCharge, charge), activationMethod: ActivationMethod);
            var seqGraph = SequenceGraph.CreateGraph(AminoAcidSet, AminoAcid.ProteinNTerm, seqStr, AminoAcid.ProteinCTerm);

            if (seqGraph == null)
            {
                return(null);
            }

            var bestScore = double.NegativeInfinity;
            Tuple <double, string> bestScoreAndModifications = null;
            var protCompositions = seqGraph.GetSequenceCompositions();

            for (var modIndex = 0; modIndex < protCompositions.Length; modIndex++)
            {
                seqGraph.SetSink(modIndex);
                var protCompositionWithH2O = seqGraph.GetSinkSequenceCompositionWithH2O();

                if (!protCompositionWithH2O.Equals(composition))
                {
                    continue;
                }

                var curScoreAndModifications = seqGraph.GetFragmentScoreAndModifications(scorer);
                var curScore = curScoreAndModifications.Item1;

                if (!(curScore > bestScore))
                {
                    continue;
                }

                bestScoreAndModifications = curScoreAndModifications;
                bestScore = curScore;
            }

            if (bestScoreAndModifications == null)
            {
                return(null);
            }

            var modifications = bestScoreAndModifications.Item2;
            var seqObj        = Sequence.CreateSequence(seqStr, modifications, AminoAcidSet);

            double score;
            int    nMatchedFragments;

            GetCompositeScores(seqObj, charge, ms2ScanNum, out score, out nMatchedFragments);
            return(new IcScores(nMatchedFragments, score, modifications));
        }
Exemple #3
0
        public IScorer GetScorer(ProductSpectrum spectrum, double precursorMass, int precursorCharge, ActivationMethod activationMethod = ActivationMethod.Unknown)
        {
            IScorer scorer = null;

            if (spectrum is DeconvolutedSpectrum)
            {
                var deconSpec = spectrum as DeconvolutedSpectrum;
                scorer = new CompositeScorerBasedOnDeconvolutedSpectrum(deconSpec, spectrum, _productTolerance, _comparer, spectrum.ActivationMethod);
            }
            else
            {
                scorer = new CompositeScorer(
                    spectrum,
                    this._productTolerance,
                    activationMethod: activationMethod,
                    minCharge: _minProductCharge,
                    maxCharge: _maxProductCharge);
            }
            return(scorer);
        }
        public IcScores GetScores(ProductSpectrum spec, string seqStr, Composition composition, int charge, int ms2ScanNum)
        {
            if (spec == null) return null;
            var scorer = new CompositeScorer(spec, Tolerance, MinProductCharge, Math.Min(MaxProductCharge, charge));
            var seqGraph = SequenceGraph.CreateGraph(AminoAcidSet, AminoAcid.ProteinNTerm, seqStr, AminoAcid.ProteinCTerm);
            if (seqGraph == null) return null;

            var bestScore = double.NegativeInfinity;
            Tuple<double, string> bestScoreAndModifications = null;
            var protCompositions = seqGraph.GetSequenceCompositions();

            for (var modIndex = 0; modIndex < protCompositions.Length; modIndex++)
            {
                seqGraph.SetSink(modIndex);
                var protCompositionWithH2O = seqGraph.GetSinkSequenceCompositionWithH2O();

                if (!protCompositionWithH2O.Equals(composition)) continue;

                var curScoreAndModifications = seqGraph.GetFragmentScoreAndModifications(scorer);
                var curScore = curScoreAndModifications.Item1;

                if (!(curScore > bestScore)) continue;

                bestScoreAndModifications = curScoreAndModifications;
                bestScore = curScore;
            }

            if (bestScoreAndModifications == null) return null;

            var modifications = bestScoreAndModifications.Item2;
            var seqObj = Sequence.CreateSequence(seqStr, modifications, AminoAcidSet);

            double score;
            int nMatchedFragments;

            GetCompositeScores(seqObj, charge, ms2ScanNum, out score, out nMatchedFragments);
            return new IcScores(nMatchedFragments, score, modifications);
        }
        public void GetCompositeScores(Sequence sequence, int parentIoncharge, int ms2ScanNum, out double score, out int nMatchedFragments)
        {
            score = 0d;
            nMatchedFragments = 0;

            var spec = Run.GetSpectrum(ms2ScanNum) as ProductSpectrum;
            if (spec == null) return;
            
            var preFixIonCheck = new bool[sequence.Count + 1];
            var sufFixIonCheck = new bool[sequence.Count + 1];
            
            var scorer = new CompositeScorer(spec, Tolerance, MinProductCharge, Math.Min(MaxProductCharge, parentIoncharge+2));
            var cleavages = sequence.GetInternalCleavages();
            var cleavageIndex = 0;

            foreach (var c in cleavages)
            {
                bool prefixHit;
                bool suffixHit;
                score += scorer.GetFragmentScore(c.PrefixComposition, c.SuffixComposition, out prefixHit, out suffixHit);

                nMatchedFragments += (prefixHit) ? 1 : 0;
                nMatchedFragments += (suffixHit) ? 1 : 0;

                if (prefixHit) preFixIonCheck[cleavageIndex] = true;
                if (suffixHit) sufFixIonCheck[cleavageIndex] = true;

                cleavageIndex++;
            }
            
            var preContCount = 0;
            var sufContCount = 0;
            for (var i = 0; i < preFixIonCheck.Length - 1; i++)
            {
                if (preFixIonCheck[i] && preFixIonCheck[i + 1]) preContCount++;
                if (sufFixIonCheck[i] && sufFixIonCheck[i + 1]) sufContCount++;
            }
            score += preContCount * CompositeScorer.ScoreParam.Prefix.ConsecutiveMatch;
            score += sufContCount * CompositeScorer.ScoreParam.Suffix.ConsecutiveMatch;
        }