Package sequence

Class MemorySequence

  • All Implemented Interfaces:
    Sequence

    public class MemorySequence
    extends Object
    implements Sequence
    An immutable sequence that is stored completely in memory.
    Author:
    gerardlee
    • Method Detail

      • fromString

        public static MemorySequence fromString​(String sequence)
        Constructs a new MemorySequence from the input sequence string that contains A, G, T, and C. Note that there should be no white space between any of the bases.
        Parameters:
        sequence - input sequence
        Returns:
        new MemorySequence
      • random

        public static MemorySequence random​(int k)
        Generates a random MemorySequence of length k.
        Parameters:
        k - length of the MemorySequence
        Returns:
        new MemorySequence
      • buildIndex

        public void buildIndex​(long k)
        Description copied from interface: Sequence
        Builds the index based on the length of the k-mer.
        Specified by:
        buildIndex in interface Sequence
        Parameters:
        k - length of the k-mer
      • getMatchingPositions

        public List<Long> getMatchingPositions​(Sequence kmer)
                                        throws Exception
        Description copied from interface: Sequence
        Gets positions of the sequence that matches with k-mer. If an index has been built, then this method tries to use that index to perform faster look-up.
        Specified by:
        getMatchingPositions in interface Sequence
        Parameters:
        kmer - sub-sequence to search for
        Returns:
        list of matching starting positions in this sequence
        Throws:
        Exception - throws exception
      • getSize

        public long getSize()
        Specified by:
        getSize in interface Sequence
        Returns:
        size of the sequence
      • getBase

        public Base getBase​(long position)
        Specified by:
        getBase in interface Sequence
        Parameters:
        position - the position of the sequence
        Returns:
        the base at the position provided