## org.biojava.bio.symbol
Class SimpleAlignment

    java.lang.Object
      |
      +--org.biojava.bio.symbol.AbstractSymbolList
            |
            +--org.biojava.bio.symbol.SimpleAlignment

public class SimpleAlignment
extends AbstractSymbolList
implements Alignment, java.io.Serializable

A simple implementation of an Alignment.

This is a simple-stupid implementation that is made from a set of same-lengthed SymbolList objects each with an associated label. It does not handle differently lengthed sequences and doesn't contain any gap-editing concepts.

Author:
  Matthew Pocock
See Also:
  Serialized Form

Inner classes inherited from class org.biojava.bio.symbol.SymbolList
`SymbolList.EmptySymbolList`

Fields inherited from interface org.biojava.bio.symbol.SymbolList
`EMPTY_LIST`

Constructor Summary
`SimpleAlignment(java.util.Map labelToResList)` Generate an alignment from a list of SymbolLists.

Method Summary
`Alphabet` `getAlphabet()` The alphabet that this SymbolList is over.
`java.util.List` `getLabels()` The list of SymbolLists in the alignment.
`int` `length()` The number of symbols in this SymbolList.
`Alignment` `subAlignment(java.util.Set labels, Location loc)` Make a view onto this alignment.
`Symbol` `symbolAt(int index)` Return the symbol at index, counting from 1.
`Symbol` `symbolAt(java.lang.Object label, int column)` Retrieve a symbol by label and column.
`SymbolList` `symbolListForLabel(java.lang.Object label)` Retrieve a single row of the alignment by label.

Methods inherited from class org.biojava.bio.symbol.AbstractSymbolList
`iterator, seqString, subList, subStr, toList`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleAlignment

    public SimpleAlignment(java.util.Map labelToResList)
                    throws java.lang.IllegalArgumentException

  Generate an alignment from a list of SymbolLists.

  The SymbolLists must all be of the same length.

  Parameters:
    `labelToResList` - the label-to-symbol list mapping
  Throws:
    java.lang.IllegalArgumentException - if the SymbolLists are not the same length

Method Detail

### length

    public int length()

  Description copied from interface: SymbolList
  The number of symbols in this SymbolList.
  Overrides:
    length in class AbstractSymbolList
  Tags copied from interface: SymbolList
  Returns:
    the length

### getAlphabet

    public Alphabet getAlphabet()

  Description copied from interface: SymbolList
  The alphabet that this SymbolList is over.

  Every symbol within this SymbolList is a member of this alphabet. `alphabet.contains(symbol) == true` for each symbol that is within this sequence.

  Overrides:
    getAlphabet in class AbstractSymbolList
  Tags copied from interface: SymbolList
  Returns:
    the alphabet

### symbolAt

    public Symbol symbolAt(int index)

  Description copied from interface: SymbolList
  Return the symbol at index, counting from 1.
  Overrides:
    symbolAt in class AbstractSymbolList
  Tags copied from interface: SymbolList
  Parameters:
    `index` - the ofset into this SymbolList
  Returns:
    the Symbol at that index
  Throws:
    java.lang.IndexOutOfBoundsException - if index is less than 1, or greater than the length of the symbol list

### getLabels

    public java.util.List getLabels()

  Description copied from interface: Alignment
  The list of SymbolLists in the alignment.

  The index in the list is the same as the index in the alignment. Each SymbolList object will only be in the alignment once. However, a single underlying SymbolList may have more than one view within an alignment, each represented by a different GappedSymbolList.

  Specified by:
    getLabels in interface Alignment
  Tags copied from interface: Alignment
  Returns:
    the List of all SymbolLists in the alignment

### symbolAt

    public Symbol symbolAt(java.lang.Object label,
                           int column)

  Description copied from interface: Alignment
  Retrieve a symbol by label and column.
  Specified by:
    symbolAt in interface Alignment
  Tags copied from interface: Alignment
  Parameters:
    `label` - the SymbolList to retrieve from
    `column` - the index of the column to retrieve
  Returns:
    the symbol in the symbol list associated with the label at the given column
  Throws:
    java.util.NoSuchElementException - if there is no row for 'label'

### subAlignment

    public Alignment subAlignment(java.util.Set labels,
                                  Location loc)
                           throws java.util.NoSuchElementException

  Description copied from interface: Alignment
  Make a view onto this alignment.

  If labels is null, then each label will be kept. Otherwise, only those in labels will be kept. If loc is null, then the entire length of the alignment will be kept. If loc is not null, then only the columns within the location will be kept.

  Specified by:
    subAlignment in interface Alignment
  Tags copied from interface: Alignment
  Parameters:
    `labels` - the Set of sequences to include by label
    `loc` - the Location to include
  Returns:
    a sub Alignment
  Throws:
    java.util.NoSuchElementException - if labels contains any item that is not a label

### symbolListForLabel

    public SymbolList symbolListForLabel(java.lang.Object label)
                                  throws java.util.NoSuchElementException

  Description copied from interface: Alignment
  Retrieve a single row of the alignment by label.
  Specified by:
    symbolListForLabel in interface Alignment
  Tags copied from interface: Alignment
  Parameters:
    `label` - the object from which to retrieve the symbol list
  Returns:
    a SymbolList that contains each token in a row of the alignment
  Throws:
    java.util.NoSuchElementException - if there is no row for 'label'