Class WindowedSequence<C extends Compound>

java.lang.Object
org.biojava.nbio.core.sequence.views.WindowedSequence<C>
Type Parameters:
C - The type of compound we return from a window
All Implemented Interfaces:
Iterable<SequenceView<C>>

public class WindowedSequence<C extends Compound> extends Object implements Iterable<SequenceView<C>>
A sliding window view of a sequence which does not implement any interfaces like Sequence because they do not fit how this works. For each index requested we return a SequenceView or List of compounds back. If you perform a view on a Sequence whose length is not a multiple of the window the final window will be omitted i.e. if we have the sequence AGCGG and a window of 3 then you will only see AGC since GG exceeds the calculated length of this sequence. Because this does not implement a Sequence interface we do not recommend passing this class around. If you need to represent a windowed sequence as a real Sequence then translate it into a new Compound
Author:
ayates
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    WindowedSequence(Sequence<C> sequence, int windowSize)
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    get(int index)
    Returns the window specified at the given index in offsets i.e. asking for position 2 in a moving window sequence of size 3 will get you the window starting at position 4.
    Access the sequence which backs this window
    getCompounds(int index)
    For a given position into the windowed view this will return those compounds we can see in the window. i.e. in the sequence AGGCCT requesting index 1 returns AGG and requesting index 2 return CCT.
    int
    Returns the size of the windowed sequence which is the length by the window size.
    int
    Access the current window size
    Returns an iterator which will return the windows in a sequence in sequential order.
    protected int
    toStartIndex(int index)
    Calculates start index according to the equation start = ( (index-1) - windowSize) +1

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable Link icon

    forEach, spliterator
  • Constructor Details Link icon

  • Method Details Link icon

    • getWindowSize Link icon

      public int getWindowSize()
      Access the current window size
    • getBackingSequence Link icon

      Access the sequence which backs this window
    • toStartIndex Link icon

      protected int toStartIndex(int index)
      Calculates start index according to the equation start = ( (index-1) - windowSize) +1
    • getLength Link icon

      public int getLength()
      Returns the size of the windowed sequence which is the length by the window size. Trailing Compounds are omitted.
    • getCompounds Link icon

      public List<C> getCompounds(int index)
      For a given position into the windowed view this will return those compounds we can see in the window. i.e. in the sequence AGGCCT requesting index 1 returns AGG and requesting index 2 return CCT.
      Parameters:
      index - Windowed index position
      Returns:
      The List of compounds
    • get Link icon

      public SequenceView<C> get(int index)
      Returns the window specified at the given index in offsets i.e. asking for position 2 in a moving window sequence of size 3 will get you the window starting at position 4.
    • iterator Link icon

      Returns an iterator which will return the windows in a sequence in sequential order.
      Specified by:
      iterator in interface Iterable<C extends Compound>