NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions
blast_lookup.h File Reference

Common definitions for protein and nucleotide lookup tables. More...

#include <algo/blast/core/ncbi_std.h>
#include <algo/blast/core/blast_def.h>
+ Include dependency graph for blast_lookup.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  BackboneCell
 Thin backbone cell for nucleotide lookup table with hashed words. More...
 

Macros

#define PV_ARRAY_TYPE   Uint4
 The pv_array 'native' type. More...
 
#define PV_ARRAY_BYTES   4
 number of BYTES in 'native' type. More...
 
#define PV_ARRAY_BTS   5
 bits-to-shift from lookup_index to pv_array index. More...
 
#define PV_ARRAY_MASK   31
 amount to mask off. More...
 
#define PV_SET(lookup, index, shift)    lookup[(index) >> (shift)] |= (PV_ARRAY_TYPE)1 << ((index) & PV_ARRAY_MASK)
 Set the bit at position 'index' in the PV array bitfield within 'lookup'. More...
 
#define PV_TEST(lookup, index, shift)
 Test the bit at position 'index' in the PV array bitfield within 'lookup'. More...
 

Typedefs

typedef struct BackboneCell BackboneCell
 Thin backbone cell for nucleotide lookup table with hashed words. More...
 
typedef Uint4(* TNaLookupHashFunction) (Uint1 *, Uint4)
 Hash function type for the lookup table. More...
 

Functions

void BlastLookupAddWordHit (Int4 **backbone, Int4 wordsize, Int4 charsize, Uint1 *seq, Int4 query_offset)
 Add a single query offset to a generic lookup table. More...
 
void BlastLookupIndexQueryExactMatches (Int4 **backbone, Int4 word_length, Int4 charsize, Int4 lut_word_length, BLAST_SequenceBlk *query, BlastSeqLoc *locations)
 Add all applicable query offsets to a generic lookup table. More...
 
static NCBI_INLINE Int4 ComputeTableIndex (Int4 wordsize, Int4 charsize, const Uint1 *word)
 Given a word, compute its index value from scratch. More...
 
static NCBI_INLINE Int4 ComputeTableIndexIncremental (Int4 wordsize, Int4 charsize, Int4 mask, const Uint1 *word, Int4 index)
 Given a word, compute its index value, reusing a previously computed index value. More...
 
BackboneCellBackboneCellFree (BackboneCell *cell)
 
BackboneCellBackboneCellNew (Uint4 word, Int4 offset)
 Create a new cell for a given word and offset. More...
 
Int4 BackboneCellInit (BackboneCell *cell, Uint4 word, Int4 offset)
 Initialize an olready allocated cell for a given word and offset. More...
 
void BlastHashLookupIndexQueryExactMatches (BackboneCell *backbone, Int4 *offsets, Int4 word_length, Int4 charsize, Int4 lut_word_length, BLAST_SequenceBlk *query, BlastSeqLoc *locations, TNaLookupHashFunction hash_func, Uint4 mask, Uint4 *pv_array)
 Add all applicable query offsets to a hashed lookup table. More...
 

Detailed Description

Common definitions for protein and nucleotide lookup tables.

Definition in file blast_lookup.h.

Macro Definition Documentation

◆ PV_ARRAY_BTS

#define PV_ARRAY_BTS   5

bits-to-shift from lookup_index to pv_array index.

Definition at line 43 of file blast_lookup.h.

◆ PV_ARRAY_BYTES

#define PV_ARRAY_BYTES   4

number of BYTES in 'native' type.

Definition at line 42 of file blast_lookup.h.

◆ PV_ARRAY_MASK

#define PV_ARRAY_MASK   31

amount to mask off.

Definition at line 44 of file blast_lookup.h.

◆ PV_ARRAY_TYPE

#define PV_ARRAY_TYPE   Uint4

The pv_array 'native' type.

Definition at line 41 of file blast_lookup.h.

◆ PV_SET

#define PV_SET (   lookup,
  index,
  shift 
)     lookup[(index) >> (shift)] |= (PV_ARRAY_TYPE)1 << ((index) & PV_ARRAY_MASK)

Set the bit at position 'index' in the PV array bitfield within 'lookup'.

Definition at line 49 of file blast_lookup.h.

◆ PV_TEST

#define PV_TEST (   lookup,
  index,
  shift 
)
Value:
( lookup[(index) >> (shift)] & \
((PV_ARRAY_TYPE)1 << ((index) & PV_ARRAY_MASK)) )
#define PV_ARRAY_MASK
amount to mask off.
Definition: blast_lookup.h:44
#define PV_ARRAY_TYPE
The pv_array 'native' type.
Definition: blast_lookup.h:41
static int lookup(const char *name, const struct lookup_int *table)
Definition: attributes.c:50

Test the bit at position 'index' in the PV array bitfield within 'lookup'.

Definition at line 55 of file blast_lookup.h.

Typedef Documentation

◆ BackboneCell

typedef struct BackboneCell BackboneCell

Thin backbone cell for nucleotide lookup table with hashed words.

◆ TNaLookupHashFunction

typedef Uint4(* TNaLookupHashFunction) (Uint1 *, Uint4)

Hash function type for the lookup table.

Definition at line 142 of file blast_lookup.h.

Function Documentation

◆ BackboneCellFree()

BackboneCell* BackboneCellFree ( BackboneCell cell)

Definition at line 135 of file blast_lookup.c.

References b, next(), NULL, and sfree.

Referenced by BackboneCellNew(), and s_BlastNaHashLookupFinalize().

◆ BackboneCellInit()

Int4 BackboneCellInit ( BackboneCell cell,
Uint4  word,
Int4  offset 
)

Initialize an olready allocated cell for a given word and offset.

Parameters
cellPointer to allocated cell [in|out]
wordNucleotide word in 2na [in]
offsetOffset for the word [in]

Definition at line 161 of file blast_lookup.c.

References BackboneCell::num_offsets, BackboneCell::offset, offset, and BackboneCell::word.

Referenced by BackboneCellNew(), and s_AddWordHit().

◆ BackboneCellNew()

BackboneCell* BackboneCellNew ( Uint4  word,
Int4  offset 
)

Create a new cell for a given word and offset.

Parameters
wordNucleotide word in 2na [in]
offsetOffset for the word [in]

Definition at line 148 of file blast_lookup.c.

References BackboneCellFree(), BackboneCellInit(), calloc(), NULL, and offset.

Referenced by s_AddWordHit().

◆ BlastHashLookupIndexQueryExactMatches()

void BlastHashLookupIndexQueryExactMatches ( BackboneCell backbone,
Int4 offsets,
Int4  word_length,
Int4  charsize,
Int4  lut_word_length,
BLAST_SequenceBlk query,
BlastSeqLoc locations,
TNaLookupHashFunction  hash_func,
Uint4  mask,
Uint4 pv_array 
)

Add all applicable query offsets to a hashed lookup table.

Parameters
backboneThe current list of hashtable cells [in][out]
word_lengthNumber of letters in a word [in]
charsizeNumber of bits in one letter [in]
lut_word_lengthWidth of the lookup table in letters (must be <= word_length) [in]
queryThe query sequence [in]
locationsWhat locations on the query sequence to index? [in]
hash_funcHash function for words in 2na [in]
pv_arrayA bit fields with bits set for words that are to be included in the lookup table. Must be 1 bit per word. [in]
Parameters
pv_arrayThe pv_array 'native' type.

Referenced by BlastNaHashLookupTableNew().

◆ BlastLookupAddWordHit()

void BlastLookupAddWordHit ( Int4 **  backbone,
Int4  wordsize,
Int4  charsize,
Uint1 seq,
Int4  query_offset 
)

Add a single query offset to a generic lookup table.

Parameters
backboneThe current list of hashtable cells [in][out]
wordsizeNumber of letters in a word [in]
charsizeNumber of bits in one letter [in]
seqpointer to the beginning of the word [in]
query_offsetthe offset in the query where the word occurs [in]

Definition at line 33 of file blast_lookup.c.

References ASSERT, ComputeTableIndex(), malloc(), and NULL.

Referenced by BlastLookupIndexQueryExactMatches(), s_AddPSSMWordHitsCore(), s_AddWordHits(), and s_AddWordHitsCore().

◆ BlastLookupIndexQueryExactMatches()

void BlastLookupIndexQueryExactMatches ( Int4 **  backbone,
Int4  word_length,
Int4  charsize,
Int4  lut_word_length,
BLAST_SequenceBlk query,
BlastSeqLoc locations 
)

Add all applicable query offsets to a generic lookup table.

Parameters
backboneThe current list of hashtable cells [in][out]
word_lengthNumber of letters in a word [in]
charsizeNumber of bits in one letter [in]
lut_word_lengthWidth of the lookup table in letters (must be <= word_length) [in]
queryThe query sequence [in]
locationsWhat locations on the query sequence to index? [in]

Definition at line 79 of file blast_lookup.c.

References BlastLookupAddWordHit(), SSeqRange::left, BlastSeqLoc::next, offset, query, SSeqRange::right, and BlastSeqLoc::ssr.

Referenced by BlastNaLookupTableNew(), BlastSmallNaLookupTableNew(), and s_AddNeighboringWords().

◆ ComputeTableIndex()

static NCBI_INLINE Int4 ComputeTableIndex ( Int4  wordsize,
Int4  charsize,
const Uint1 word 
)
static

Given a word, compute its index value from scratch.

Parameters
wordsizelength of the word, in residues [in]
charsizelength of one residue, in bits [in]
wordpointer to the beginning of the word [in]
Returns
the computed index value

Definition at line 96 of file blast_lookup.h.

References i.

Referenced by BlastLookupAddWordHit(), BlastRPSScanSubject(), s_BlastAaScanSubject(), and s_BlastSmallAaScanSubject().

◆ ComputeTableIndexIncremental()

static NCBI_INLINE Int4 ComputeTableIndexIncremental ( Int4  wordsize,
Int4  charsize,
Int4  mask,
const Uint1 word,
Int4  index 
)
static

Given a word, compute its index value, reusing a previously computed index value.

Parameters
wordsizelength of the word - 1, in residues [in]
charsizelength of one residue, in bits [in]
maskvalue used to mask the index so that only the bottom wordsize * charsize bits remain [in]
wordpointer to the beginning of the word [in]
indexthe current value of the index [in]
Returns
the computed index value

Definition at line 121 of file blast_lookup.h.

References mask.

Referenced by BlastRPSScanSubject(), s_BlastAaScanSubject(), and s_BlastSmallAaScanSubject().

Modified on Sun Apr 21 03:37:40 2024 by modify_doxy.py rev. 669887