Package jgromacs.data

# Class Sequence

java.lang.Object
jgromacs.data.Sequence

All Implemented Interfaces:
  `Cloneable`

public class Sequence extends Object implements Cloneable
Objects of this class represent a single amino acid sequence

## Constructor Summary

Constructors
Constructor
Description
`Sequence()`
Constructs a new Sequence object
`Sequence(String name)`
Constructs a new Sequence object of given name

## Method Summary

Modifier and Type
Method
Description
`void`
`addGap()`
Adds a new gap to the sequence
`void`
`addPosition(int index, ResidueType type)`
Adds a new position of given index and residue type to the sequence
`void`
`addPosition(int index, ResidueType type, String annotation)`
Adds a new position of given index, residue type and annotation to the sequence
`void`
`addPosition(SequencePosition pos)`
Adds a new position to the sequence
`void`
`addPosition(ResidueType type, String annotation)`
Adds a new position of given residue type and annotation to the sequence
`void`
`addPositionsFromString(String str)`
Adds a series of new positions to the sequence taken from a String object
`Object`
`clone()`
Returns an identical Sequence object
`Sequence`
`concat(Sequence other)`
Returns the given sequence concatenated to this sequence
`boolean`
`containsSubSequence(Sequence subsequence)`
Returns true if the given subsequence is contained in this sequence
`boolean`
`equals(Object other)`
Returns true if the two sequences are identical
`String`
`getAnnotationOfPosition(int i)`
Returns the annotation of sequence position #i
`String`
`getAnnotationOfPositionOfIndex(int index)`
Returns the annotation of sequence position of given index
`ArrayList<SequencePosition>`
`getAsArrayList()`
Returns sequence as an ArrayList object
`int`
`getIndexOfPosition(int i)`
Returns the index of sequence position #i
`String`
`getName()`
Returns the name of sequence
`SequencePosition`
`getPosition(int i)`
Returns sequence position #i
`SequencePosition`
`getPositionByIndex(int index)`
Returns sequence position of given index
`ResidueType`
`getResidueTypeOfPosition(int i)`
Returns the residue type of sequence position #i
`ResidueType`
`getResidueTypeOfPositionOfIndex(int index)`
Returns the residue type of sequence position of given index
`Sequence`
`getReverse()`
Returns the reverse sequence
`int`
`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 #end
`Sequence`
`getSubSequenceFrom(int begin)`
Returns subsequence beginning at sequence position #begin
`Sequence`
`getSubSequenceTo(int end)`
Returns subsequence ending at sequence position #end
`int`
`hashCode()`
Returns hash code
`void`
`insertGap(int i)`
Inserts a new gap to position #i
`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
`void`
`insertPosition(int i, int index, ResidueType type, 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
`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
`void`
`insertPosition(int i, ResidueType type, 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
`boolean`
`isPositionAGap(int i)`
Returns true if sequence position #i is a gap
`void`
`reIndexPositions()`
Reindexes all positions in the sequence starting from 1
`void`
`reIndexPositions(int startindex)`
Reindexes all positions in the sequence starting from a given index
`void`
`removeGaps()`
Removes all gaps from the sequence
`void`
`removePosition(int i)`
Removes sequence position #i
`void`
`removePosition(SequencePosition pos)`
Removes the given sequence position
`void`
`removePositionByIndex(int index)`
Removes the sequence position of given index
`void`
`setName(String name)`
Sets the name of sequence
`void`
`setPosition(int i, int index, ResidueType type)`
Replaces position #i with the a sequence position of given index and residue type
`void`
`setPosition(int i, int index, ResidueType type, String annotation)`
Replaces position #i with the a sequence position of given index, residue type and annotation
`void`
`setPosition(int i, SequencePosition pos)`
Replaces position #i with the given sequence position
`void`
`setPosition(int i, ResidueType type, String annotation)`
Replaces position #i with the a sequence position of given residue type and annotation
`void`
`setPositionByIndex(int index, ResidueType type)`
Replaces the position of given index with the a sequence position of given residue type
`void`
`setPositionByIndex(int index, ResidueType type, String annotation)`
Replaces the position of given index with the a sequence position of given residue type and annotation
`String`
`toString()`
Returns the String representation of sequence
`String`
`toString1Letter()`
Returns a String representation in which each residue is represented by its 1 letter code
`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
`String`
`toString3Letter()`
Returns a String representation in which each residue is represented by its 3 letter code
`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
`String`
`toStringInfo()`
Returns summary information about the sequence

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Sequence

public Sequence()
Constructs a new Sequence object

### Sequence

public Sequence(String name)
Constructs a new Sequence object of given name

## Method Details

### getName

public String getName()
Returns the name of sequence

Returns:
  name of sequence

### setName

public void setName(String name)
Sets the name of sequence

Parameters:
  `name` - name of sequence

### getAsArrayList

public 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 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 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, String annotation)
Adds a new position of given residue type and annotation to the sequence

Parameters:
  `type` - residue type of new position
  `annotation` - 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 position
  `type` - residue type of new position

### addPosition

public void addPosition(int index, ResidueType type, String annotation)
Adds a new position of given index, residue type and annotation to the sequence

Parameters:
  `index` - index of new position
  `type` - residue type of new position
  `annotation` - annotation of new position

### addPositionsFromString

public void addPositionsFromString(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, String annotation)
Replaces position #i with the a sequence position of given residue type and annotation

Parameters:
  `type` - residue type of new sequence position
  `annotation` - 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 position
  `type` - residue type of new sequence position

### setPosition

public void setPosition(int i, int index, ResidueType type, String annotation)
Replaces position #i with the a sequence position of given index, residue type and annotation

Parameters:
  `index` - index of new sequence position
  `type` - residue type of new sequence position
  `annotation` - annotation of new sequence position

### setPositionByIndex

public void setPositionByIndex(int index, ResidueType type, String annotation)
Replaces the position of given index with the a sequence position of given residue type and annotation

Parameters:
  `index` - index of sequence position
  `type` - residue type of new sequence position
  `annotation` - 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 position
  `type` - 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, 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 position
  `annotation` - 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 position
  `type` - residue type of new sequence position

### insertPosition

public void insertPosition(int i, int index, ResidueType type, 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 position
  `type` - residue type of new sequence position
  `annotation` - 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 subsequence
  `end` - 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 String toString()
Returns the String representation of sequence

Overrides:
  `toString` in class `Object`
Returns:
  String representation

### toString1Letter

public String toString1Letter()
Returns a String representation in which each residue is represented by its 1 letter code

Returns:
  String representation

### toString3Letter

public String toString3Letter()
Returns a String representation in which each residue is represented by its 3 letter code

Returns:
  String representation

### toString1Letter

public 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 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 String toStringInfo()
Returns summary information about the sequence

Returns:
  summary information

### clone

public Object clone()
Returns an identical Sequence object

Overrides:
  `clone` in class `Object`
Returns:
  clone of the sequence

### equals

public boolean equals(Object other)
Returns true if the two sequences are identical

Overrides:
  `equals` in class `Object`
Parameters:
  `other` - the other sequence

### hashCode

public int hashCode()
Returns hash code

Overrides:
  `hashCode` in class `Object`