NCBI C++ ToolKit
|
Declaration of ADT to save and retrieve lists of HSPs in the BLAST engine. More...
#include <algo/blast/core/ncbi_std.h>
#include <algo/blast/core/blast_export.h>
#include <algo/blast/core/blast_hits.h>
#include <algo/blast/core/split_query.h>
#include <algo/blast/core/blast_program.h>
#include <algo/blast/core/blast_hspfilter.h>
#include <algo/blast/core/spliced_hits.h>
#include <connect/ncbi_core.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | SSortByScoreStruct |
Auxiliary structure to allow sorting the results by score for the composition-based statistics code. More... | |
struct | BlastHSPStreamResultBatch |
structure used to hold a collection of hits retrieved from the HSPStream More... | |
struct | BlastHSPStream |
Default implementation of BlastHSPStream. More... | |
Typedefs | |
typedef struct SSortByScoreStruct | SSortByScoreStruct |
Auxiliary structure to allow sorting the results by score for the composition-based statistics code. More... | |
typedef struct BlastHSPStreamResultBatch | BlastHSPStreamResultBatch |
structure used to hold a collection of hits retrieved from the HSPStream More... | |
typedef struct BlastHSPStream | BlastHSPStream |
Default implementation of BlastHSPStream. More... | |
Functions | |
BlastHSPStreamResultBatch * | Blast_HSPStreamResultBatchInit (Int4 num_hsplists) |
create a new batch to hold HSP results More... | |
BlastHSPStreamResultBatch * | Blast_HSPStreamResultBatchFree (BlastHSPStreamResultBatch *batch) |
free a batch of HSP results. More... | |
BlastHSPStreamResultBatch * | Blast_HSPStreamResultBatchReset (BlastHSPStreamResultBatch *batch) |
free the list of HSPLists within a batch More... | |
BlastHSPStream * | BlastHSPStreamNew (EBlastProgramType program, const BlastExtensionOptions *extn_opts, Boolean sort_on_read, Int4 num_queries, BlastHSPWriter *writer) |
Initialize the HSP stream. More... | |
BlastHSPStream * | BlastHSPStreamFree (BlastHSPStream *hsp_stream) |
Frees the BlastHSPStream structure by invoking the destructor function set by the user-defined constructor function when the structure is initialized (indirectly, by BlastHSPStreamNew). More... | |
void | BlastHSPStreamClose (BlastHSPStream *hsp_stream) |
Closes the BlastHSPStream structure for writing. More... | |
void | BlastHSPStreamSimpleClose (BlastHSPStream *hsp_stream) |
Closes the BlastHSPStream structure for writing without any sorting as done in BlastHSPStreamClose. More... | |
void | BlastHSPStreamMappingClose (BlastHSPStream *hsp_stream, BlastMappingResults *results) |
Closes BlastHSPStream structure for mapping and produces BlastMappingResults. More... | |
void | BlastHSPStreamTBackClose (BlastHSPStream *hsp_stream, BlastHSPResults *results) |
Closes the BlastHSPStream structure after traceback. More... | |
int | BlastHSPStreamMerge (SSplitQueryBlk *squery_blk, Uint4 chunk_num, BlastHSPStream *hsp_stream, BlastHSPStream *combined_hsp_stream) |
Moves the HSPlists from an HSPStream into the list contained by a second HSPStream. More... | |
int | BlastHSPStreamWrite (BlastHSPStream *hsp_stream, BlastHSPList **hsp_list) |
Invokes the user-specified write function for this BlastHSPStream implementation. More... | |
int | BlastHSPStreamRead (BlastHSPStream *hsp_stream, BlastHSPList **hsp_list) |
Invokes the user-specified read function for this BlastHSPStream implementation. More... | |
int | BlastHSPStreamBatchRead (BlastHSPStream *hsp_stream, BlastHSPStreamResultBatch *batch) |
Batch read function for this BlastHSPStream implementation. More... | |
int | BlastHSPStreamRegisterMTLock (BlastHSPStream *hsp_stream, MT_LOCK lock) |
Attach a mutex lock to a stream to protect multiple access during writing. More... | |
int | BlastHSPStreamRegisterPipe (BlastHSPStream *hsp_stream, BlastHSPPipe *pipe, EBlastStage stage) |
Insert the user-specified pipe to the *end* of the pipeline. More... | |
void | BlastHSPCBSStreamClose (BlastHSPStream *hsp_stream, int hitlist_size) |
Variables | |
const int | kBlastHSPStream_Error |
Standard error return value for BlastHSPStream methods. More... | |
const int | kBlastHSPStream_Success |
Standard success return value for BlastHSPStream methods. More... | |
const int | kBlastHSPStream_Eof |
Return value when the end of the stream is reached (applicable to read method only) More... | |
Declaration of ADT to save and retrieve lists of HSPs in the BLAST engine.
Definition in file blast_hspstream.h.
typedef struct BlastHSPStream BlastHSPStream |
Default implementation of BlastHSPStream.
typedef struct BlastHSPStreamResultBatch BlastHSPStreamResultBatch |
structure used to hold a collection of hits retrieved from the HSPStream
typedef struct SSortByScoreStruct SSortByScoreStruct |
Auxiliary structure to allow sorting the results by score for the composition-based statistics code.
BlastHSPStreamResultBatch* Blast_HSPStreamResultBatchFree | ( | BlastHSPStreamResultBatch * | batch | ) |
free a batch of HSP results.
Note that the HSPLists themselves are not freed
batch | Structure to free |
Definition at line 628 of file blast_hspstream.c.
References BlastHSPStreamResultBatch::hsplist_array, NULL, and sfree.
Referenced by BlastHSPStreamToHSPStreamResultsBatch(), and s_BlastHSPStreamResultsBatchArrayReset().
BlastHSPStreamResultBatch* Blast_HSPStreamResultBatchInit | ( | Int4 | num_hsplists | ) |
create a new batch to hold HSP results
num_hsplists | Maximum number of results to hold |
Definition at line 617 of file blast_hspstream.c.
References calloc(), and BlastHSPStreamResultBatch::hsplist_array.
Referenced by BlastHSPStreamToHSPStreamResultsBatch().
BlastHSPStreamResultBatch* Blast_HSPStreamResultBatchReset | ( | BlastHSPStreamResultBatch * | batch | ) |
free the list of HSPLists within a batch
batch | Structure to reset |
Definition at line 639 of file blast_hspstream.c.
References Blast_HSPListFree(), BlastHSPStreamResultBatch::hsplist_array, i, NULL, and BlastHSPStreamResultBatch::num_hsplists.
Referenced by BLAST_ComputeTraceback_MT(), and s_BlastHSPStreamResultsBatchArrayReset().
void BlastHSPCBSStreamClose | ( | BlastHSPStream * | hsp_stream, |
int | hitlist_size | ||
) |
Definition at line 816 of file blast_hspstream.c.
References BlastHSPList::best_evalue, Blast_HitListSortByEvalue(), BlastHSPStreamClose(), BlastHitList::hsplist_array, BlastHitList::hsplist_count, i, log10(), MAX, BlastHSPStream::results, results, BlastHSPStream::results_sorted, s_FinalizeWriter(), and s_TrimHitList().
Referenced by Blast_RunTracebackSearchWithInterrupt().
int BlastHSPStreamBatchRead | ( | BlastHSPStream * | hsp_stream, |
BlastHSPStreamResultBatch * | batch | ||
) |
Batch read function for this BlastHSPStream implementation.
hsp_stream | The BlastHSPStream object [in] |
batch | List of HSP lists for the HSPStream to return. The caller acquires ownership of all HSP lists returned [out] |
Definition at line 568 of file blast_hspstream.c.
References BlastHSPStreamClose(), BlastHSPStreamResultBatch::hsplist_array, i, kBlastHSPStream_Eof, kBlastHSPStream_Error, kBlastHSPStream_Success, BlastHSPStreamResultBatch::num_hsplists, BlastHSPStream::num_hsplists, BlastHSPList::oid, BlastHSPStream::results, BlastHSPStream::results_sorted, and BlastHSPStream::sorted_hsplists.
Referenced by BlastHSPStreamToHSPStreamResultsBatch().
void BlastHSPStreamClose | ( | BlastHSPStream * | hsp_stream | ) |
Closes the BlastHSPStream structure for writing.
Any subsequent attempt to write to the stream will return error.
hsp_stream | The stream to close [in] [out] |
Closes the BlastHSPStream structure for writing.
Also perform sorting of results here to prepare them for reading.
hsp_stream | The HSP stream to close [in] [out] |
Definition at line 133 of file blast_hspstream.c.
References Blast_HSPResultsReverseOrder(), Blast_HSPResultsReverseSort(), BlastHitList::hsplist_array, BlastHitList::hsplist_count, i, MAX, MT_LOCK_Delete(), NULL, BlastHSPStream::num_hsplists, BlastHSPStream::num_hsplists_alloc, BlastHSPList::query_index, BlastHSPStream::results, results, BlastHSPStream::results_sorted, s_FinalizeWriter(), s_SortHSPListByOid(), BlastHSPStream::sort_by_score, SSortByScoreStruct::sort_on_read, BlastHSPStream::sorted_hsplists, TRUE, and BlastHSPStream::x_lock.
Referenced by Blast_RunFullSearch(), Blast_RunTracebackSearchWithInterrupt(), BlastHSPCBSStreamClose(), BlastHSPStreamBatchRead(), BlastHSPStreamRead(), and testHSPStream().
BlastHSPStream* BlastHSPStreamFree | ( | BlastHSPStream * | hsp_stream | ) |
Frees the BlastHSPStream structure by invoking the destructor function set by the user-defined constructor function when the structure is initialized (indirectly, by BlastHSPStreamNew).
If the destructor function pointer is not set, a memory leak could occur.
hsp_stream | BlastHSPStream to free [in] |
Frees the BlastHSPStream structure by invoking the destructor function set by the user-defined constructor function when the structure is initialized (indirectly, by BlastHSPStreamNew).
Free the BlastHSPStream with its HSP list collector data structure.
hsp_stream | The HSP stream to free [in] |
Definition at line 46 of file blast_hspstream.c.
References Blast_HSPListFree(), Blast_HSPResultsFree(), BlastHSPWriter::FreeFnPtr, MT_LOCK_Delete(), BlastHSPPipe::next, NULL, BlastHSPStream::num_hsplists, BlastHSPStream::pre_pipe, BlastHSPStream::results, sfree, BlastHSPStream::sort_by_score, BlastHSPStream::sorted_hsplists, BlastHSPStream::tback_pipe, BlastHSPStream::writer, and BlastHSPStream::x_lock.
Referenced by BlastSetupPreliminarySearchEx(), BOOST_AUTO_TEST_CASE(), Deleter< BlastHSPStream >::Delete(), CRedoAlignmentTestFixture::runRedoAlignmentCoreUnitTest(), testHSPStream(), CTracebackSearchTestFixture::x_GetSampleHspStream(), and CTracebackSearchTestFixture::x_GetSelfHitHspStream().
void BlastHSPStreamMappingClose | ( | BlastHSPStream * | hsp_stream, |
BlastMappingResults * | results | ||
) |
Closes BlastHSPStream structure for mapping and produces BlastMappingResults.
hsp_stream | The stream to close [in] [out] |
results | The results [in] [out] |
Definition at line 209 of file blast_hspstream.c.
References BlastHSPWriter::data, BlastHSPWriter::FinalFnPtr, BlastHSPWriter::InitFnPtr, MT_LOCK_Delete(), BlastHSPStream::results, results, TRUE, BlastHSPStream::writer, BlastHSPStream::writer_finalized, BlastHSPStream::writer_initialized, and BlastHSPStream::x_lock.
Referenced by CMagicBlast::Run(), and CMagicBlast::RunEx().
int BlastHSPStreamMerge | ( | SSplitQueryBlk * | squery_blk, |
Uint4 | chunk_num, | ||
BlastHSPStream * | stream1, | ||
BlastHSPStream * | stream2 | ||
) |
Moves the HSPlists from an HSPStream into the list contained by a second HSPStream.
squery_blk | Information needed to map HSPs from one HSPstream to the combined HSPstream [in] |
chunk_num | Used to choose a subset of the information in squery_blk [in] |
hsp_stream | The stream to merge [in][out] |
combined_hsp_stream | The stream that will contain the HSPLists of the first stream [in][out] |
Moves the HSPlists from an HSPStream into the list contained by a second HSPStream.
The HSPs from the first stream are moved to the second stream.
squery_blk | Structure controlling the merge process [in] |
chunk_num | Unique integer assigned to hsp_stream [in] |
stream1 | The stream to merge [in][out] |
stream2 | The stream that will contain the HSPLists of the first stream [in][out] |
Definition at line 399 of file blast_hspstream.c.
References ASSERT, BLAST_ContextToFrame(), BLAST_GetNumberOfContexts(), Blast_HitListMerge(), Blast_HSPListSortByScore(), BlastHSP::context, BlastSeg::end, FALSE, BlastSeg::frame, BlastSeg::gapped_start, BlastHSPList::hsp_array, BlastHSPList::hspcnt, BlastHitList::hsplist_array, BlastHitList::hsplist_count, i, INT4_MIN, kBlastHSPStream_Error, kBlastHSPStream_Success, MAX, NULL, NUM_FRAMES, BlastSeg::offset, BlastHSPList::oid, BlastHSPStream::program, BlastHSP::query, BlastHSPList::query_index, BlastHSPStream::results, results1, results2, BlastHSPStream::results_sorted, s_FinalizeWriter(), BlastHSP::score, sfree, SplitQueryBlk_AllowGap(), SplitQueryBlk_GetChunkOverlapSize(), SplitQueryBlk_GetContextOffsetsForChunk(), SplitQueryBlk_GetQueryContextsForChunk(), SplitQueryBlk_GetQueryIndicesForChunk(), BlastHSP::subject, and UINT4_MAX.
Referenced by CBlastPrelimSearch::Run().
BlastHSPStream* BlastHSPStreamNew | ( | EBlastProgramType | program, |
const BlastExtensionOptions * | extn_opts, | ||
Boolean | sort_on_read, | ||
Int4 | num_queries, | ||
BlastHSPWriter * | writer | ||
) |
Initialize the HSP stream.
program | Type of BlAST program [in] |
extn_opts | Extension options to determine composition-based statistics mode [in] |
sort_on_read | Should results be sorted on the first read call? Only applicable if composition-based statistics is on [in] |
num_queries | Number of query sequences in this BLAST search [in] |
writer | Writer to be registered [in] |
Definition at line 653 of file blast_hspstream.c.
References Blast_HSPResultsNew(), Blast_QueryIsProtein(), Blast_QueryIsPssm(), calloc(), BlastExtensionOptions::compositionBasedStats, FALSE, SSortByScoreStruct::first_query_index, malloc(), NULL, BlastHSPStream::num_hsplists, BlastHSPStream::num_hsplists_alloc, BlastHSPStream::pre_pipe, BlastHSPStream::program, BlastHSPStream::results, BlastHSPStream::results_sorted, BlastHSPStream::sort_by_score, SSortByScoreStruct::sort_on_read, BlastHSPStream::sorted_hsplists, BlastHSPStream::tback_pipe, BlastHSPStream::writer, BlastHSPStream::writer_finalized, BlastHSPStream::writer_initialized, and BlastHSPStream::x_lock.
Referenced by BOOST_AUTO_TEST_CASE(), CSetupFactory::CreateHspStream(), CRedoAlignmentTestFixture::runRedoAlignmentCoreUnitTest(), testHSPStream(), CTracebackSearchTestFixture::x_GetSampleHspStream(), CTracebackSearchTestFixture::x_GetSelfHitHspStream(), and CTracebackTestFixture::x_MakeStream().
int BlastHSPStreamRead | ( | BlastHSPStream * | hsp_stream, |
BlastHSPList ** | hsp_list_out | ||
) |
Invokes the user-specified read function for this BlastHSPStream implementation.
hsp_stream | The BlastHSPStream object [in] |
hsp_list | List of HSPs for the HSPStream to return. The caller acquires ownership of the hsp_list [out] |
Invokes the user-specified read function for this BlastHSPStream implementation.
Once an HSP list is read from the stream, it relinquishes ownership and removes it from the internal results data structure.
hsp_stream | The HSP stream to read from [in] |
hsp_list_out | The read HSP list. [out] |
Definition at line 271 of file blast_hspstream.c.
References BlastHSPStreamClose(), SSortByScoreStruct::first_query_index, BlastHitList::hsplist_array, BlastHitList::hsplist_count, kBlastHSPStream_Eof, kBlastHSPStream_Error, kBlastHSPStream_Success, NULL, BlastHSPStream::num_hsplists, BlastHSPList::query_index, BlastHSPStream::results, results, BlastHSPStream::results_sorted, BlastHSPStream::sort_by_score, and BlastHSPStream::sorted_hsplists.
Referenced by Blast_HSPResultsFromHSPStream(), Blast_RedoAlignmentCore_MT(), BOOST_AUTO_TEST_CASE(), s_RPSComputeTraceback(), and testHSPStream().
int BlastHSPStreamRegisterMTLock | ( | BlastHSPStream * | hsp_stream, |
MT_LOCK | lock | ||
) |
Attach a mutex lock to a stream to protect multiple access during writing.
hsp_stream | The stream to attach [in] |
lock | Pointer to locking structure for writing by multiple threads. Locking will not be performed if NULL. [in] |
Definition at line 697 of file blast_hspstream.c.
References MT_LOCK_Delete(), and BlastHSPStream::x_lock.
Referenced by BlastSetupPreliminarySearchEx(), CBlastPrelimSearch::SetNumberOfThreads(), and testHSPStream().
int BlastHSPStreamRegisterPipe | ( | BlastHSPStream * | hsp_stream, |
BlastHSPPipe * | pipe, | ||
EBlastStage | stage | ||
) |
Insert the user-specified pipe to the *end* of the pipeline.
hsp_stream | The BlastHSPStream object [in] |
pipe | The pipe to be registered [in] |
stage | At what stage should this pipeline be applied [in] |
Definition at line 709 of file blast_hspstream.c.
References ePrelimSearch, eTracebackSearch, BlastHSPPipe::next, NULL, BlastHSPStream::pre_pipe, and BlastHSPStream::tback_pipe.
Referenced by BlastSetupPreliminarySearchEx().
void BlastHSPStreamSimpleClose | ( | BlastHSPStream * | hsp_stream | ) |
Closes the BlastHSPStream structure for writing without any sorting as done in BlastHSPStreamClose.
Any subsequent attempt to write to the stream will return error.
hsp_stream | The stream to close [in] [out] |
Definition at line 226 of file blast_hspstream.c.
References MT_LOCK_Delete(), s_FinalizeWriter(), and BlastHSPStream::x_lock.
void BlastHSPStreamTBackClose | ( | BlastHSPStream * | hsp_stream, |
BlastHSPResults * | results | ||
) |
Closes the BlastHSPStream structure after traceback.
This is mainly to provide a chance to apply post-traceback pipes.
hsp_stream | The stream to close [in] [out] |
results | The traceback results [in] [out] |
Closes the BlastHSPStream structure after traceback.
This is mainly to provide a chance to apply post-traceback pipes.
hsp_stream | The HSP stream to close [in] [out] |
results | The traceback results [in] [out] |
Definition at line 241 of file blast_hspstream.c.
References BlastHSPPipe::data, BlastHSPPipe::FreeFnPtr, BlastHSPPipe::next, results, BlastHSPPipe::RunFnPtr, and BlastHSPStream::tback_pipe.
Referenced by BLAST_ComputeTraceback_MT(), Blast_RedoAlignmentCore_MT(), and s_RPSComputeTraceback().
int BlastHSPStreamWrite | ( | BlastHSPStream * | hsp_stream, |
BlastHSPList ** | hsp_list | ||
) |
Invokes the user-specified write function for this BlastHSPStream implementation.
hsp_stream | The BlastHSPStream object [in] |
hsp_list | List of HSPs for the HSPStream to keep track of. The caller releases ownership of the hsp_list [in] |
Invokes the user-specified write function for this BlastHSPStream implementation.
The HSP stream assumes ownership of the HSP list and sets the dereferenced pointer to NULL.
hsp_stream | Stream to write to. [in] [out] |
hsp_list | Pointer to the HSP list to save in the collector. [in] |
Definition at line 339 of file blast_hspstream.c.
References BlastHSPWriter::data, eMT_Lock, eMT_Unlock, FALSE, BlastHSPWriter::InitFnPtr, kBlastHSPStream_Error, kBlastHSPStream_Success, MT_LOCK_Do, NULL, BlastHSPStream::results, BlastHSPStream::results_sorted, BlastHSPWriter::RunFnPtr, TRUE, BlastHSPStream::writer, BlastHSPStream::writer_initialized, and BlastHSPStream::x_lock.
Referenced by BLAST_PreliminarySearchEngine(), BOOST_AUTO_TEST_CASE(), DoAnchoredSearch(), CHspStreamWriteThread::Main(), CRedoAlignmentTestFixture::runRedoAlignmentCoreUnitTest(), s_RPSPreliminarySearchEngine(), testHSPStream(), CTracebackSearchTestFixture::x_GetSampleHspStream(), and CTracebackSearchTestFixture::x_GetSelfHitHspStream().
Return value when the end of the stream is reached (applicable to read method only)
Definition at line 262 of file blast_hspstream.c.
Referenced by Blast_HSPResultsFromHSPStream(), Blast_RedoAlignmentCore_MT(), BlastHSPStreamBatchRead(), BlastHSPStreamRead(), BlastHSPStreamToHSPStreamResultsBatch(), BOOST_AUTO_TEST_CASE(), s_RPSComputeTraceback(), and testHSPStream().
Standard error return value for BlastHSPStream methods.
Definition at line 260 of file blast_hspstream.c.
Referenced by BlastHSPStreamBatchRead(), BlastHSPStreamMerge(), BlastHSPStreamRead(), BlastHSPStreamWrite(), and testHSPStream().
Standard success return value for BlastHSPStream methods.
Definition at line 261 of file blast_hspstream.c.
Referenced by BlastHSPStreamBatchRead(), BlastHSPStreamMerge(), BlastHSPStreamRead(), BlastHSPStreamToHSPStreamResultsBatch(), BlastHSPStreamWrite(), BOOST_AUTO_TEST_CASE(), CHspStreamWriteThread::Main(), and testHSPStream().