Class 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
    • Field Detail

      • data

        protected java.util.Map data
      • labelOrder

        protected java.util.List labelOrder
      • alignmentRange

        protected Location alignmentRange
    • Constructor Detail

      • FlexibleAlignment

        public FlexibleAlignment​(java.util.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

      • locInAlignment

        public Location locInAlignment​(java.lang.Object label)
                                throws java.util.NoSuchElementException
        The location of an individual SymbolList relative to overall Alignment
        Specified by:
        locInAlignment in interface UnequalLengthAlignment
        Throws:
        java.util.NoSuchElementException
      • getLabelsAt

        public java.util.List getLabelsAt​(int column)
                                   throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.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 java.util.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​(java.lang.Object label,
                               int column)
                        throws java.util.NoSuchElementException,
                               java.lang.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:
        java.util.NoSuchElementException - if there is no row for 'label'
        java.lang.IndexOutOfBoundsException
      • 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
        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'
      • 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
      • greater

        protected int greater​(int x,
                              int y)
      • lesser

        protected int lesser​(int x,
                             int y)
      • getAE

        protected AlignmentElement getAE​(java.lang.Object label)
                                  throws java.util.NoSuchElementException
        Throws:
        java.util.NoSuchElementException
      • posInSeq

        protected int posInSeq​(java.lang.Object label,
                               int column)
                        throws java.util.NoSuchElementException,
                               java.lang.IndexOutOfBoundsException
        get the position in the sequence corresponding to the postion within the alignment
        Throws:
        java.util.NoSuchElementException
        java.lang.IndexOutOfBoundsException
      • locInSeq

        protected Location locInSeq​(java.lang.Object label,
                                    Location viewLoc)
                             throws java.util.NoSuchElementException,
                                    java.lang.IndexOutOfBoundsException
        Throws:
        java.util.NoSuchElementException
        java.lang.IndexOutOfBoundsException