## org.biojava.bio.alignment
Class FlexibleAlignment

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojava.bio.symbol.AbstractSymbolList
              org.biojava.bio.alignment.AbstractULAlignment
                  org.biojava.bio.alignment.FlexibleAlignment

All Implemented Interfaces:
  ARAlignment, EditableAlignment, UnequalLengthAlignment, Alignment, SymbolList, Changeable

    public class FlexibleAlignment

extends AbstractULAlignment
implements ARAlignment, EditableAlignment

FlexibleAlignment is a class which implements UnequalLengthAlignment, ARAlignment and EditableAlignment It places no restriction on where any sequence can be in the alignment so there could be gaps in the alignment. You tell it where to put the sequence, it will do it. I think I will be adding an Exception NonContinuousAlignmentException. STILL UNDER CONSTRUCTION. seqString does not work because there it does not seem to support tokenization 'token' this is true for SimpleAlignment too.

Author:
  David Waring, Matthew Pocock

Nested Class Summary

Nested classes/interfaces inherited from class org.biojava.bio.alignment.AbstractULAlignment
`AbstractULAlignment.LeftRightLocationComparator, AbstractULAlignment.SubULAlignment`

Nested classes/interfaces inherited from class org.biojava.bio.symbol.AbstractSymbolList
`AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater`

Nested classes/interfaces inherited from interface org.biojava.bio.symbol.Alignment
`Alignment.SymbolListIterator`

Field Summary
`protected Location` `alignmentRange`
`protected Map` `data`
`protected List` `labelOrder`

Fields inherited from class org.biojava.bio.alignment.AbstractULAlignment
`alphabet`

Fields inherited from interface org.biojava.bio.alignment.ARAlignment
`ADD_LABEL, REMOVE_LABEL`

Fields inherited from interface org.biojava.bio.symbol.Alignment
`CONTENT`

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

Fields inherited from interface org.biojava.bio.alignment.EditableAlignment
`GAPS, LOCATION`

Constructor Summary
`FlexibleAlignment(List seqList)` construct this object with the reference sequence which can either be a gappedSymbolList or not label in all cases refers to an object that holds the display name (generally just a String).

Method Summary
`void` `addSequence(AlignmentElement ae)` add a new a alignment usings a location to the reference sequence.
`protected boolean` `allGaps(SymbolList seq, int start, int end)` make sure that all Symbols in this range are gaps
`void` `edit(Object label, Edit edit)` edit() allows edits on an individual sequence, they should be reflected back to the underlying SymbolList.
`protected AlignmentElement` `getAE(Object label)`
`Alphabet` `getAlphabet()` The alphabet that this SymbolList is over.
`List` `getLabels()` getLabels will return a list of labels in left to right order
`List` `getLabelsAt(int column)`
`protected int` `greater(int x, int y)`
`int` `length()` The number of symbols in this SymbolList.
`protected int` `lesser(int x, int y)`
`Location` `locInAlignment(Object label)` The location of an individual SymbolList relative to overall Alignment
`protected Location` `locInSeq(Object label, Location viewLoc)`
`protected int` `posInSeq(Object label, int column)` get the position in the sequence corresponding to the postion within the alignment
`void` `removeGaps(GappedSymbolList seq, int start, int length)` because there is a bug in GappedSymbolList
`void` `removeSequence(Object label)`
`protected void` `resetRange()` check that begining is at 1 otherwise shift everything over
`protected void` `shift(Object label, int offset)` moves the whole sequence
`protected void` `shiftAll(int offset)`
`void` `shiftAtAlignmentLoc(Object label, Location loc, int offset)` loc in this case is the Alignment Location
`void` `shiftAtSequenceLoc(Object label, Location loc, int offset)` loc in this case is the SymbolList Location
`Symbol` `symbolAt(Object label, int column)` This gets the symbol for an individual sequence at position in the overall alignment If the sequence is not aligned at that location it returns null
`SymbolList` `symbolListForLabel(Object label)` Retrieve a single row of the alignment by label.

Methods inherited from class org.biojava.bio.alignment.AbstractULAlignment
`debug, labelsAt, labelsInRange, leftMost, orderedLables, rightMost, subAlignment, subAlignment, symbolAt, symbolListIterator`

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

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

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

Methods inherited from interface org.biojava.bio.symbol.Alignment
`subAlignment, symbolListIterator`

Methods inherited from interface org.biojava.bio.symbol.SymbolList
`edit, iterator, seqString, subList, subStr, symbolAt, toList`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Field Detail

### data

    protected Map data

### labelOrder

    protected List labelOrder

### alignmentRange

    protected Location alignmentRange

Constructor Detail

### FlexibleAlignment

    public FlexibleAlignment(List seqList)
                      throws BioException

  construct this object with the reference sequence which can either be a gappedSymbolList or not label in all cases refers to an object that holds the display name (generally just a String). since more than one sequence in an alignment could have the same name this works as long as the labels are different objects even though they may hold the same name.

  Throws:
    `BioException`

Method Detail

### addSequence

    public void addSequence(AlignmentElement ae)
                     throws ChangeVetoException,
                            BioException

  add a new a alignment usings a location to the reference sequence. This should either contain no gaps or it should be relative to a reference sequence that already has the gaps added

  Specified by:
    `addSequence` in interface `ARAlignment`
  Throws:
    `ChangeVetoException`
    `BioException`

### removeSequence

    public void removeSequence(Object label)
                        throws ChangeVetoException

  Specified by:
    `removeSequence` in interface `ARAlignment`
  Throws:
    `ChangeVetoException`

### locInAlignment

    public Location locInAlignment(Object label)
                            throws NoSuchElementException

  The location of an individual SymbolList relative to overall Alignment

  Specified by:
    `locInAlignment` in interface `UnequalLengthAlignment`
  Throws:
    `NoSuchElementException`

### getLabelsAt

    public List getLabelsAt(int column)
                     throws IndexOutOfBoundsException

  Throws:
    `IndexOutOfBoundsException`

### length

    public int length()

  Description copied from interface: `SymbolList`
  The number of symbols in this SymbolList.

  Specified by:
    `length` in 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.

  Specified by:
    `getAlphabet` in interface `SymbolList`
  Returns:
    the alphabet

### getLabels

    public List getLabels()

  getLabels will return a list of labels in left to right order

  Specified by:
    `getLabels` in interface `Alignment`
  Returns:
    the List of all SymbolLists in the alignment

### symbolAt

    public Symbol symbolAt(Object label,
                           int column)
                    throws NoSuchElementException,
                           IndexOutOfBoundsException

  This gets the symbol for an individual sequence at position in the overall alignment If the sequence is not aligned at that location it returns null

  Specified by:
    `symbolAt` in 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:
    `NoSuchElementException` - if there is no row for 'label'
    `IndexOutOfBoundsException`

### symbolListForLabel

    public SymbolList symbolListForLabel(Object label)
                                  throws NoSuchElementException

  Description copied from interface: `Alignment`
  Retrieve a single row of the alignment by label.

  Specified by:
    `symbolListForLabel` in 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:
    `NoSuchElementException` - if there is no row for 'label'

### edit

    public void edit(Object label,
                     Edit edit)
              throws ChangeVetoException

  Description copied from interface: `EditableAlignment`

  edit() allows edits on an individual sequence, they should be reflected back to the underlying SymbolList.

  Specified by:
    `edit` in interface `EditableAlignment`
  Throws:
    `ChangeVetoException`

### shiftAtAlignmentLoc

    public void shiftAtAlignmentLoc(Object label,
                                    Location loc,
                                    int offset)
                             throws ChangeVetoException,
                                    IllegalAlignmentEditException,
                                    IndexOutOfBoundsException

  loc in this case is the Alignment Location

  Specified by:
    `shiftAtAlignmentLoc` in interface `EditableAlignment`
  Throws:
    `ChangeVetoException`
    `IllegalAlignmentEditException`
    `IndexOutOfBoundsException`

### shiftAtSequenceLoc

    public void shiftAtSequenceLoc(Object label,
                                   Location loc,
                                   int offset)
                            throws ChangeVetoException,
                                   IllegalAlignmentEditException,
                                   IndexOutOfBoundsException

  loc in this case is the SymbolList Location

  Specified by:
    `shiftAtSequenceLoc` in interface `EditableAlignment`
  Throws:
    `ChangeVetoException`
    `IllegalAlignmentEditException`
    `IndexOutOfBoundsException`

### removeGaps

    public void removeGaps(GappedSymbolList seq,
                           int start,
                           int length)

  because there is a bug in GappedSymbolList

### allGaps

    protected boolean allGaps(SymbolList seq,
                              int start,
                              int end)

  make sure that all Symbols in this range are gaps

### resetRange

    protected void resetRange()
                       throws ChangeVetoException

  check that begining is at 1 otherwise shift everything over

  Throws:
    `ChangeVetoException`

### shiftAll

    protected void shiftAll(int offset)
                     throws ChangeVetoException

  Throws:
    `ChangeVetoException`

### shift

    protected void shift(Object label,
                         int offset)
                  throws ChangeVetoException

  moves the whole sequence

  Throws:
    `ChangeVetoException`

### greater

    protected int greater(int x,
                          int y)

### lesser

    protected int lesser(int x,
                         int y)

### getAE

    protected AlignmentElement getAE(Object label)
                              throws NoSuchElementException

  Throws:
    `NoSuchElementException`

### posInSeq

    protected int posInSeq(Object label,
                           int column)
                    throws NoSuchElementException,
                           IndexOutOfBoundsException

  get the position in the sequence corresponding to the postion within the alignment

  Throws:
    `NoSuchElementException`
    `IndexOutOfBoundsException`

### locInSeq

    protected Location locInSeq(Object label,
                                Location viewLoc)
                         throws NoSuchElementException,
                                IndexOutOfBoundsException

  Throws:
    `NoSuchElementException`
    `IndexOutOfBoundsException`