java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.biology.proteins.Peptide
All Implemented Interfaces:
Serializable

public class Peptide
extends ExperimentObject
This class represents a peptide. Note that maps and lists provided in constructors are used in the class and not cloned.
Author:
Marc Vaudel, Dominik Kopczynski, Harald Barsnes
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • Peptide

      public Peptide()
      Constructor for the peptide.
    • Peptide

      public Peptide​(String aSequence, ModificationMatch[] variableModifications, HashMap<String,​HashMap<Integer,​PeptideVariantMatches>> variantMatches, boolean sanityCheck, double mass)
      Constructor.
      Parameters:
      aSequence - the peptide sequence, assumed to be in upper case only
      variableModifications - the variable modifications of this peptide
      variantMatches - the sequence variants compared to the database
      sanityCheck - boolean indicating whether the input should be checked
      mass - the mass of the peptide
    • Peptide

      public Peptide​(String aSequence, ModificationMatch[] variableModifications, boolean sanityCheck, double mass)
      Constructor.
      Parameters:
      aSequence - the peptide sequence, assumed to be in upper case only
      variableModifications - the variable modification of this peptide
      sanityCheck - boolean indicating whether the input should be checked
      mass - the mass of the peptide
    • Peptide

      public Peptide​(String aSequence, ModificationMatch[] variableModifications, boolean sanityCheck)
      Constructor.
      Parameters:
      aSequence - the peptide sequence, assumed to be in upper case only
      variableModifications - the variable modification of this peptide
      sanityCheck - boolean indicating whether the input should be checked
    • Peptide

      public Peptide​(String aSequence)
      Constructor. No sanity check is performed on the input.
      Parameters:
      aSequence - the peptide sequence
    • Peptide

      public Peptide​(String aSequence, ModificationMatch[] variableModifications)
      Constructor. No sanity check is performed on the input.
      Parameters:
      aSequence - the peptide sequence, assumed to be in upper case only
      variableModifications - the variable modification of this peptide
    • Peptide

      public Peptide​(String aSequence, ModificationMatch[] variableModifications, HashMap<String,​HashMap<Integer,​PeptideVariantMatches>> variantMatches, boolean sanityCheck)
      Constructor for the peptide.
      Parameters:
      aSequence - the peptide sequence, assumed to be in upper case only
      variableModifications - the variable modifications of this peptide
      variantMatches - the variants compared to the database
      sanityCheck - boolean indicating whether the input should be checked
  • Method Details

    • setMass

      public void setMass​(double mass)
      Sets the mass.
      Parameters:
      mass - the mass
    • setKey

      public void setKey​(long key)
      Sets the object key.
      Parameters:
      key - the object key
    • getProteinMapping

      public TreeMap<String,​int[]> getProteinMapping()
      Returns the proteins mapping as a map of 0 based indexes for every protein accession.
      Returns:
      the proteins mapping
    • setProteinMapping

      public void setProteinMapping​(TreeMap<String,​int[]> proteinMapping)
      Sets the proteins mapping as a map of 0 based indexes for every protein accession.
      Parameters:
      proteinMapping - the proteins mapping
    • setVariantMatches

      public void setVariantMatches​(HashMap<String,​HashMap<Integer,​PeptideVariantMatches>> variantMatches)
      Sets the sequence variant matches of this peptide.
      Parameters:
      variantMatches - the variant matches of this peptide
    • getVariantMatches

      public HashMap<String,​HashMap<Integer,​PeptideVariantMatches>> getVariantMatches()
      Returns the sequence variant matches of this peptide indexed by protein accession and peptide start.
      Returns:
      the sequence variant matches of this peptide
    • getMass

      public double getMass()
      Returns the mass, does not attempt to estimate it. An exception is thrown if the mass was not previously estimated.
      Returns:
      the peptide mass
    • getMass

      public double getMass​(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationSequenceMatchingParameters)
      Returns the mass, estimates it if not done before.
      Parameters:
      modificationParameters - the modifications parameters
      sequenceProvider - a protein sequence provider
      modificationSequenceMatchingParameters - the modifications sequence matching parameters
      Returns:
      the peptide mass
    • getVariableModifications

      public ModificationMatch[] getVariableModifications()
      Returns the variable modifications.
      Returns:
      the variable modifications
    • getIndexedVariableModifications

      public String[] getIndexedVariableModifications()
      Returns the variable modifications indexed by site. Modifications are indexed by site as follows: N-term modifications are at index 0, C-term at sequence length + 1, and amino acid at 1-based index on the sequence.
      Returns:
      the variable modifications indexed by site
    • getFixedModifications

      public String[] getFixedModifications​(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters)
      Returns the fixed modifications for this peptide based on the given modification parameters. Modifications are returned as array of modification names as they appear on the peptide. N-term modifications are at index 0, C-term at index sequence length + 1, and other modifications at amino acid index starting from 1. An error is thrown if attempting to stack modifications.
      Parameters:
      modificationParameters - the modification parameters the modification parameters
      sequenceProvider - a protein sequence provider
      modificationsSequenceMatchingParameters - the sequence matching parameters to use for modifications
      Returns:
      the fixed modifications for this peptide
    • setVariableModifications

      public void setVariableModifications​(ModificationMatch[] variableModifications)
      Sets the variable modifications.
      Parameters:
      variableModifications - the variable modifications
    • clearVariableModifications

      public void clearVariableModifications()
      Clears the variable modifications.
    • addVariableModification

      public void addVariableModification​(ModificationMatch modificationMatch)
      Adds a modification match.
      Parameters:
      modificationMatch - the modification match to add
    • clearVariantMatches

      public void clearVariantMatches()
      Clears the list of imported variant matches.
    • getPeptideEnd

      public int getPeptideEnd​(String proteinAccession, int peptideStart)
      Returns the 0 based end index of the peptide on the protein sequence.
      Parameters:
      proteinAccession - the protein accession
      peptideStart - the peptide start index
      Returns:
      the 0 based end index of the peptide on the protein sequence
    • getSequence

      public String getSequence()
      Returns for the sequence.
      Returns:
      the peptide sequence
    • setSequence

      public void setSequence​(String sequence)
      Sets for the sequence.
      Parameters:
      sequence - the peptide sequence
    • getNMissedCleavages

      public int getNMissedCleavages​(Enzyme enzyme)
      Returns the number of missed cleavages using the specified enzyme.
      Parameters:
      enzyme - the enzyme used
      Returns:
      the amount of missed cleavages
    • getNMissedCleavages

      public int getNMissedCleavages​(DigestionParameters digestionPreferences)
      Returns the number of missed cleavages using the digestion preferences. 0 if no cleavage set. If multiple enzymes were used, the minimum across the different enzymes.
      Parameters:
      digestionPreferences - the digestion preferences
      Returns:
      the amount of missed cleavages
    • getMatchingKey

      public long getMatchingKey()
      Returns the key accounting for sequence matching preferences
      Returns:
      the key accounting for sequence matching preferences
    • setMatchingKey

      public void setMatchingKey​(long matchingKey)
      Sets the key accounting for sequence matching preferences.
      Parameters:
      matchingKey - the key accounting for sequence matching preferences
    • getMatchingKey

      public long getMatchingKey​(SequenceMatchingParameters sequenceMatchingPreferences)
      Returns a unique key for the peptide when considering the given matching preferences. When ambiguity the first amino acid according to AminoAcid.getAminoAcidsList() will be selected. For example the matching key of peptide PEPTLDE_mod1_mod2 is PEPTIDE_mod1_mod2
      Parameters:
      sequenceMatchingPreferences - the sequence matching preferences
      Returns:
      a key unique to the given matching type
    • getKey

      public long getKey()
      Returns the reference key of a peptide. index = SEQUENCE_modMass1_modMass2 with modMass1 and modMass2 modification masses ordered alphabetically. See ExperimentObject for the conversion to long. Note: the key is not unique for indistinguishable sequences, see getMatchingKey(SequenceMatchingPreferences sequenceMatchingPreferences). Modifications must be loaded in the modification factory.
      Returns:
      the key of the peptide
    • getKey

      public static long getKey​(String sequence, ModificationMatch[] variableModifications)
      Returns the reference key of a peptide. key = SEQUENCE_mod1_mod2 modMass1 and modMass2 modification masses ordered alphabetically.
      Parameters:
      sequence - the sequence of the peptide
      variableModifications - list of modification matches
      Returns:
      the key of the peptide
    • getNVariableModifications

      public int getNVariableModifications​(double modificationMass)
      Returns the number of variable modifications found with the given mass.
      Parameters:
      modificationMass - the mass of the modification
      Returns:
      the number of occurrences of this modification
    • getNVariableModifications

      public int getNVariableModifications()
      Returns the number of modifications carried by this peptide.
      Returns:
      the number of modifications carried by this peptide
    • getPotentialModificationSitesNoCombination

      public ArrayList<Integer> getPotentialModificationSitesNoCombination​(Modification modification, String proteinSequence, int peptideStart)
      Returns the potential modification sites as an ordered list of sites. No amino acid combination is tested. 1 is the first amino acid. An empty list is returned if no possibility was found. No peptide to protein mapping is done. The index on the protein must be provided with 0 as first amino acid.
      Parameters:
      modification - the Modification considered
      proteinSequence - the protein sequence
      peptideStart - the index of the peptide start on the protein
      Returns:
      a list of potential modification sites
    • isSameSequenceAndModificationStatus

      public boolean isSameSequenceAndModificationStatus​(Peptide anotherPeptide, SequenceMatchingParameters sequenceMatchingPreferences)
      Indicates whether another peptide has the same sequence and modification status without accounting for modification localization.
      Parameters:
      anotherPeptide - the other peptide to compare to this instance
      sequenceMatchingPreferences - the sequence matching preferences
      Returns:
      a boolean indicating whether the other peptide has the same sequence and modification status.
    • isSameSequence

      public boolean isSameSequence​(Peptide anotherPeptide, SequenceMatchingParameters sequenceMatchingPreferences)
      Returns a boolean indicating whether another peptide has the same sequence as the given peptide
      Parameters:
      anotherPeptide - the other peptide to compare
      sequenceMatchingPreferences - the sequence matching preferences
      Returns:
      a boolean indicating whether the other peptide has the same sequence
    • isSameModificationStatus

      public boolean isSameModificationStatus​(Peptide anotherPeptide)
      Indicates whether another peptide has the same variable modifications as this peptide. The localization of the Modification is not accounted for. Modifications are considered equal when of exact same mass, no rounding is conducted. Modifications should be loaded in the Modification factory. Fixed modifications are not inspected.
      Parameters:
      anotherPeptide - the other peptide
      Returns:
      a boolean indicating whether the other peptide has the same variable modifications as the peptide of interest
    • sameModificationsAs

      public boolean sameModificationsAs​(Peptide anotherPeptide, ArrayList<String> modifications)
      Indicates whether another peptide has the same variable modifications at the same localization as this peptide. This method comes as a complement of isSameAs, here the localization of all Modifications is taken into account. Modifications are considered equal when of same mass. Modifications should be loaded in the Modification factory. Fixed modifications are not inspected.
      Parameters:
      anotherPeptide - another peptide
      modifications - the Modifications
      Returns:
      true if the other peptide has the same positions at the same location as the considered peptide
    • sameModificationsAs

      public boolean sameModificationsAs​(Peptide anotherPeptide)
      Indicates whether another peptide has the same modifications at the same localization as this peptide. This method comes as a complement of isSameAs, here the localization of all Modifications is taken into account. Modifications are considered equal when of same mass. Modifications should be loaded in the Modification factory. Fixed modifications are not inspected.
      Parameters:
      anotherPeptide - another peptide
      Returns:
      true if the other peptide has the same positions at the same location as the considered peptide
    • getTaggedModifiedSequence

      public String getTaggedModifiedSequence​(ModificationParameters modificationProfile, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters, boolean useHtmlColorCoding, boolean includeHtmlStartEndTags, boolean useShortName, HashSet<String> displayedModifications)
      Returns the modified sequence as an tagged string with potential modification sites color coded or with Modification tags, e.g, <mox>. /!\ this method will work only if the Modification found in the peptide are in the ModificationFactory. /!\ This method uses the modifications as set in the modification matches of this peptide and displays all of them.
      Parameters:
      modificationProfile - the modification profile of the search
      sequenceProvider - a protein sequence provider
      modificationsSequenceMatchingParameters - the sequence matching parameters to use for modifications
      useHtmlColorCoding - if true, color coded HTML is used, otherwise Modification tags, e.g, <mox>, are used
      includeHtmlStartEndTags - if true, start and end HTML tags are added
      useShortName - if true the short names are used in the tags
      displayedModifications - the modifications to display
      Returns:
      the modified sequence as a tagged string
    • estimateTheoreticMass

      public void estimateTheoreticMass​(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationSequenceMatchingParameters)
      Estimates the theoretic mass of the peptide. The previous version is silently overwritten.
      Parameters:
      modificationParameters - the modifications parameters
      sequenceProvider - a protein sequence provider
      modificationSequenceMatchingParameters - the modifications sequence matching parameters
    • getNoModPeptide

      public Peptide getNoModPeptide​(HashSet<String> forbiddenModifications)
      Returns a version of the peptide which does not contain the given list of modifications.
      Parameters:
      forbiddenModifications - list of forbidden modifications
      Returns:
      a not modified version of the peptide