OpenMS
Loading...
Searching...
No Matches
ACTrieState Struct Reference

#include <OpenMS/ANALYSIS/ID/AhoCorasickAmbiguous.h>

Public Member Functions

void setQuery (const std::string &haystack)
 
size_t textPos () const
 
const char * textPosIt () const
 
const std::string & getQuery () const
 The current query.
 
AA nextValidAA ()
 

Public Attributes

friend ACScout
 
std::vector< Hit > hits
 
std::queue< ACScout > scouts
 
Index tree_pos
 position in trie (for the Primary)
 

Private Attributes

const char * it_q_ = ""
 
std::string query_
 current query ( = haystack = text)
 

Detailed Description

A state object for an ACTrie, i.e. dynamic information when traversing the trie (which is 'const' after construction) Useful when using multi-threading; each thread can walk the trie and keep track of its state using an instance of this class

Member Function Documentation

◆ getQuery()

const std::string & getQuery ( ) const

The current query.

◆ nextValidAA()

AA nextValidAA ( )

Return the next valid AA in the query. If the query was fully traversed, an invalid AA is returned. This moves the internal iterator for the query forwards.

◆ setQuery()

void setQuery ( const std::string &  haystack)

Set a haystack (query) where the needles (patterns) are to be searched This also resets the current trie-node to ROOT, and voids the hits

◆ textPos()

size_t textPos ( ) const

Where in the text are we currently?

Note
The result is undefined unless setQuery() was called before, since the position is computed relative to the current query (a default-constructed state points into an empty string literal instead)

◆ textPosIt()

const char * textPosIt ( ) const

Where in the text are we currently?

Note
See textPos(): without a preceding setQuery() this does not point into the query

Member Data Documentation

◆ ACScout

friend ACScout

◆ hits

std::vector<Hit> hits

current hits found

◆ it_q_

const char* it_q_ = ""
private

position in query; defaults to an empty string literal, so that a state which never saw a setQuery() reads as 'query fully consumed' instead of dereferencing an uninitialized pointer (could happen in OpenMP context, with more threads than proteins to search, where some threads never get a protein to search)

◆ query_

std::string query_
private

current query ( = haystack = text)

◆ scouts

std::queue<ACScout> scouts

initial scout points which are currently active and need processing. this needs a deque: ACTrie::nextHitsNoClear_() holds a reference to front() while pushing new scouts, which only a deque (not a vector) keeps valid.

◆ tree_pos

Index tree_pos

position in trie (for the Primary)