当前位置: 首页>>代码示例>>C#>>正文


C# Sequence.GetInternalCleavages方法代码示例

本文整理汇总了C#中Sequence.GetInternalCleavages方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.GetInternalCleavages方法的具体用法?C# Sequence.GetInternalCleavages怎么用?C# Sequence.GetInternalCleavages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence.GetInternalCleavages方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OutputStatistics

        public void OutputStatistics(ProductSpectrum spectrum, Sequence sequence)
        {
            var baseIonTypes = spectrum.ActivationMethod != ActivationMethod.ETD ? BaseIonTypesCid : BaseIonTypesEtd;
            var cleavages = sequence.GetInternalCleavages().ToArray();
            var tolerance = new Tolerance(10);

            var maxIntensity = spectrum.Peaks.Max(p => p.Intensity);

            foreach (var c in cleavages)
            {
                foreach (var baseIonType in baseIonTypes)
                {
                    var fragmentComposition = baseIonType.IsPrefix
                        ? c.PrefixComposition + baseIonType.OffsetComposition
                        : c.SuffixComposition + baseIonType.OffsetComposition;

                    for (int charge = MinCharge; charge <= MaxCharge; charge++)
                    {
                        var ion = new Ion(fragmentComposition, charge);
                        var observedPeaks = spectrum.GetAllIsotopePeaks(ion, tolerance, RelativeIsotopeIntensityThreshold);

                        if (observedPeaks == null) continue;

                        var mostAbundantIsotopeIndex = ion.Composition.GetMostAbundantIsotopeZeroBasedIndex();


                        // representative peak intensity
                        var ionPeakIntensity = observedPeaks[mostAbundantIsotopeIndex].Intensity;

                        // calc. correlation
                        var isotopomerEnvelope = ion.Composition.GetIsotopomerEnvelopeRelativeIntensities();
                        var observedIntensities = new double[observedPeaks.Length];
                        for (var i = 0; i < observedPeaks.Length; i++)
                        {
                            var observedPeak = observedPeaks[i];
                            observedIntensities[i] = observedPeak != null ? (float)observedPeak.Intensity : 0.0;
                        }
                        var corrCoeff = FitScoreCalculator.GetPearsonCorrelation(isotopomerEnvelope, observedIntensities);

                        // mz error
                        var mostAbundantIsotopeMz = ion.GetIsotopeMz(mostAbundantIsotopeIndex);
                        var errorPpm = ((observedPeaks[mostAbundantIsotopeIndex].Mz - mostAbundantIsotopeMz)/
                                        mostAbundantIsotopeMz)*1e6;


                    }
                }

            }

        }
开发者ID:javamng,项目名称:GitHUB,代码行数:51,代码来源:AnalysisTopDownMatchedPeaks.cs

示例2: GetLongestSequence

        public Tuple<int, int, int, int, string, string> GetLongestSequence(ProductSpectrum spectrum, Sequence sequence)
        {
            _spectrum = spectrum;
            _sequence = sequence;
            _baseIonTypes = _spectrum.ActivationMethod != ActivationMethod.ETD ? BaseIonTypesCid : BaseIonTypesEtd;

            var cleavages = _sequence.GetInternalCleavages().ToArray();
            var prefixValueArr = new int[cleavages.Length];
            var suffixValueArr = new int[cleavages.Length];
            var prefixPeakArr = new Peak[cleavages.Length];
            var suffixPeakArr = new Peak[cleavages.Length];
            //var peakList = new double[_spectrum.Peaks.Length];

            int cleavageIndex = 0;

            /*
            for (int i = 0; i < peakList.Length; i++)
            {
                peakList[i] = _spectrum.Peaks[i].Intensity;
            }*/

            //var rankings = ArrayUtil.GetRankings(peakList);

            foreach (var c in cleavages)
            {
                foreach (var baseIonType in _baseIonTypes)
                {
                    var fragmentComposition = baseIonType.IsPrefix
                                 ? c.PrefixComposition + baseIonType.OffsetComposition
                                 : c.SuffixComposition + baseIonType.OffsetComposition;
                    for (var charge = _minCharge; charge <= _maxCharge; charge++)
                    {

                        var ion = new Ion(fragmentComposition, charge);
                        if (_spectrum.GetCorrScore(ion, _tolerance, RelativeIsotopeIntensityThreshold) < .7) continue;
                        if (baseIonType.IsPrefix) prefixValueArr[cleavageIndex] = 1;
                        else suffixValueArr[cleavageIndex] = 1;


                    }
                }
                cleavageIndex++;
            }

            var prefixSequenceArr = new int[_sequence.Count];
            var suffixSequenceArr = new int[_sequence.Count];
            prefixSequenceArr[0] = prefixValueArr[0];
            suffixSequenceArr[suffixSequenceArr.Length - 1] = suffixValueArr[suffixValueArr.Length - 1];

            for (int i = 1; i < prefixValueArr.Length; i++)
            {
                if (prefixValueArr[i] == 1 && prefixValueArr[i - 1] == 1)
                {
                    if (_sequence[i] is ModifiedAminoAcid) continue;
                    prefixSequenceArr[i] = 1;

                }
            }

            for (int i = suffixValueArr.Length - 2; i >= 0; i--)
            {
                if (suffixValueArr[i] == 1 && suffixValueArr[i + 1] == 1)
                {
                    if (_sequence[i + 1] is ModifiedAminoAcid) continue;
                    suffixSequenceArr[i + 1] = 1;
                }
            }



            var prefixSubString = FindLongestSubstring(prefixSequenceArr);
            var prefixStartIndex = -1;
            var prefixEndIndex = -1;
            //var prefixSequencePeaks = new List<Peak>();
            //var prefixPval = -1.0;
            var prefixSequence = "";
            if (prefixSubString != "")
            {
                var prefixIndex = string.Concat(prefixSequenceArr);
                prefixStartIndex = prefixIndex.IndexOf(prefixSubString) + 1;
                prefixEndIndex = (prefixStartIndex == 1) ? 1 : prefixStartIndex + prefixSubString.Length - 1;
                //prefixSequencePeaks = GetPrefixSequencePeaks(prefixPeakArr, prefixStartIndex, prefixEndIndex);
                //var prefixRankSum = GetSequenceRankSum(prefixSequencePeaks, rankings, peakList);
                //prefixPval = FitScoreCalculator.GetRankSumPvalue(peakList.Length, prefixSequencePeaks.Count, prefixRankSum);
                prefixSequence = GetStringSubSequence(_sequence, prefixStartIndex, prefixEndIndex);
            }

            var suffixSubString = FindLongestSubstring(suffixSequenceArr);
            var suffixStartIndex = -1;
            var suffixEndIndex = -1;
            //var suffixSequencePeaks = new List<Peak>();
            //var suffixPval = -1.0;
            var suffixSequence = "";

            if (suffixSubString != "")
            {
                var suffixIndex = string.Concat(suffixSequenceArr);
                suffixStartIndex = suffixIndex.IndexOf(suffixSubString) + 1;
                suffixEndIndex = (suffixStartIndex == 1) ? 1 : suffixStartIndex + suffixSubString.Length - 1;
                //suffixSequencePeaks = GetSuffixSequencePeaks(suffixPeakArr, suffixStartIndex, suffixEndIndex);
//.........这里部分代码省略.........
开发者ID:javamng,项目名称:GitHUB,代码行数:101,代码来源:SequenceTagIndexFinder.cs

示例3: GetNodeStatistics

        private void GetNodeStatistics(bool isDecoy, ProductSpectrum ms2Spec, Sequence sequence, StreamWriter writer) //, StreamWriter mzErrorWriter)
        {
            if (ms2Spec == null) return;
            if (sequence == null) return;
            //var refIntensity = ms2Spec.Peaks.Max(p => p.Intensity) * 0.01;
            //refIntensity = Math.Min(ms2Spec.Peaks.Select(p => p.Intensity).Median(), refIntensity);
            
            var BaseIonTypesCID = new[] { BaseIonType.B, BaseIonType.Y };
            var BaseIonTypesETD = new[] { BaseIonType.C, BaseIonType.Z };
            var tolerance = new Tolerance(15);
            var minCharge = 1;
            var maxCharge = 20;
            var baseIonTypes = ms2Spec.ActivationMethod != ActivationMethod.ETD ? BaseIonTypesCID : BaseIonTypesETD;
            
            var refIntensity = ms2Spec.Peaks.Max(p => p.Intensity);

            var activationMethodFlag = ms2Spec.ActivationMethod == ActivationMethod.ETD ? 1 : 2;
            var cleavages = sequence.GetInternalCleavages();

            var prevPrefixFragMass = 0d;
            var prevPrefixObsIonMass = 0d;
            var prevPrefixObsIonCharge = 0;
            var prevPrefixObsIonIntensity = 0d;

            var prevSuffixFragMass = 0d;
            var prevSuffixObsIonMass = 0d;
            var prevSuffixObsIonCharge = 0;
            var prevSuffixObsIonIntensity = 0d;

            var nComplementaryFrags = 0;
            
            var cleavageIndex = 0;

            foreach (var c in cleavages)
            {
                var bothObs = true;
                foreach (var baseIonType in baseIonTypes)
                {
                    var peakType = baseIonType.IsPrefix ? 1 : 2; // unexplained
                    var fragmentComposition = baseIonType.IsPrefix
                                  ? c.PrefixComposition + baseIonType.OffsetComposition
                                  : c.SuffixComposition + baseIonType.OffsetComposition;

                    var curFragMass = fragmentComposition.Mass;
                    var curObsIonMass = 0d;
                    var curObsIonCharge = 0;
                    var curObsIonDist = 1.0d;
                    var curObsIonCorr = 0d;
                    var curObsIonIntensity = 0d;

                    var ionMatch = false;
                    for (var charge = minCharge; charge <= maxCharge; charge++)
                    {
                        var ion = new Ion(fragmentComposition, charge);

                        var isotopePeaks = ms2Spec.GetAllIsotopePeaks(ion, tolerance, 0.1);

                        if (isotopePeaks == null) continue;

                        var distCorr = AbstractFragmentScorer.GetDistCorr(ion, isotopePeaks);
                        
                        if (distCorr.Item2 < 0.7 && distCorr.Item1 > 0.07) continue;
                        var mostAbundantIsotopeIndex = ion.Composition.GetMostAbundantIsotopeZeroBasedIndex();
                        var mostAbuPeak = isotopePeaks[mostAbundantIsotopeIndex];
                        
                        var summedIntensity = isotopePeaks.Where(p => p != null).Sum(p => p.Intensity);
                        var intScore = summedIntensity/refIntensity;
                        //var intScore = mostAbuPeak.Intensity / medIntensity;
                        //var intScore = summedIntensity / refIntensity;

                        if (ionMatch == false || curObsIonIntensity < intScore)
                        {
                            curObsIonMass = Ion.GetMonoIsotopicMass(mostAbuPeak.Mz, charge, mostAbundantIsotopeIndex);
                            curObsIonCharge = charge;
                            curObsIonCorr = distCorr.Item2;
                            curObsIonDist = distCorr.Item1;
                            curObsIonIntensity = intScore;
                        }
                        ionMatch = true;
                    }

                    if (!ionMatch)
                    {
                        bothObs = false;
                        continue;
                    }


                    writer.Write(activationMethodFlag);
                    writer.Write("\t");

                    writer.Write(peakType);
                    writer.Write("\t");

                    writer.Write("{0:0.000}", curFragMass);
                    writer.Write("\t");

                    writer.Write("{0}", curObsIonCharge);
                    writer.Write("\t");

//.........这里部分代码省略.........
开发者ID:javamng,项目名称:GitHUB,代码行数:101,代码来源:TestLikelihoodScorer.cs

示例4: GetMatchStatistics

        private void GetMatchStatistics(ProductSpectrum ms2Spec, Sequence sequence, int parentIonCharge, StreamWriter writer)
        {
            if (ms2Spec == null) return;
            if (sequence == null) return;

            var BaseIonTypesCID = new[] { BaseIonType.B, BaseIonType.Y };
            var BaseIonTypesETD = new[] { BaseIonType.C, BaseIonType.Z };
            var tolerance = new Tolerance(12);
            var MinProductCharge = 1;
            var MaxProductCharge = Math.Min(parentIonCharge+2, 20);

            var baseIonTypes = ms2Spec.ActivationMethod != ActivationMethod.ETD ? BaseIonTypesCID : BaseIonTypesETD;
            var refIntensity = CompositeScorer.GetRefIntensity(ms2Spec.Peaks);

            var activationMethodFlag = ms2Spec.ActivationMethod == ActivationMethod.ETD ? 2 : 1;
            var cleavages = sequence.GetInternalCleavages();
            var nComplementaryFrags = 0;

            var prefixStat = new FragmentStat();
            var suffixStat = new FragmentStat();

            var minMz = ms2Spec.Peaks.First().Mz;
            var maxMz = ms2Spec.Peaks.Last().Mz;


            var cleavageIndex = 0;

            var preFixIonCheck = new bool[sequence.Count + 1];
            var sufFixIonCheck = new bool[sequence.Count + 1];
            
            foreach (var c in cleavages)
            {
                var prefixHit = false;
                var suffixHit = false;

                foreach (var baseIonType in baseIonTypes)
                {
                    var stat = baseIonType.IsPrefix ? prefixStat : suffixStat;

                    var fragmentComposition = baseIonType.IsPrefix
                                  ? c.PrefixComposition + baseIonType.OffsetComposition
                                  : c.SuffixComposition + baseIonType.OffsetComposition;

                    if (fragmentComposition.Mass < ms2Spec.Peaks[0].Mz) continue;

                    var curFragMass = fragmentComposition.Mass;
                    /*var curObsIonCharge = 0;
                    var curObsIonDist = 1.0d;
                    var curObsIonCorr = 0d;
                    var curObsIonIntensity = 0d;
                    var curObsIonMassError = 0d;*/

                    var mostAbundantIsotopeIndex = fragmentComposition.GetMostAbundantIsotopeZeroBasedIndex();
                    var fragmentIonMostAbuMass = fragmentComposition.Mass + Constants.C13MinusC12 * mostAbundantIsotopeIndex;

                    var maxCharge = (int)Math.Floor(fragmentIonMostAbuMass / (minMz - Constants.Proton));
                    var minCharge = (int)Math.Ceiling(fragmentIonMostAbuMass / (maxMz - Constants.Proton));
                    if (maxCharge < 1 || maxCharge > MaxProductCharge) maxCharge = MaxProductCharge;
                    if (minCharge < 1 || minCharge < MinProductCharge) minCharge = MinProductCharge;

                    //var ionMatch = false;
                    for (var charge = minCharge; charge <= maxCharge; charge++)
                    {
                        var ion = new Ion(fragmentComposition, charge);

                        var isotopePeaks = ms2Spec.GetAllIsotopePeaks(ion, tolerance, 0.1);

                        if (isotopePeaks == null) continue;

                        var distCorr = CompositeScorer.GetDistCorr(ion, isotopePeaks);
                        if (distCorr.Item2 < 0.7 && distCorr.Item1 > 0.03) continue;
                        var mostAbuPeak = isotopePeaks[mostAbundantIsotopeIndex];
                        var intScore = mostAbuPeak.Intensity / refIntensity;
                        /*
                        if (ionMatch == false || curObsIonIntensity < intScore)
                        {
                            curObsIonCharge = charge;
                            curObsIonCorr = distCorr.Item2;
                            curObsIonDist = distCorr.Item1;
                            curObsIonIntensity = intScore;

                            var mostAbuPeakMz = Ion.GetIsotopeMz(curFragMass, charge, mostAbundantIsotopeIndex);
                            curObsIonMassError = (Math.Abs(mostAbuPeak.Mz - mostAbuPeakMz) / mostAbuPeakMz) * 1e6;
                            
                            //var curObsIonMass = Ion.GetMonoIsotopicMass(mostAbuPeak.Mz, charge, mostAbundantIsotopeIndex);
                            //curObsIonMassError = (Math.Abs(curFragMass - curObsIonMass) / curFragMass) * 1e6;
                        }
                        ionMatch = true;
                        */
                        var mostAbuPeakMz = Ion.GetIsotopeMz(curFragMass, charge, mostAbundantIsotopeIndex);
                        var curObsIonMassError = (Math.Abs(mostAbuPeak.Mz - mostAbuPeakMz) / mostAbuPeakMz) * 1e6;

                        stat.Count++;
                        stat.Intensity += Math.Min(intScore, 1.0);
                        stat.Corr += distCorr.Item2;
                        stat.Dist += distCorr.Item1;
                        stat.MassError += curObsIonMassError;

                        if (baseIonType.IsPrefix) prefixHit = true;
                        else suffixHit = true;
//.........这里部分代码省略.........
开发者ID:javamng,项目名称:GitHUB,代码行数:101,代码来源:TestLikelihoodScorer.cs

示例5: GetCompositeScores

        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;
        }
开发者ID:javamng,项目名称:GitHUB,代码行数:40,代码来源:InformedTopDownScorer.cs


注:本文中的Sequence.GetInternalCleavages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。