javagene.seq
Class SeqStranded

java.lang.Object
  extended by javagene.seq.SeqStranded
All Implemented Interfaces:
SeqI

public class SeqStranded
extends java.lang.Object
implements SeqI

A SeqI wrapper that presents a stranded coordinate system mapped to an underlying SeqI object.

The bounds of a SeqStranded object can be set to an arbitrary location; they do not necessarily start at 0, and they may be on the reverse strand.

In JavaGene's coordinate system a numerical increase is always upstream. The direction (strand) of the underlying sequence is indicated by the strand of the bounding location.

The sequence type (RNA or DNA) is always set in constructor.


Constructor Summary
SeqStranded(SeqI baseSequence, Location location, Nucleotide.Type type)
          Construct from SeqI using specified location as the bounding location.
SeqStranded(SeqI baseSequence, Nucleotide.Type type)
          Construct from an arbitrary SeqI object.
SeqStranded(SeqStranded baseSequence)
          Construct a clone.
 
Method Summary
 SeqI baseSeq()
          Get the base sequence that was specified in the constructor.
 Location bounds()
          Get the bounding location of this sequence.
 java.lang.String description()
          Get the text description of the sequence.
 java.lang.String id()
          Get the (single-word) identifier of the sequence.
 Location mapFromBase(Location baseLocation)
          Map a location on the base sequence to the equivalent genomic location.
 Location mapToBase(Location genomicLocation)
          Map a genomic location to the equivalent location on the base sequence.
 SeqStranded subseq(Location location)
          Create a new sequence containing only the portion specified by the location parameter.
 SeqStranded subseq(Location location, java.lang.String id, java.lang.String description)
          Create a new sequence containing only the portion specified by the location parameter, with the specified id and description.
 java.lang.String toString()
          Get the IUPAC character string representation of this entire sequence, as defined by the bounding location.
 java.lang.String toString(Location location)
          Get the IUPAC character string representation of the subsequence specified by the location parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SeqStranded

public SeqStranded(SeqI baseSequence,
                   Location location,
                   Nucleotide.Type type)
Construct from SeqI using specified location as the bounding location. Shares the underlying data. The start index of the bounding location may be non-zero. The bounding location may be on either strand. Note: the length of the sequence must equal the length of the location.

Parameters:
baseSequence - A SeqI object.
location - The bounding location.
type - Nucleotide.Type.DNA or Nucleotide.Type.RNA
Throws:
java.lang.IllegalArgumentException - The sequence length and location length were not equal.

SeqStranded

public SeqStranded(SeqI baseSequence,
                   Nucleotide.Type type)
Construct from an arbitrary SeqI object. Shares the underlying data. The bounding location starts at 0.

Parameters:
baseSequence - A SeqI object.
type - Nucleotide.Type.DNA or Nucleotide.Type.RNA.

SeqStranded

public SeqStranded(SeqStranded baseSequence)
Construct a clone. Shares the underlying data.

Parameters:
baseSequence - A SeqI object.
Method Detail

baseSeq

public SeqI baseSeq()
Get the base sequence that was specified in the constructor.

Returns:
The base sequence.

bounds

public Location bounds()
Get the bounding location of this sequence. The location can start at any index, on either strand.

Specified by:
bounds in interface SeqI
Returns:
The bounding location.

description

public java.lang.String description()
Description copied from interface: SeqI
Get the text description of the sequence. This is all the text on the description line of a Fasta file after the id.

Specified by:
description in interface SeqI
Returns:
The text description.

id

public java.lang.String id()
Description copied from interface: SeqI
Get the (single-word) identifier of the sequence. This is the first identifier in a Fasta file.

Specified by:
id in interface SeqI
Returns:
The single-word identifier.

mapFromBase

public Location mapFromBase(Location baseLocation)
Map a location on the base sequence to the equivalent genomic location. The returned genomic location is always on the same strand as the location bounds.

Parameters:
baseLocation - The location on the base string.
Returns:
A location within the location bounds.
Throws:
java.lang.IndexOutOfBoundsException - The specified baseLocation could not be mapped within the SeqStranded object's location bounds.

mapToBase

public Location mapToBase(Location genomicLocation)
Map a genomic location to the equivalent location on the base sequence. If the specified location is on the opposite strand, this method first converts the specified location to the other strand, and then maps the result to the base sequence.

Parameters:
genomicLocation - The location to map. Must be within the location bounds, though both strands are allowed.
Returns:
The equivalent location on the base sequence.
Throws:
java.lang.IndexOutOfBoundsException - The genomicLocation did not map within the base sequence bounds.

subseq

public SeqStranded subseq(Location location)
Create a new sequence containing only the portion specified by the location parameter. Shares the underlying data (does not make a copy). The specified location must be contained by the bounding location, and on the same strand. Consider using the toString( Location ) method if the location might be on either strand.

Specified by:
subseq in interface SeqI
Parameters:
location - The location of the subsequence.
Returns:
The subsequence.
Throws:
java.lang.IndexOutOfBoundsException - The bounding location did not contain the specified location.

subseq

public SeqStranded subseq(Location location,
                          java.lang.String id,
                          java.lang.String description)
Create a new sequence containing only the portion specified by the location parameter, with the specified id and description. Shares the underlying data (does not make a copy). The specified location must be contained by the bounding location, and on the same strand. Consider using the toString( Location ) method if the location might be on either strand.

Specified by:
subseq in interface SeqI
Parameters:
location - The location of the subsequence.
id - The new single-word id.
description - The new description line.
Returns:
The subsequence.
Throws:
java.lang.IndexOutOfBoundsException - The bounding location did not contain the specified location.

toString

public java.lang.String toString()
Get the IUPAC character string representation of this entire sequence, as defined by the bounding location.

Specified by:
toString in interface SeqI
Overrides:
toString in class java.lang.Object
Returns:
The text string.

toString

public java.lang.String toString(Location location)
Get the IUPAC character string representation of the subsequence specified by the location parameter. Returns the reverse complement if the specified location and bounding locations are on opposite strands. Uses the sequence type (Rna or Dna) to choose whether T or U should be used when complementing (if necessary). The specified location must be within the bounding location.

Specified by:
toString in interface SeqI
Parameters:
location - The portion of the sequence to get.
Returns:
The string.
Throws:
java.lang.IndexOutOfBoundsException - The location parameter was not within the bounding location of the sequence.