org.biojava.bio.symbol
Class SymbolListViews

java.lang.Object
  extended by org.biojava.bio.symbol.SymbolListViews

public final class SymbolListViews
extends java.lang.Object

Tools class for constructing views of SymbolList objects.

Since:
1.2

Method Summary
static Alignment alignment(java.util.List labels, SymbolList symList)
          View a SymbolList over a cross-product Alphabet as an Alignment.
static Alignment alignment(java.util.Map labelToSymList)
          Construct an alignment of the SymbolLists contained in the values collection of labelToSymList.
static SymbolList emptyList(Alphabet alpha)
          Get a new immutable, empty symbol list with the given alphabet.
static SymbolList orderNSymbolList(SymbolList source, int order)
          An n-th order view of another SymbolList.
static SymbolList reverse(SymbolList symbols)
          A reversed view onto a SymbolList.
static SymbolList subList(SymbolList parent, int start, int end)
          View a portion of a SymbolList.
static SymbolList translate(SymbolList symbols, TranslationTable table)
          Provides a 'translated' view of an underlying SymbolList.
static SymbolList windowedSymbolList(SymbolList source, int wsize)
          A view of windows onto another SymbolList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

orderNSymbolList

public static SymbolList orderNSymbolList(SymbolList source,
                                          int order)
                                   throws IllegalAlphabetException
An n-th order view of another SymbolList.

In practice, what this means is that you can view a DNA sequence into an overlapping dinucleotide sequence without having to do any work yourself.

Parameters:
source - The underlying SymbolList to view
order - The window size
Throws:
IllegalAlphabetException

windowedSymbolList

public static SymbolList windowedSymbolList(SymbolList source,
                                            int wsize)
                                     throws java.lang.IllegalArgumentException
A view of windows onto another SymbolList.

In practice, what this means is that you can view a DNA sequence as codons which do not overlap.

Parameters:
source - The underlying SymbolList to view
wsize - The window size.
Throws:
java.lang.IllegalArgumentException - if the symbollist length isn't an integer multiple of wsize.

reverse

public static SymbolList reverse(SymbolList symbols)
A reversed view onto a SymbolList.

Parameters:
symbols - the SymbolList to reverse.

translate

public static SymbolList translate(SymbolList symbols,
                                   TranslationTable table)
                            throws IllegalAlphabetException
Provides a 'translated' view of an underlying SymbolList.

This method allows you to translate from one alphabet into another, so for example, you could translate from DNA-triplets into amino-acids. You could also translate from DNA-dinucleotide into the 'twist' structural metric, or any other translation that takes your fancy.

The actual mapping from source to view Symbol is encapsulated in a TranslationTable object.

The translated SymbolList will be the same length as the source, and each Symbol in the view will correspond to a single Symbol in the source.

Parameters:
symbols - a SymbolList to translate.
table - a translation table for mapping symbols.
Throws:
IllegalAlphabetException

alignment

public static Alignment alignment(java.util.Map labelToSymList)
                           throws java.lang.IllegalArgumentException
Construct an alignment of the SymbolLists contained in the values collection of labelToSymList.

Parameters:
labelToSymList - A Map containing label -> SymbolList mappings
Throws:
java.lang.IllegalArgumentException

alignment

public static Alignment alignment(java.util.List labels,
                                  SymbolList symList)
                           throws java.lang.IllegalArgumentException
View a SymbolList over a cross-product Alphabet as an Alignment.

Parameters:
labels - a List of labels, which should be the same length as the order symList's Alphabet.
symList - a SymbolList over a cross-product alphabet.
Throws:
java.lang.IllegalArgumentException

subList

public static SymbolList subList(SymbolList parent,
                                 int start,
                                 int end)
                          throws java.lang.IllegalArgumentException
View a portion of a SymbolList. Unlike SymbolList.subList, this method is guarenteed to return a view, which will change when the underlying SymbolList is modified.

Parameters:
parent - the SymbolList to view
start - the first index to include in the view
end - the last index to include in the view
Throws:
java.lang.IllegalArgumentException - if the start or end points fall outside the parent SymbolList.
Since:
1.4

emptyList

public static SymbolList emptyList(Alphabet alpha)
Get a new immutable, empty symbol list with the given alphabet.

Parameters:
alpha - the Alphabet this symbol list is over
Returns:
a new empty SymbolList
Since:
1.4