[go: nahoru, domu]

Skip to content

Commit

Permalink
add function for init-ing search range from single character
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawwave committed Jan 29, 2024
1 parent 6062d17 commit 0601107
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/AwFmIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,25 @@ struct AwFmSearchRange awFmCreateInitialQueryRange(
const struct AwFmIndex *_RESTRICT_ const index, const char *_RESTRICT_ const query, const uint8_t queryLength);


/*
* Function: awFmCreateInitialQueryRangeFromChar
* --------------------
* Creates the initial Start Pointer - End Pointer range for the given query.
* This is a simpler version of the awFmCreateInitialQueryRange function for when
* you just want to start the range based off a single character
*
* NOTE: This function is likely only useful if you need to query on a letter-by-letter
* basis, e.g., to implement inexact matching. If you just want to query for exact matches,
* especially for many queries, use awFmParallelSearchLocate or awFmParallelSearchCount instead.
*
* Inputs:
* index: AwFmIndex struct to search
* letter: letter to begin the search with. This will represent the final chacter in a searched kmer.
*/
struct AwFmSearchRange awFmCreateInitialQueryRangeFromChar(
const struct AwFmIndex *_RESTRICT_ const index, const char letter);


/*
* Function: awFmIterativeStepBackwardSearch
* --------------------
Expand Down
17 changes: 17 additions & 0 deletions src/AwFmSearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ struct AwFmSearchRange awFmCreateInitialQueryRange(
}


struct AwFmSearchRange awFmCreateInitialQueryRangeFromChar(
const struct AwFmIndex *_RESTRICT_ const index, const char letter){
uint8_t letterIndex;
if(index->config.alphabetType != AwFmAlphabetAmino) {
letterIndex = awFmAsciiNucleotideToLetterIndex(letter);
}
else {
letterIndex = awFmAsciiAminoAcidToLetterIndex(letter);
}
struct AwFmSearchRange searchRange;
searchRange.startPtr = index->prefixSums[letterIndex],
searchRange.endPtr = index->prefixSums[letterIndex + 1] - 1;

return searchRange;
}


void awFmNucleotideIterativeStepBackwardSearch(
const struct AwFmIndex *_RESTRICT_ const index, struct AwFmSearchRange *_RESTRICT_ const range, const uint8_t letter) {

Expand Down

0 comments on commit 0601107

Please sign in to comment.