javagene.seq
Class SeqFast

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

public class SeqFast
extends java.lang.Object
implements SeqI

A SeqI implementation that keeps the entire sequence in memory. The sequence must be ungapped (ie contiguous) and is untyped (ie might be dna, rna, codons, ambiguous, etc.).


Constructor Summary
SeqFast(SeqI sequence)
          Construct SeqFast object from an arbitrary SeqI object.
SeqFast(java.lang.String seqData, java.lang.String id, java.lang.String description)
          Construct SeqFast object from string data.
 
Method Summary
 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 locationOf(java.lang.String searchText)
          Return the location of the parameter string in this sequence.
 SeqFast subseq(Location location)
          Create a new sequence containing only the portion specified by the location parameter.
 SeqFast 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 toReverseString(Location location)
          Get the IUPAC character string representation of the subsequence specified by the location parameter, in reverse order.
 java.lang.String toString()
          Get the IUPAC character string representation of this entire sequence.
 java.lang.String toString(Location location)
          Get the IUPAC character string representation of the subsequence specified by the location parameter.
 java.lang.String toTaggedString(Location location, java.lang.String beginTag, java.lang.String endTag)
          Get the IUPAC representation of the entire sequence, bracketing the portion specified by the location parameter with the specified begin and end tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SeqFast

public SeqFast(SeqI sequence)
Construct SeqFast object from an arbitrary SeqI object. This can be useful when working with subsequences of SeqBig objects, as SeqFast supports additional methods that SeqBig does not.

Parameters:
sequence - A SeqI object.

SeqFast

public SeqFast(java.lang.String seqData,
               java.lang.String id,
               java.lang.String description)
Construct SeqFast object from string data.

Parameters:
seqData -
id -
description -
Method Detail

bounds

public Location bounds()
Get the bounding location of this sequence. SeqFast objects always start at index 0. To use a coordinate system that starts at a non-zero genomic location, wrap the SeqFast object in a SeqStranded object.

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.

locationOf

public Location locationOf(java.lang.String searchText)
Return the location of the parameter string in this sequence. Returns null if the searchText is not found.

Parameters:
searchText - The string to search for.
Returns:
The first location of the searchText in the string, or null if the text is not found.

subseq

public SeqFast subseq(Location location)
Create a new sequence containing only the portion specified by the location parameter. May make a copy of the underlying data.

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

subseq

public SeqFast 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.

Specified by:
subseq in interface SeqI
Parameters:
location - The portion of the sequence to get.
id - The new single-word id.
description - The new description line.
Returns:
The subsequence.
Throws:
java.lang.IndexOutOfBoundsException - The location parameter was not within the bounding location of the sequence.

toReverseString

public java.lang.String toReverseString(Location location)
Get the IUPAC character string representation of the subsequence specified by the location parameter, in reverse order. Note: just reversed, not complemented. See the Nucleotide class for complementation methods.

Parameters:
location - The portion of the sequence to get.
Returns:
The reversed string.
Throws:
java.lang.IndexOutOfBoundsException - The location parameter was not within the bounding location of the sequence.

toString

public java.lang.String toString()
Description copied from interface: SeqI
Get the IUPAC character string representation of this entire sequence.

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)
Description copied from interface: SeqI
Get the IUPAC character string representation of the subsequence specified by the location parameter.

Specified by:
toString in interface SeqI
Parameters:
location - The portion of the sequence to get.
Returns:
The string.

toTaggedString

public java.lang.String toTaggedString(Location location,
                                       java.lang.String beginTag,
                                       java.lang.String endTag)
Get the IUPAC representation of the entire sequence, bracketing the portion specified by the location parameter with the specified begin and end tags. Use this to create HTML-ready output of sequences with a specific location identified. For example, try using "<span style='color:red'>" and "</span>" as tags.

Parameters:
location - Location of the interesting portion of the sequence.
beginTag - The string to put before the portion of interest.
endTag - The string to put after the portion of interest.
Returns:
The formatted string.
Throws:
java.lang.IndexOutOfBoundsException - The location parameter was not within the bounding location of the sequence.