jbil.sequence
Class FactorTrie

java.lang.Object
  extended by jbil.sequence.Trie
      extended by jbil.sequence.FactorTrie
All Implemented Interfaces:
KMerCounter

public class FactorTrie
extends Trie

A factor trie is a trie representing all factors of a given length of a set of sequences.

Author:
Paulo G. S. da Fonseca

Constructor Summary
FactorTrie(Alphabet alphabet, int factorLength)
          Creates an empty factor trie.
FactorTrie(Sequence baseSequence, int factorLength)
          Creates a factor trie representing the factors of a given sequence.
 
Method Summary
 void addBaseSequence(Sequence baseSequence)
          Adds a base sequence to the factor trie, i.e., add all factors of the adequate size of this sequence to the trie.
 Pair<java.lang.Integer,java.lang.Integer> countOccurrences(Sequence pattern, int beginIndex, int endIndex, int offset)
          Counts the number of occurrences of the patterns pattern[beginIndex..endIndex-2] and pattern[beginIndex..endIndex-1] respectively, as prefixes of the words represented by the subtries rooted at nodes at a given height.
 void removeBaseSequence(Sequence baseSequence)
          Removes one occurrence of a base sequence from the factor trie, that is, removes one occurrence of each factor of the appropriate length of this base sequence from the factor trie.
 
Methods inherited from class jbil.sequence.Trie
addSequence, addSequence, countOccurrences, deleteSequence, deleteSequence, getAlphabet, getHeight, getSequenceList, print, reset, sequenceCount
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactorTrie

public FactorTrie(Alphabet alphabet,
                  int factorLength)
Creates an empty factor trie.

Parameters:
alphabet - The base alphabet.
factorLength - The length of the represented factors.

FactorTrie

public FactorTrie(Sequence baseSequence,
                  int factorLength)
Creates a factor trie representing the factors of a given sequence.

Parameters:
baseSequence - The base sequence whose factors are to be represented.
factorLength - The length of the represented factors.
Method Detail

addBaseSequence

public void addBaseSequence(Sequence baseSequence)
Adds a base sequence to the factor trie, i.e., add all factors of the adequate size of this sequence to the trie. A same base sequence can be added more than once. In ths case, its factors will be considered multiple times.

Parameters:
baseSequence - The new base sequence.

removeBaseSequence

public void removeBaseSequence(Sequence baseSequence)
Removes one occurrence of a base sequence from the factor trie, that is, removes one occurrence of each factor of the appropriate length of this base sequence from the factor trie.

Parameters:
baseSequence - The base sequence whose factors are to be removed.

countOccurrences

public Pair<java.lang.Integer,java.lang.Integer> countOccurrences(Sequence pattern,
                                                                  int beginIndex,
                                                                  int endIndex,
                                                                  int offset)
Description copied from class: Trie
Counts the number of occurrences of the patterns pattern[beginIndex..endIndex-2] and pattern[beginIndex..endIndex-1] respectively, as prefixes of the words represented by the subtries rooted at nodes at a given height.

Specified by:
countOccurrences in interface KMerCounter
Overrides:
countOccurrences in class Trie
Parameters:
pattern - The base pattern.
beginIndex - The start position of the subpattern to be counted.
endIndex - The end position (not inclusive) of the subpattern to be counted.
offset - The height of the nodes at which the search must begin.