Package jgromacs.data
Class Sequence
- java.lang.Object
-
- jgromacs.data.Sequence
-
- All Implemented Interfaces:
java.lang.Cloneable
public class Sequence extends java.lang.Object implements java.lang.Cloneable
Objects of this class represent a single amino acid sequence
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGap()
Adds a new gap to the sequencevoid
addPosition(int index, ResidueType type)
Adds a new position of given index and residue type to the sequencevoid
addPosition(int index, ResidueType type, java.lang.String annotation)
Adds a new position of given index, residue type and annotation to the sequencevoid
addPosition(SequencePosition pos)
Adds a new position to the sequencevoid
addPosition(ResidueType type, java.lang.String annotation)
Adds a new position of given residue type and annotation to the sequencevoid
addPositionsFromString(java.lang.String str)
Adds a series of new positions to the sequence taken from a String objectjava.lang.Object
clone()
Returns an identical Sequence objectSequence
concat(Sequence other)
Returns the given sequence concatenated to this sequenceboolean
containsSubSequence(Sequence subsequence)
Returns true if the given subsequence is contained in this sequenceboolean
equals(java.lang.Object other)
Returns true if the two sequences are identicaljava.lang.String
getAnnotationOfPosition(int i)
Returns the annotation of sequence position #ijava.lang.String
getAnnotationOfPositionOfIndex(int index)
Returns the annotation of sequence position of given indexjava.util.ArrayList<SequencePosition>
getAsArrayList()
Returns sequence as an ArrayList objectint
getIndexOfPosition(int i)
Returns the index of sequence position #ijava.lang.String
getName()
Returns the name of sequenceSequencePosition
getPosition(int i)
Returns sequence position #iSequencePosition
getPositionByIndex(int index)
Returns sequence position of given indexResidueType
getResidueTypeOfPosition(int i)
Returns the residue type of sequence position #iResidueType
getResidueTypeOfPositionOfIndex(int index)
Returns the residue type of sequence position of given indexSequence
getReverse()
Returns the reverse sequenceint
getSequenceLength()
Returns the length of sequence (gaps excluded)int
getSequenceLengthWithGaps()
Returns the length of sequence (gaps included)Sequence
getSubSequence(int begin, int end)
Returns subsequence beginning at sequence position #begin and ending at sequence position #endSequence
getSubSequenceFrom(int begin)
Returns subsequence beginning at sequence position #beginSequence
getSubSequenceTo(int end)
Returns subsequence ending at sequence position #endint
hashCode()
Returns hash codevoid
insertGap(int i)
Inserts a new gap to position #ivoid
insertPosition(int i, int index, ResidueType type)
Inserts sequence position of given index and residue type to position #i Note that you may have to re-index sequence positions after using this methodvoid
insertPosition(int i, int index, ResidueType type, java.lang.String annotation)
Inserts sequence position of given index, residue type and annotation to position #i Note that you may have to re-index sequence positions after using this methodvoid
insertPosition(int i, SequencePosition pos)
Inserts the given sequence position to position #i Note that you may have to re-index sequence positions after using this methodvoid
insertPosition(int i, ResidueType type, java.lang.String annotation)
Inserts sequence position of given residue type and annotation to position #i Note that you may have to re-index sequence positions after using this methodboolean
isPositionAGap(int i)
Returns true if sequence position #i is a gapvoid
reIndexPositions()
Reindexes all positions in the sequence starting from 1void
reIndexPositions(int startindex)
Reindexes all positions in the sequence starting from a given indexvoid
removeGaps()
Removes all gaps from the sequencevoid
removePosition(int i)
Removes sequence position #ivoid
removePosition(SequencePosition pos)
Removes the given sequence positionvoid
removePositionByIndex(int index)
Removes the sequence position of given indexvoid
setName(java.lang.String name)
Sets the name of sequencevoid
setPosition(int i, int index, ResidueType type)
Replaces position #i with the a sequence position of given index and residue typevoid
setPosition(int i, int index, ResidueType type, java.lang.String annotation)
Replaces position #i with the a sequence position of given index, residue type and annotationvoid
setPosition(int i, SequencePosition pos)
Replaces position #i with the given sequence positionvoid
setPosition(int i, ResidueType type, java.lang.String annotation)
Replaces position #i with the a sequence position of given residue type and annotationvoid
setPositionByIndex(int index, ResidueType type)
Replaces the position of given index with the a sequence position of given residue typevoid
setPositionByIndex(int index, ResidueType type, java.lang.String annotation)
Replaces the position of given index with the a sequence position of given residue type and annotationjava.lang.String
toString()
Returns the String representation of sequencejava.lang.String
toString1Letter()
Returns a String representation in which each residue is represented by its 1 letter codejava.lang.String
toString1Letter(int lengthOfLine)
Returns a String representation in which each residue is represented by its 1 letter code and the string is split to lines of the given lengthjava.lang.String
toString3Letter()
Returns a String representation in which each residue is represented by its 3 letter codejava.lang.String
toString3Letter(int lengthOfLine)
Returns a String representation in which each residue is represented by its 3 letter code and the string is split to lines of the given lengthjava.lang.String
toStringInfo()
Returns summary information about the sequence
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of sequence- Returns:
- name of sequence
-
setName
public void setName(java.lang.String name)
Sets the name of sequence- Parameters:
name
- name of sequence
-
getAsArrayList
public java.util.ArrayList<SequencePosition> getAsArrayList()
Returns sequence as an ArrayList object- Returns:
- sequence as an ArrayList
-
getSequenceLength
public int getSequenceLength()
Returns the length of sequence (gaps excluded)- Returns:
- length of sequence
-
getSequenceLengthWithGaps
public int getSequenceLengthWithGaps()
Returns the length of sequence (gaps included)- Returns:
- length of sequence
-
getPosition
public SequencePosition getPosition(int i)
Returns sequence position #i- Returns:
- sequence position #i
-
getPositionByIndex
public SequencePosition getPositionByIndex(int index)
Returns sequence position of given index- Parameters:
index
- index of position- Returns:
- sequence position of given index
-
getIndexOfPosition
public int getIndexOfPosition(int i)
Returns the index of sequence position #i- Returns:
- index of sequence position
-
getResidueTypeOfPosition
public ResidueType getResidueTypeOfPosition(int i)
Returns the residue type of sequence position #i- Returns:
- residue type of sequence position
-
getAnnotationOfPosition
public java.lang.String getAnnotationOfPosition(int i)
Returns the annotation of sequence position #i- Returns:
- annotation of sequence position
-
getResidueTypeOfPositionOfIndex
public ResidueType getResidueTypeOfPositionOfIndex(int index)
Returns the residue type of sequence position of given index- Parameters:
index
- index of position- Returns:
- residue type of sequence position
-
getAnnotationOfPositionOfIndex
public java.lang.String getAnnotationOfPositionOfIndex(int index)
Returns the annotation of sequence position of given index- Parameters:
index
- index of position- Returns:
- annotation of sequence position
-
addPosition
public void addPosition(SequencePosition pos)
Adds a new position to the sequence- Parameters:
pos
- new sequence position
-
addPosition
public void addPosition(ResidueType type, java.lang.String annotation)
Adds a new position of given residue type and annotation to the sequence- Parameters:
type
- residue type of new positionannotation
- annotation of new position
-
addPosition
public void addPosition(int index, ResidueType type)
Adds a new position of given index and residue type to the sequence- Parameters:
index
- index of new positiontype
- residue type of new position
-
addPosition
public void addPosition(int index, ResidueType type, java.lang.String annotation)
Adds a new position of given index, residue type and annotation to the sequence- Parameters:
index
- index of new positiontype
- residue type of new positionannotation
- annotation of new position
-
addPositionsFromString
public void addPositionsFromString(java.lang.String str)
Adds a series of new positions to the sequence taken from a String object- Parameters:
str
- String object encoding a series of sequence positions
-
addGap
public void addGap()
Adds a new gap to the sequence
-
insertGap
public void insertGap(int i)
Inserts a new gap to position #i
-
setPosition
public void setPosition(int i, SequencePosition pos)
Replaces position #i with the given sequence position- Parameters:
pos
- new sequence position
-
setPosition
public void setPosition(int i, ResidueType type, java.lang.String annotation)
Replaces position #i with the a sequence position of given residue type and annotation- Parameters:
type
- residue type of new sequence positionannotation
- annotation of new sequence position
-
setPosition
public void setPosition(int i, int index, ResidueType type)
Replaces position #i with the a sequence position of given index and residue type- Parameters:
index
- index of new sequence positiontype
- residue type of new sequence position
-
setPosition
public void setPosition(int i, int index, ResidueType type, java.lang.String annotation)
Replaces position #i with the a sequence position of given index, residue type and annotation- Parameters:
index
- index of new sequence positiontype
- residue type of new sequence positionannotation
- annotation of new sequence position
-
setPositionByIndex
public void setPositionByIndex(int index, ResidueType type, java.lang.String annotation)
Replaces the position of given index with the a sequence position of given residue type and annotation- Parameters:
index
- index of sequence positiontype
- residue type of new sequence positionannotation
- annotation of new sequence position
-
setPositionByIndex
public void setPositionByIndex(int index, ResidueType type)
Replaces the position of given index with the a sequence position of given residue type- Parameters:
index
- index of sequence positiontype
- residue type of new sequence position
-
removePosition
public void removePosition(int i)
Removes sequence position #i
-
removePosition
public void removePosition(SequencePosition pos)
Removes the given sequence position- Parameters:
pos
- sequence position to be removed
-
removePositionByIndex
public void removePositionByIndex(int index)
Removes the sequence position of given index- Parameters:
index
- index of sequence position to be removed
-
removeGaps
public void removeGaps()
Removes all gaps from the sequence
-
reIndexPositions
public void reIndexPositions(int startindex)
Reindexes all positions in the sequence starting from a given index- Parameters:
startindex
- index of position #0
-
reIndexPositions
public void reIndexPositions()
Reindexes all positions in the sequence starting from 1
-
insertPosition
public void insertPosition(int i, SequencePosition pos)
Inserts the given sequence position to position #i Note that you may have to re-index sequence positions after using this method- Parameters:
pos
- new sequence position
-
insertPosition
public void insertPosition(int i, ResidueType type, java.lang.String annotation)
Inserts sequence position of given residue type and annotation to position #i Note that you may have to re-index sequence positions after using this method- Parameters:
type
- residue type of new sequence positionannotation
- annotation of new sequence position
-
insertPosition
public void insertPosition(int i, int index, ResidueType type)
Inserts sequence position of given index and residue type to position #i Note that you may have to re-index sequence positions after using this method- Parameters:
index
- index of new sequence positiontype
- residue type of new sequence position
-
insertPosition
public void insertPosition(int i, int index, ResidueType type, java.lang.String annotation)
Inserts sequence position of given index, residue type and annotation to position #i Note that you may have to re-index sequence positions after using this method- Parameters:
index
- index of new sequence positiontype
- residue type of new sequence positionannotation
- annotation of new sequence position
-
isPositionAGap
public boolean isPositionAGap(int i)
Returns true if sequence position #i is a gap
-
getSubSequence
public Sequence getSubSequence(int begin, int end)
Returns subsequence beginning at sequence position #begin and ending at sequence position #end- Parameters:
begin
- start position of subsequenceend
- end position of subsequence- Returns:
- subsequence
-
getSubSequenceFrom
public Sequence getSubSequenceFrom(int begin)
Returns subsequence beginning at sequence position #begin- Parameters:
begin
- start position of subsequence- Returns:
- subsequence
-
getSubSequenceTo
public Sequence getSubSequenceTo(int end)
Returns subsequence ending at sequence position #end- Parameters:
end
- end position of subsequence- Returns:
- subsequence
-
getReverse
public Sequence getReverse()
Returns the reverse sequence- Returns:
- reverse sequence
-
concat
public Sequence concat(Sequence other)
Returns the given sequence concatenated to this sequence- Parameters:
other
- second sequence- Returns:
- concatenated sequence
-
containsSubSequence
public boolean containsSubSequence(Sequence subsequence)
Returns true if the given subsequence is contained in this sequence- Parameters:
subsequence
- subsequence to search for
-
toString
public java.lang.String toString()
Returns the String representation of sequence- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation
-
toString1Letter
public java.lang.String toString1Letter()
Returns a String representation in which each residue is represented by its 1 letter code- Returns:
- String representation
-
toString3Letter
public java.lang.String toString3Letter()
Returns a String representation in which each residue is represented by its 3 letter code- Returns:
- String representation
-
toString1Letter
public java.lang.String toString1Letter(int lengthOfLine)
Returns a String representation in which each residue is represented by its 1 letter code and the string is split to lines of the given length- Parameters:
lengthOfLine
- max length of a line in the string- Returns:
- String representation
-
toString3Letter
public java.lang.String toString3Letter(int lengthOfLine)
Returns a String representation in which each residue is represented by its 3 letter code and the string is split to lines of the given length- Parameters:
lengthOfLine
- max length of a line (number of residues) in the string- Returns:
- String representation
-
toStringInfo
public java.lang.String toStringInfo()
Returns summary information about the sequence- Returns:
- summary information
-
clone
public java.lang.Object clone()
Returns an identical Sequence object- Overrides:
clone
in classjava.lang.Object
- Returns:
- clone of the sequence
-
equals
public boolean equals(java.lang.Object other)
Returns true if the two sequences are identical- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- the other sequence
-
hashCode
public int hashCode()
Returns hash code- Overrides:
hashCode
in classjava.lang.Object
-
-