jbil.sequence
Class TrieForest

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

public class TrieForest
extends java.lang.Object
implements KMerCounter

Class representing a trie forest. Each trie in the forest can either be active or inactive. If it is inactive, it is not counted as participating in the forest, although it is physically present.

Author:
Paulo G. S. da Fonseca

Constructor Summary
TrieForest()
          Creates an empty forest of tries.
 
Method Summary
 void addTrie(Trie trie)
          Add a trie to the forest.
 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 words represented by the subtries of the active tries in the forest rooted at nodes at a given height.
 boolean isActiveTrie(int index)
          Checks whether the trie at a given position is active or not.
 Trie removeTrie(Trie trie)
          Removes a trie from the forest.
 int sequenceCount()
          Returns the total number of words represented by the active tries in the forest, taking into account word multiplicity and high order symbols.
 void setActiveTrie(int index, boolean active)
          Sets the status of the trie at a given position in the forest active/inactive.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrieForest

public TrieForest()
Creates an empty forest of tries.

Method Detail

addTrie

public void addTrie(Trie trie)
Add a trie to the forest.

Parameters:
trie - The trie to be added.

removeTrie

public Trie removeTrie(Trie trie)
Removes a trie from the forest.

Parameters:
trie - The trie to be removed.
Returns:
The removed trie.

isActiveTrie

public boolean isActiveTrie(int index)
Checks whether the trie at a given position is active or not.

Parameters:
index - The position of the trie in the forest.

setActiveTrie

public void setActiveTrie(int index,
                          boolean active)
Sets the status of the trie at a given position in the forest active/inactive.

Parameters:
index - The position of the trie in the forest.
active - The status: false=inactive, true=active.

countOccurrences

public 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 words represented by the subtries of the active tries in the forest rooted at nodes at a given height.

Specified by:
countOccurrences in interface KMerCounter
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.
See Also:
Trie.countOccurrences(Sequence, int, int, int)

sequenceCount

public int sequenceCount()
Returns the total number of words represented by the active tries in the forest, taking into account word multiplicity and high order symbols.

Specified by:
sequenceCount in interface KMerCounter