com.compomics.util.experiment.biology
Class AminoAcidPattern

java.lang.Object
  extended by com.compomics.util.experiment.biology.AminoAcidPattern
All Implemented Interfaces:
Serializable

public class AminoAcidPattern
extends Object
implements Serializable

An amino acid pattern is a sequence of amino-acids. For example for trypsin: Target R or K not followed by P. the Indexing starts with 0.

Author:
Marc Vaudel
See Also:
Serialized Form

Constructor Summary
AminoAcidPattern()
          Creates an empty pattern.
AminoAcidPattern(AminoAcidPattern aminoAcidPattern)
          Creates a pattern from another pattern.
AminoAcidPattern(ArrayList<String> targetTesidues)
          Convenience constructor giving a list of targeted residues as input.
 
Method Summary
 ArrayList<AminoAcid> getAminoAcidsAtTarget()
          Returns the targeted amino acids at position "target".
 Pattern getAsStringPattern()
          Returns the amino acid pattern as case insensitive pattern for String matching.
 ArrayList<AminoAcid> getExcludedAA(int index)
          Returns the excluded amino acids at a given index in the pattern.
 ArrayList<Integer> getIndexes(String input)
          Returns the indexes where the amino acid pattern was found in the input. 0 is the first amino acid.
 AminoAcidPattern getStandardSearchPattern()
          Computes a pattern which can be searched by standard search engines, i.e., a pattern targeting a single amino-acid and not a complex pattern.
 Integer getTarget()
          Returns the index of the amino acid of interest in the pattern.
 ArrayList<AminoAcid> getTargetedAA(int index)
          Returns the targeted amino acids at a given index in the pattern.
static AminoAcidPattern getTrypsinExample()
          Returns the trypsin example as amino acid pattern.
 boolean isEnding(String aminoAcidSequence)
          Indicates whether the given amino acid sequence ends with the pattern.
 boolean isSameAs(AminoAcidPattern anotherPattern)
          Indicates whether another AminoAcidPattern targets the same pattern.
 boolean isStarting(String aminoAcidSequence)
          Indicates whether the given amino acid sequence starts with the pattern.
 int length()
          Returns the length of the pattern in amino acids.
 boolean matches(String aminoAcidSequence)
          Indicates whether the pattern is found in the given amino-acid sequence.
 void merge(AminoAcidPattern otherPattern)
          Simple merger for two patterns.
static AminoAcidPattern merge(AminoAcidPattern pattern1, AminoAcidPattern pattern2)
          Convenience method merging two different patterns (see public void merge(AminoAcidPattern otherPattern) for detailed information of the merging procedure).
 void removeAA(int index)
          Removes an amino acid index from the pattern.
 void setExcluded(int index, ArrayList<AminoAcid> exclusions)
          Sets the amino acids excluded at a given index.
 void setTarget(Integer target)
          Sets the index of the amino acid of interest in the pattern.
 void setTargeted(int index, ArrayList<AminoAcid> targets)
          Sets the amino acids targeted at a given index.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AminoAcidPattern

public AminoAcidPattern()
Creates an empty pattern.


AminoAcidPattern

public AminoAcidPattern(AminoAcidPattern aminoAcidPattern)
Creates a pattern from another pattern.

Parameters:
aminoAcidPattern - the other pattern

AminoAcidPattern

public AminoAcidPattern(ArrayList<String> targetTesidues)
                 throws IllegalArgumentException
Convenience constructor giving a list of targeted residues as input. For instance (S, T, Y)

Parameters:
targetTesidues - a list of targeted residues
Throws:
IllegalArgumentException - exception thrown whenever a letter is not recognized as amino acid
Method Detail

getTarget

public Integer getTarget()
Returns the index of the amino acid of interest in the pattern. Null if none.

Returns:
the index of the amino acid of interest in the pattern.

setTarget

public void setTarget(Integer target)
Sets the index of the amino acid of interest in the pattern.

Parameters:
target - the index of the amino acid of interest in the pattern.

getAminoAcidsAtTarget

public ArrayList<AminoAcid> getAminoAcidsAtTarget()
Returns the targeted amino acids at position "target". An empty list if none.

Returns:
the targeted amino acids at position "target"

setTargeted

public void setTargeted(int index,
                        ArrayList<AminoAcid> targets)
Sets the amino acids targeted at a given index.

Parameters:
index - the index in the pattern
targets - the amino acids targeted

getTargetedAA

public ArrayList<AminoAcid> getTargetedAA(int index)
Returns the targeted amino acids at a given index in the pattern.

Parameters:
index - the index in the pattern
Returns:
the targeted amino acids

getExcludedAA

public ArrayList<AminoAcid> getExcludedAA(int index)
Returns the excluded amino acids at a given index in the pattern.

Parameters:
index - the index in the pattern
Returns:
the excluded amino acids

setExcluded

public void setExcluded(int index,
                        ArrayList<AminoAcid> exclusions)
Sets the amino acids excluded at a given index. There shall be no excluded amino acid at the targeted index.

Parameters:
index - the index in the pattern
exclusions - the amino acids excluded

removeAA

public void removeAA(int index)
Removes an amino acid index from the pattern.

Parameters:
index - the index of the amino acid to remove

getAsStringPattern

public Pattern getAsStringPattern()
Returns the amino acid pattern as case insensitive pattern for String matching.

Returns:
the amino acid pattern as java string pattern

getIndexes

public ArrayList<Integer> getIndexes(String input)
Returns the indexes where the amino acid pattern was found in the input. 0 is the first amino acid.

Parameters:
input - the amino acid input sequence as string
Returns:
a list of indexes where the amino acid pattern was found

matches

public boolean matches(String aminoAcidSequence)
Indicates whether the pattern is found in the given amino-acid sequence.

Parameters:
aminoAcidSequence - the amino-acid sequence
Returns:
a boolean indicating whether the pattern is found in the given amino-acid sequence

isStarting

public boolean isStarting(String aminoAcidSequence)
Indicates whether the given amino acid sequence starts with the pattern.

Parameters:
aminoAcidSequence - the amino acid sequence
Returns:
a boolean indicating whether the given amino acid sequence starts with the pattern

isEnding

public boolean isEnding(String aminoAcidSequence)
Indicates whether the given amino acid sequence ends with the pattern.

Parameters:
aminoAcidSequence - the amino acid sequence
Returns:
a boolean indicating whether the given amino acid sequence ends with the pattern

isSameAs

public boolean isSameAs(AminoAcidPattern anotherPattern)
Indicates whether another AminoAcidPattern targets the same pattern.

Parameters:
anotherPattern - the other AminoAcidPattern
Returns:
true if the other AminoAcidPattern targets the same pattern

length

public int length()
Returns the length of the pattern in amino acids.

Returns:
the length of the pattern in amino acids

getStandardSearchPattern

public AminoAcidPattern getStandardSearchPattern()
Computes a pattern which can be searched by standard search engines, i.e., a pattern targeting a single amino-acid and not a complex pattern.

Returns:
a pattern which can be searched by standard search engines

getTrypsinExample

public static AminoAcidPattern getTrypsinExample()
Returns the trypsin example as amino acid pattern.

Returns:
the trypsin example as amino acid pattern

merge

public void merge(AminoAcidPattern otherPattern)
Simple merger for two patterns. To be used carefully. Example: this: target{0->S} exclusion{} otherPattern: target{0->T} exclusion{} result (this): target{0->S|T} exclusion{} Example of misuse: this: target{0->S} exclusion{0->null, 1>P} otherPattern: target{0->T, 1->P} exclusion{} result (this): target{0->S|T, 1->P} exclusion{0->null, 1>P}

Parameters:
otherPattern - another pattern to be merged with this

merge

public static AminoAcidPattern merge(AminoAcidPattern pattern1,
                                     AminoAcidPattern pattern2)
Convenience method merging two different patterns (see public void merge(AminoAcidPattern otherPattern) for detailed information of the merging procedure).

Parameters:
pattern1 - the first pattern
pattern2 - the second pattern
Returns:
a merged version of the two patterns

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.