Class Peptide
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 Summary
Fields Modifier and Type Field Description static String
MODIFICATION_LOCALIZATION_SEPARATOR
Separator preceding confident localization of the confident localization of a modification.static String
MODIFICATION_SEPARATOR
Separator used to separate modifications in peptide keys as string. -
Constructor Summary
Constructors Constructor Description Peptide()
Constructor for the peptide.Peptide(String aSequence)
Constructor.Peptide(String aSequence, ModificationMatch[] variableModifications)
Constructor.Peptide(String aSequence, ModificationMatch[] variableModifications, boolean sanityCheck)
Constructor.Peptide(String aSequence, ModificationMatch[] variableModifications, boolean sanityCheck, double mass)
Constructor.Peptide(String aSequence, ModificationMatch[] variableModifications, HashMap<String,HashMap<Integer,PeptideVariantMatches>> variantMatches, boolean sanityCheck)
Constructor for the peptide.Peptide(String aSequence, ModificationMatch[] variableModifications, HashMap<String,HashMap<Integer,PeptideVariantMatches>> variantMatches, boolean sanityCheck, double mass)
Constructor. -
Method Summary
Modifier and Type Method Description void
addVariableModification(ModificationMatch modificationMatch)
Adds a modification match.void
clearVariableModifications()
Clears the variable modifications.void
clearVariantMatches()
Clears the list of imported variant matches.void
estimateTheoreticMass(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationSequenceMatchingParameters)
Estimates the theoretic mass of the peptide.String[]
getFixedModifications(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters)
Returns the fixed modifications for this peptide based on the given modification parameters.String[]
getIndexedVariableModifications()
Returns the variable modifications indexed by site.long
getKey()
Returns the reference key of a peptide.static long
getKey(String sequence, ModificationMatch[] variableModifications)
Returns the reference key of a peptide.double
getMass()
Returns the mass, does not attempt to estimate it.double
getMass(ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationSequenceMatchingParameters)
Returns the mass, estimates it if not done before.long
getMatchingKey()
Returns the key accounting for sequence matching preferenceslong
getMatchingKey(SequenceMatchingParameters sequenceMatchingPreferences)
Returns a unique key for the peptide when considering the given matching preferences.int
getNMissedCleavages(Enzyme enzyme)
Returns the number of missed cleavages using the specified enzyme.int
getNMissedCleavages(DigestionParameters digestionPreferences)
Returns the number of missed cleavages using the digestion preferences.Peptide
getNoModPeptide(HashSet<String> forbiddenModifications)
Returns a version of the peptide which does not contain the given list of modifications.int
getNVariableModifications()
Returns the number of modifications carried by this peptide.int
getNVariableModifications(double modificationMass)
Returns the number of variable modifications found with the given mass.int
getPeptideEnd(String proteinAccession, int peptideStart)
Returns the 0 based end index of the peptide on the protein sequence.ArrayList<Integer>
getPotentialModificationSitesNoCombination(Modification modification, String proteinSequence, int peptideStart)
Returns the potential modification sites as an ordered list of sites.TreeMap<String,int[]>
getProteinMapping()
Returns the proteins mapping as a map of 0 based indexes for every protein accession.String
getSequence()
Returns for the sequence.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>.ModificationMatch[]
getVariableModifications()
Returns the variable modifications.HashMap<String,HashMap<Integer,PeptideVariantMatches>>
getVariantMatches()
Returns the sequence variant matches of this peptide indexed by protein accession and peptide start.boolean
isSameModificationStatus(Peptide anotherPeptide)
Indicates whether another peptide has the same variable modifications as this peptide.boolean
isSameSequence(Peptide anotherPeptide, SequenceMatchingParameters sequenceMatchingPreferences)
Returns a boolean indicating whether another peptide has the same sequence as the given peptideboolean
isSameSequenceAndModificationStatus(Peptide anotherPeptide, SequenceMatchingParameters sequenceMatchingPreferences)
Indicates whether another peptide has the same sequence and modification status without accounting for modification localization.boolean
sameModificationsAs(Peptide anotherPeptide)
Indicates whether another peptide has the same modifications at the same localization as this peptide.boolean
sameModificationsAs(Peptide anotherPeptide, ArrayList<String> modifications)
Indicates whether another peptide has the same variable modifications at the same localization as this peptide.void
setKey(long key)
Sets the object key.void
setMass(double mass)
Sets the mass.void
setMatchingKey(long matchingKey)
Sets the key accounting for sequence matching preferences.void
setProteinMapping(TreeMap<String,int[]> proteinMapping)
Sets the proteins mapping as a map of 0 based indexes for every protein accession.void
setSequence(String sequence)
Sets for the sequence.void
setVariableModifications(ModificationMatch[] variableModifications)
Sets the variable modifications.void
setVariantMatches(HashMap<String,HashMap<Integer,PeptideVariantMatches>> variantMatches)
Sets the sequence variant matches of this peptide.Methods inherited from class com.compomics.util.experiment.personalization.ExperimentObject
addUrParam, asLong, clearParametersMap, getId, getUrParam, getUrParams, removeUrParam, setId, setUrParams
-
Field Details
-
MODIFICATION_LOCALIZATION_SEPARATOR
Separator preceding confident localization of the confident localization of a modification.- See Also:
- Constant Field Values
-
MODIFICATION_SEPARATOR
Separator used to separate modifications in peptide keys as string.- See Also:
- Constant Field Values
-
-
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 onlyvariableModifications
- the variable modifications of this peptidevariantMatches
- the sequence variants compared to the databasesanityCheck
- boolean indicating whether the input should be checkedmass
- 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 onlyvariableModifications
- the variable modification of this peptidesanityCheck
- boolean indicating whether the input should be checkedmass
- the mass of the peptide
-
Peptide
Constructor.- Parameters:
aSequence
- the peptide sequence, assumed to be in upper case onlyvariableModifications
- the variable modification of this peptidesanityCheck
- boolean indicating whether the input should be checked
-
Peptide
Constructor. No sanity check is performed on the input.- Parameters:
aSequence
- the peptide sequence
-
Peptide
Constructor. No sanity check is performed on the input.- Parameters:
aSequence
- the peptide sequence, assumed to be in upper case onlyvariableModifications
- 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 onlyvariableModifications
- the variable modifications of this peptidevariantMatches
- the variants compared to the databasesanityCheck
- 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
Returns the proteins mapping as a map of 0 based indexes for every protein accession.- Returns:
- the proteins mapping
-
setProteinMapping
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
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 parameterssequenceProvider
- a protein sequence providermodificationSequenceMatchingParameters
- the modifications sequence matching parameters- Returns:
- the peptide mass
-
getVariableModifications
Returns the variable modifications.- Returns:
- the variable modifications
-
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 parameterssequenceProvider
- a protein sequence providermodificationsSequenceMatchingParameters
- the sequence matching parameters to use for modifications- Returns:
- the fixed modifications for this peptide
-
setVariableModifications
Sets the variable modifications.- Parameters:
variableModifications
- the variable modifications
-
clearVariableModifications
public void clearVariableModifications()Clears the variable modifications. -
addVariableModification
Adds a modification match.- Parameters:
modificationMatch
- the modification match to add
-
clearVariantMatches
public void clearVariantMatches()Clears the list of imported variant matches. -
getPeptideEnd
Returns the 0 based end index of the peptide on the protein sequence.- Parameters:
proteinAccession
- the protein accessionpeptideStart
- the peptide start index- Returns:
- the 0 based end index of the peptide on the protein sequence
-
getSequence
Returns for the sequence.- Returns:
- the peptide sequence
-
setSequence
Sets for the sequence.- Parameters:
sequence
- the peptide sequence
-
getNMissedCleavages
Returns the number of missed cleavages using the specified enzyme.- Parameters:
enzyme
- the enzyme used- Returns:
- the amount of missed cleavages
-
getNMissedCleavages
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
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
Returns the reference key of a peptide. key = SEQUENCE_mod1_mod2 modMass1 and modMass2 modification masses ordered alphabetically.- Parameters:
sequence
- the sequence of the peptidevariableModifications
- 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 consideredproteinSequence
- the protein sequencepeptideStart
- 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 instancesequenceMatchingPreferences
- 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 comparesequenceMatchingPreferences
- the sequence matching preferences- Returns:
- a boolean indicating whether the other peptide has the same sequence
-
isSameModificationStatus
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
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 peptidemodifications
- the Modifications- Returns:
- true if the other peptide has the same positions at the same location as the considered peptide
-
sameModificationsAs
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 searchsequenceProvider
- a protein sequence providermodificationsSequenceMatchingParameters
- the sequence matching parameters to use for modificationsuseHtmlColorCoding
- if true, color coded HTML is used, otherwise Modification tags, e.g, <mox>, are usedincludeHtmlStartEndTags
- if true, start and end HTML tags are addeduseShortName
- if true the short names are used in the tagsdisplayedModifications
- 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 parameterssequenceProvider
- a protein sequence providermodificationSequenceMatchingParameters
- the modifications sequence matching parameters
-
getNoModPeptide
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
-