상속: AminoAcidPolymer
예제 #1
0
        public PeptideSpectrumMatch(TandemMassSpectrum spectrum, Peptide peptide, MassTolerance productMassTolerance)
        {
            Spectrum = spectrum;
            Peptide = peptide;

            PrecursorMassErrorDa = spectrum.PrecursorMass - (precursorMassType == MassType.Average ? peptide.AverageMass : peptide.MonoisotopicMass);
            PrecursorMassErrorPpm = PrecursorMassErrorDa / (precursorMassType == MassType.Average ? peptide.AverageMass : peptide.MonoisotopicMass) * 1e6;

            ScoreMatch(productMassTolerance);
        }
예제 #2
0
 private Peptide(Peptide peptide) : this(peptide.Parent, peptide.StartResidueNumber, peptide.EndResidueNumber, peptide.MissedCleavages)
 {
 }
예제 #3
0
        public IEnumerable <Peptide> GetVariablyModifiedPeptides(IEnumerable <Modification> variableModifications, int maximumVariableModificationIsoforms)
        {
            Dictionary <int, List <Modification> > possible_modifications = new Dictionary <int, List <Modification> >(Length + 4);

            foreach (Modification variable_modification in variableModifications)
            {
                if (variable_modification.Type == ModificationType.ProteinNTerminus && (StartResidueNumber == 1 || (StartResidueNumber == 2 && Parent[0] == 'M')) &&
                    (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List <Modification> prot_n_term_variable_mods;
                    if (!possible_modifications.TryGetValue(0, out prot_n_term_variable_mods))
                    {
                        prot_n_term_variable_mods = new List <Modification>();
                        prot_n_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(0, prot_n_term_variable_mods);
                    }
                    else
                    {
                        prot_n_term_variable_mods.Add(variable_modification);
                    }
                }

                if (variable_modification.Type == ModificationType.PeptideNTerminus && (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List <Modification> pep_n_term_variable_mods;
                    if (!possible_modifications.TryGetValue(1, out pep_n_term_variable_mods))
                    {
                        pep_n_term_variable_mods = new List <Modification>();
                        pep_n_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(1, pep_n_term_variable_mods);
                    }
                    else
                    {
                        pep_n_term_variable_mods.Add(variable_modification);
                    }
                }

                for (int r = 0; r < Length; r++)
                {
                    if (variable_modification.Type == ModificationType.AminoAcidResidue && this[r] == variable_modification.AminoAcid)
                    {
                        List <Modification> residue_variable_mods;
                        if (!possible_modifications.TryGetValue(r + 2, out residue_variable_mods))
                        {
                            residue_variable_mods = new List <Modification>();
                            residue_variable_mods.Add(variable_modification);
                            possible_modifications.Add(r + 2, residue_variable_mods);
                        }
                        else
                        {
                            residue_variable_mods.Add(variable_modification);
                        }
                    }
                }

                if (variable_modification.Type == ModificationType.PeptideCTerminus && (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List <Modification> pep_c_term_variable_mods;
                    if (!possible_modifications.TryGetValue(Length + 2, out pep_c_term_variable_mods))
                    {
                        pep_c_term_variable_mods = new List <Modification>();
                        pep_c_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(Length + 2, pep_c_term_variable_mods);
                    }
                    else
                    {
                        pep_c_term_variable_mods.Add(variable_modification);
                    }
                }

                if (variable_modification.Type == ModificationType.ProteinCTerminus && (EndResidueNumber == Parent.Length - 1) &&
                    (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List <Modification> prot_c_term_variable_mods;
                    if (!possible_modifications.TryGetValue(Length + 3, out prot_c_term_variable_mods))
                    {
                        prot_c_term_variable_mods = new List <Modification>();
                        prot_c_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(Length + 3, prot_c_term_variable_mods);
                    }
                    else
                    {
                        prot_c_term_variable_mods.Add(variable_modification);
                    }
                }
            }

            int variable_modification_isoforms = 0;

            foreach (Dictionary <int, Modification> kvp in GetVariableModificationPatterns(possible_modifications))
            {
                Peptide peptide = new Peptide(this);
                peptide.FixedModifications    = FixedModifications;
                peptide.VariableModifications = kvp;
                yield return(peptide);

                variable_modification_isoforms++;
                if (variable_modification_isoforms == maximumVariableModificationIsoforms)
                {
                    yield break;
                }
            }
        }
        // This Init method needs to be called before this object can be used.
        // For more info, see how we use these objects in DatabaseSearcher.
        //
        // We copy the peptide parameter deeply (because these sometimes come
        // from reusable buffers) but not the spectrum parameter (because these
        // are not reused).
        //
        // The array product_masses_buf is used for temporary internal storage
        // and may be resized. It needs to be local to the current thread; no
        // locking is performed. Its contents are not of interest to the
        // caller.
        //
        // The fast_q_sorter object also need to be local to the current
        // thread, as its internal state will be modified.
        public void Init(TandemMassSpectrum spectrum, Peptide peptide, MassTolerance productMassTolerance,
            ref double[] product_masses_buf, FastQSorter fast_q_sorter)
        {
            Spectrum = spectrum;
            if(Peptide == null)
                Peptide = new Peptide();
            Peptide.CopyFrom(peptide);

            PrecursorMassErrorDa = spectrum.PrecursorMass - (precursorMassType == MassType.Average ? peptide.AverageMass : peptide.MonoisotopicMass);
            PrecursorMassErrorPpm = PrecursorMassErrorDa / (precursorMassType == MassType.Average ? peptide.AverageMass : peptide.MonoisotopicMass) * 1e6;

            ScoreMatch(productMassTolerance, ref product_masses_buf, fast_q_sorter);
        }
 // Copy all of this objects data members from the other object's data
 // members. We copy other.Peptide deeply (because these sometimes come
 // from reusable buffers) but not other.Spectrum (because these are not
 // reused).
 public void CopyFrom(PeptideSpectrumMatch other)
 {
     Spectrum = other.Spectrum;
     if(Peptide == null)
         Peptide = new Peptide();
     Peptide.CopyFrom(other.Peptide);
     PrecursorMassErrorDa = other.PrecursorMassErrorDa;
     PrecursorMassErrorPpm = other.PrecursorMassErrorPpm;
     MatchingProducts = other.MatchingProducts;
     TotalProducts = other.TotalProducts;
     MatchingProductsFraction = other.MatchingProductsFraction;
     MatchingIntensity = other.MatchingIntensity;
     MatchingIntensityFraction = other.MatchingIntensityFraction;
     MorpheusScore = other.MorpheusScore;
 }
예제 #6
0
파일: Peptide.cs 프로젝트: cwenger/Morpheus
 private Peptide(Peptide peptide)
     : this(peptide.Parent, peptide.StartResidueNumber, peptide.EndResidueNumber, peptide.MissedCleavages)
 {
 }
예제 #7
0
파일: Peptide.cs 프로젝트: cwenger/Morpheus
        public IEnumerable<Peptide> GetVariablyModifiedPeptides(IEnumerable<Modification> variableModifications, int maximumVariableModificationIsoforms)
        {
            Dictionary<int, List<Modification>> possible_modifications = new Dictionary<int, List<Modification>>(Length + 4);

            foreach(Modification variable_modification in variableModifications)
            {
                if(variable_modification.Type == ModificationType.ProteinNTerminus && (StartResidueNumber == 1 || (StartResidueNumber == 2 && Parent[0] == 'M'))
                    && (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List<Modification> prot_n_term_variable_mods;
                    if(!possible_modifications.TryGetValue(0, out prot_n_term_variable_mods))
                    {
                        prot_n_term_variable_mods = new List<Modification>();
                        prot_n_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(0, prot_n_term_variable_mods);
                    }
                    else
                    {
                        prot_n_term_variable_mods.Add(variable_modification);
                    }
                }

                if(variable_modification.Type == ModificationType.PeptideNTerminus && (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List<Modification> pep_n_term_variable_mods;
                    if(!possible_modifications.TryGetValue(1, out pep_n_term_variable_mods))
                    {
                        pep_n_term_variable_mods = new List<Modification>();
                        pep_n_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(1, pep_n_term_variable_mods);
                    }
                    else
                    {
                        pep_n_term_variable_mods.Add(variable_modification);
                    }
                }

                for(int r = 0; r < Length; r++)
                {
                    if(variable_modification.Type == ModificationType.AminoAcidResidue && this[r] == variable_modification.AminoAcid)
                    {
                        List<Modification> residue_variable_mods;
                        if(!possible_modifications.TryGetValue(r + 2, out residue_variable_mods))
                        {
                            residue_variable_mods = new List<Modification>();
                            residue_variable_mods.Add(variable_modification);
                            possible_modifications.Add(r + 2, residue_variable_mods);
                        }
                        else
                        {
                            residue_variable_mods.Add(variable_modification);
                        }
                    }
                }

                if(variable_modification.Type == ModificationType.PeptideCTerminus && (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List<Modification> pep_c_term_variable_mods;
                    if(!possible_modifications.TryGetValue(Length + 2, out pep_c_term_variable_mods))
                    {
                        pep_c_term_variable_mods = new List<Modification>();
                        pep_c_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(Length + 2, pep_c_term_variable_mods);
                    }
                    else
                    {
                        pep_c_term_variable_mods.Add(variable_modification);
                    }
                }

                if(variable_modification.Type == ModificationType.ProteinCTerminus && (EndResidueNumber == Parent.Length - 1)
                    && (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List<Modification> prot_c_term_variable_mods;
                    if(!possible_modifications.TryGetValue(Length + 3, out prot_c_term_variable_mods))
                    {
                        prot_c_term_variable_mods = new List<Modification>();
                        prot_c_term_variable_mods.Add(variable_modification);
                        possible_modifications.Add(Length + 3, prot_c_term_variable_mods);
                    }
                    else
                    {
                        prot_c_term_variable_mods.Add(variable_modification);
                    }
                }
            }

            int variable_modification_isoforms = 0;
            foreach(Dictionary<int, Modification> kvp in GetVariableModificationPatterns(possible_modifications))
            {
                Peptide peptide = new Peptide(this);
                peptide.FixedModifications = FixedModifications;
                peptide.VariableModifications = kvp;
                yield return peptide;
                variable_modification_isoforms++;
                if(variable_modification_isoforms == maximumVariableModificationIsoforms)
                {
                    yield break;
                }
            }
        }
예제 #8
0
        private void ScoreMatch(MassTolerance productMassTolerance)
        {
            double[] theoretical_product_masses = Peptide.CalculateProductMasses(PRODUCT_TYPES[Spectrum.FragmentationMethod]).ToArray();
            TotalProducts = theoretical_product_masses.Length;

            // speed optimizations
            int num_theoretical_products = theoretical_product_masses.Length;

            double[]           experimental_masses          = Spectrum.Masses;
            double[]           experimental_intensities     = Spectrum.Intensities;
            int                num_experimental_peaks       = experimental_masses.Length;
            double             product_mass_tolerance_value = productMassTolerance.Value;
            MassToleranceUnits product_mass_tolerance_units = productMassTolerance.Units;

            MatchingProducts = 0;
            int t = 0;
            int e = 0;

            while (t < num_theoretical_products && e < num_experimental_peaks)
            {
                double mass_difference = experimental_masses[e] - theoretical_product_masses[t];
                if (product_mass_tolerance_units == MassToleranceUnits.ppm)
                {
                    mass_difference = mass_difference / theoretical_product_masses[t] * 1e6;
                }
                if (Math.Abs(mass_difference) <= product_mass_tolerance_value)
                {
                    MatchingProducts++;
                    t++;
                }
                else if (mass_difference < 0)
                {
                    e++;
                }
                else if (mass_difference > 0)
                {
                    t++;
                }
            }
            MatchingProductsFraction = (double)MatchingProducts / TotalProducts;

            MatchingIntensity = 0.0;
            int e2 = 0;
            int t2 = 0;

            while (e2 < num_experimental_peaks && t2 < num_theoretical_products)
            {
                double mass_difference = experimental_masses[e2] - theoretical_product_masses[t2];
                if (product_mass_tolerance_units == MassToleranceUnits.ppm)
                {
                    mass_difference = mass_difference / theoretical_product_masses[t2] * 1e6;
                }
                if (Math.Abs(mass_difference) <= product_mass_tolerance_value)
                {
                    MatchingIntensity += experimental_intensities[e2];
                    e2++;
                }
                else if (mass_difference < 0)
                {
                    e2++;
                }
                else if (mass_difference > 0)
                {
                    t2++;
                }
            }
            MatchingIntensityFraction = MatchingIntensity / Spectrum.TotalIntensity;

            MorpheusScore = MatchingProducts + MatchingIntensityFraction;
        }
예제 #9
0
        public IEnumerable <Peptide> Digest(Protease protease, int maximumMissedCleavages, InitiatorMethionineBehavior initiatorMethionineBehavior,
                                            int?minimumPeptideLength, int?maximumPeptideLength)
        {
            if (Length > 0)
            {
                if (protease.CleavageSpecificity != CleavageSpecificity.None)
                {
                    // these are the 0-based residue indices the protease cleaves AFTER
                    List <int> indices = protease.GetDigestionSiteIndices(this);
                    indices.Insert(0, -1);
                    indices.Add(Length - 1);

                    if (protease.CleavageSpecificity == CleavageSpecificity.Full)
                    {
                        for (int missed_cleavages = 0; missed_cleavages <= maximumMissedCleavages; missed_cleavages++)
                        {
                            for (int i = 0; i < indices.Count - missed_cleavages - 1; i++)
                            {
                                if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Cleave || indices[i] + 1 != 0 || this[0] != 'M')
                                {
                                    int length = indices[i + missed_cleavages + 1] - indices[i];
                                    if ((!minimumPeptideLength.HasValue || length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || length <= maximumPeptideLength.Value))
                                    {
                                        // start residue number: +1 for starting at the next residue after the cleavage, +1 for 0->1 indexing
                                        // end residue number: +1 for 0->1 indexing
                                        Peptide peptide = new Peptide(this, indices[i] + 1 + 1, indices[i + missed_cleavages + 1] + 1, missed_cleavages);
                                        yield return(peptide);
                                    }
                                }

                                if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Retain && indices[i] + 1 == 0 && this[0] == 'M')
                                {
                                    int length = indices[i + missed_cleavages + 1] - indices[i] - 1;
                                    if (length > 0 && (!minimumPeptideLength.HasValue || length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || length <= maximumPeptideLength.Value))
                                    {
                                        // start residue number: +1 for skipping initiator methionine, +1 for starting at the next residue after the cleavage, +1 for 0->1 indexing
                                        // end residue number: +1 for 0->1 indexing
                                        Peptide peptide_without_initiator_methionine = new Peptide(this, indices[i] + 1 + 1 + 1, indices[i + missed_cleavages + 1] + 1, missed_cleavages);
                                        yield return(peptide_without_initiator_methionine);
                                    }
                                }
                            }
                        }
                    }
                    else  // protease.CleavageSpecificity == CleavageSpecificity.Semi || protease.CleavageSpecificity == CleavageSpecificity.SemiN || protease.CleavageSpecificity == CleavageSpecificity.SemiC
                    {
                        if (protease.CleavageSpecificity == CleavageSpecificity.Semi || protease.CleavageSpecificity == CleavageSpecificity.SemiN)
                        {
                            for (int missed_cleavages = 0; missed_cleavages <= maximumMissedCleavages; missed_cleavages++)
                            {
                                for (int i = 0; i < indices.Count - missed_cleavages - 1; i++)
                                {
                                    if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Cleave || indices[i] + 1 != 0 || this[0] != 'M')
                                    {
                                        // conditional ensures that we are generating peptides at their lowest missed cleavage state
                                        for (int length = indices[i + missed_cleavages + 1] - indices[i]; length > (indices[i + missed_cleavages + 1] - indices[i]) - (indices[i + missed_cleavages + 1] - indices[(i + missed_cleavages + 1) - 1]); length--)
                                        {
                                            if ((indices[i] + 1 + 1) + length - 1 <= Length)
                                            {
                                                if ((!minimumPeptideLength.HasValue || length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || length <= maximumPeptideLength.Value))
                                                {
                                                    // start residue number: +1 for starting at the next residue after the cleavage, +1 for 0->1 indexing
                                                    // end residue number: start residue number + length - 1
                                                    Peptide peptide = new Peptide(this, indices[i] + 1 + 1, (indices[i] + 1 + 1) + length - 1, missed_cleavages);
                                                    yield return(peptide);
                                                }
                                            }
                                        }
                                    }

                                    if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Retain && indices[i] + 1 == 0 && this[0] == 'M')
                                    {
                                        // conditional ensures that we are generating peptides at their lowest missed cleavage state
                                        for (int length = indices[i + missed_cleavages + 1] - indices[i]; length > (indices[i + missed_cleavages + 1] - indices[i]) - (indices[i + missed_cleavages + 1] - indices[(i + missed_cleavages + 1) - 1]); length--)
                                        {
                                            if ((indices[i] + 1 + 1 + 1) + length - 1 <= Length)
                                            {
                                                if ((!minimumPeptideLength.HasValue || length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || length <= maximumPeptideLength.Value))
                                                {
                                                    // start residue number: +1 for skipping initiator methionine, +1 for starting at the next residue after the cleavage, +1 for 0->1 indexing
                                                    // end residue number: start residue number + length - 1
                                                    Peptide peptide_without_initiator_methionine = new Peptide(this, indices[i] + 1 + 1 + 1, (indices[i] + 1 + 1 + 1) + length - 1, missed_cleavages);
                                                    yield return(peptide_without_initiator_methionine);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (protease.CleavageSpecificity == CleavageSpecificity.Semi || protease.CleavageSpecificity == CleavageSpecificity.SemiC)
                        {
                            for (int missed_cleavages = 0; missed_cleavages <= maximumMissedCleavages; missed_cleavages++)
                            {
                                for (int i = 0; i < indices.Count - missed_cleavages - 1; i++)
                                {
                                    // handling for initiator methionine not required

                                    // - (protease.CleavageSpecificity == CleavageSpecificity.Semi ? 1 : 0) ensures that we don't repeat the same peptides we generated above in the SemiN digestion
                                    // conditional ensures that we are generating peptides at their lowest missed cleavage state
                                    for (int length = indices[i + missed_cleavages + 1] - indices[i] - (protease.CleavageSpecificity == CleavageSpecificity.Semi ? 1 : 0); length > (indices[i + missed_cleavages + 1] - indices[i]) - (indices[i + 1] - indices[i]); length--)
                                    {
                                        if ((indices[i + missed_cleavages + 1] + 1) - length + 1 >= 1)
                                        {
                                            if ((!minimumPeptideLength.HasValue || length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || length <= maximumPeptideLength.Value))
                                            {
                                                // start residue number: end residue number - length + 1
                                                // end residue number: +1 for 0->1 indexing
                                                Peptide peptide = new Peptide(this, (indices[i + missed_cleavages + 1] + 1) - length + 1, indices[i + missed_cleavages + 1] + 1, missed_cleavages);
                                                yield return(peptide);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else  // protease.CleavageSpecificity == CleavageSpecificity.None
                {
                    if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Cleave || this[0] != 'M')
                    {
                        if ((!minimumPeptideLength.HasValue || Length >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || Length <= maximumPeptideLength.Value))
                        {
                            Peptide peptide = new Peptide(this, 1, Length, -1);
                            yield return(peptide);
                        }
                    }

                    if (initiatorMethionineBehavior != InitiatorMethionineBehavior.Retain && this[0] == 'M')
                    {
                        if (Length > 1 && (!minimumPeptideLength.HasValue || Length - 1 >= minimumPeptideLength.Value) && (!maximumPeptideLength.HasValue || Length - 1 <= maximumPeptideLength.Value))
                        {
                            Peptide peptide_without_initiator_methionine = new Peptide(this, 2, Length, -1);
                            yield return(peptide_without_initiator_methionine);
                        }
                    }
                }
            }
        }
예제 #10
0
 public void CopyFrom(Peptide peptide)
 {
     Init(peptide.Parent, peptide.StartResidueNumber, peptide.EndResidueNumber, peptide.MissedCleavages);
 }