Class SimpleGappedSymbolList

    • Method Detail

      • addGapsInSource

        public void addGapsInSource​(int pos,
                                    int length)
        Description copied from interface: GappedSymbolList
        Add length gaps at pos within the source coordinates.
        Specified by:
        addGapsInSource in interface GappedSymbolList
        Parameters:
        pos - where to add the gap
        length - how many gaps to add
      • addGapsInView

        public void addGapsInView​(int pos,
                                  int length)
                           throws IndexOutOfBoundsException
        Description copied from interface: GappedSymbolList
        Add length gaps at pos within the view coordinates.

        this.symbolAt(i) will then return gap for i = (pos .. pos+count-1). Adding gaps at 1 will prepend gaps. Adding gaps at (length+1) will append gaps.

        Specified by:
        addGapsInView in interface GappedSymbolList
        Parameters:
        pos - the position to add a gap before
        length - the number of gaps to insert
        Throws:
        IndexOutOfBoundsException - if pos is not within 1->length+1
      • BlockIterator

        public List<SimpleGappedSymbolList.BlockBlockIterator()
        Get list of the un-gapped region of the SymbolList.

        The gapped symbol list can be represented as a list of ungapped regions. Given a list of start-stop pairs in the ungapped coordinate system each with a corresponding pair of start-stop pairs in the gapped view, the entire gapped list can be reconstructed.

        Returns:
        a List of Block instances
      • dumpBlocks

        public void dumpBlocks()
        Debugging method
      • firstNonGap

        public int firstNonGap()
        Description copied from interface: GappedSymbolList
        Return the index of the first Symbol that is not a Gap character.

        All symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.

        Specified by:
        firstNonGap in interface GappedSymbolList
        Returns:
        the index of the first character not to be a gap
      • gappedToLocation

        public Location gappedToLocation​(Location l)
        Translates a Location from the gapped view into the underlying sequence. End points that are in gaps are moved 'inwards' to shorten the location.
        Since:
        1.3
      • 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
      • getUngappedLocation

        public Location getUngappedLocation()
        Description copied from interface: GappedSymbolList
        Get a Location that contains exactly those positions that are not gaps.

        This will be a Location that contains every symbol in the underlying ungapped sequence. Every symbol not in the Location is not from the underlying sequence and is a gap.

        Specified by:
        getUngappedLocation in interface GappedSymbolList
        Returns:
        a new Location that contains all non-gap symbols
      • lastNonGap

        public int lastNonGap()
        Description copied from interface: GappedSymbolList
        Return the index of the last Symbol that is not a Gap character.

        All symbols after lastNonGap untill length are trailing gaps. lastNonGap is effectively the index in the view of symbol length in the original sequence.

        Specified by:
        lastNonGap in interface GappedSymbolList
        Returns:
        the index of the last character not to be a gap
      • 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
      • viewToSource

        public final int viewToSource​(int indx)
                               throws IndexOutOfBoundsException
        Description copied from interface: GappedSymbolList
        Coordinate conversion from view to source.

        If the index can be projected onto the source, the index it projects onto is returned. If it falls within a gap, then the index of the first symbol after the run of gaps is negated and returned. If the index is after the last block of symbols (and therefore in the trailing list of gaps), then it returns -(length + 1).

        Specified by:
        viewToSource in interface GappedSymbolList
        Parameters:
        indx - the index to project
        Returns:
        the position of indx projected from view to source
        Throws:
        IndexOutOfBoundsException - if indx is not a valid view index
      • findSourceBlock

        protected final int findSourceBlock​(int indx)
        Finds the index of the block containing the source coordinate indx.
        Parameters:
        indx - the index to find
        Returns:
        the index of the Block containing indx
      • findSourceGap

        protected final int findSourceGap​(int indx)
        Finds the index of the Block before the gap at indx within the following gap.
        Parameters:
        indx - the index to find within a gap
        Returns:
        the index of the block with indx in the gap
      • findViewBlock

        protected final int findViewBlock​(int indx)
        Finds the index of the Block containing indx within the view ranges.

        If indx is not within a view block, then it is the index of a gap. The method will return -(indx+1) where indx is the block emediately following the gap.

        Parameters:
        indx - the index to find within a view range.
        Returns:
        the index of the block containing index or one less than the negative of the index of the block following the gap
      • findViewGap

        protected final int findViewGap​(int indx)
        Finds the index of the Block before the gap at indx within the view range.

        If indx is in-fact a real symbol, then there will be no Block before it. In this case, the method returns -2. It returns -1 if indx is within the leading gaps and blocks.size()-1 if it is within the trailing gaps.

        Parameters:
        indx - the index to find within a view range
        Returns:
        the index of the block with indx in the following gap
      • isSane

        protected boolean isSane()
      • renumber

        protected final void renumber​(int i,
                                      int delta)
        Renumber the view indexes from block, adding delta to each offset.

        This adjusts viewStart and viewEnd to be += delta for each block i->blocks.size(), and sets the total length to += delta.

        Parameters:
        i - the first
      • sourceToView

        protected final int sourceToView​(SimpleGappedSymbolList.Block b,
                                         int indx)
        Coordinate conversion from source to view.
        Parameters:
        b - the block containing indx
        indx - the index to project
        Returns:
        the position of indx projected from source to view
      • viewToSource

        protected final int viewToSource​(SimpleGappedSymbolList.Block b,
                                         int indx)
        Coordinate conversion from view to source.
        Parameters:
        b - the block containing indx
        indx - the index to project
        Returns:
        the position of indx projected from view to source