(index=0; index < hsp_stream->
num_hsplists; index++)
65 if(hsp_stream->
writer) {
95 return(*yy)->
oid- (*xx)->oid;
108 if(hsp_stream->
writer) {
162 for(
i= 0;
i<
results->num_queries;
i++) {
165 if(hitlist ==
NULL)
184 if(hsplist ==
NULL)
200 if(num_hsplists > 1) {
212 if(!hsp_stream || !hsp_stream->
writer)
246 if(!hsp_stream || !
results) {
273*hsp_list_out =
NULL;
290 Int4last_hsplist_index = -1, index = 0;
296index < results->num_queries; ++index) {
297 if(
results->hitlist_array[index] &&
298 results->hitlist_array[index]->hsplist_count > 0)
301 if(index >=
results->num_queries)
306hit_list =
results->hitlist_array[index];
309*hsp_list_out = hit_list->
hsplist_array[last_hsplist_index];
359 if(hsp_stream->
writer) {
407 Int4contexts_per_query = 0;
409 Int4num_queries = 0, num_ctx = 0, num_ctx_offsets = 0;
413 Uint4*query_list =
NULL, *offset_list =
NULL, num_contexts = 0;
417 if(!stream1 || !stream2)
430&context_list, &num_contexts);
433 #if defined(_DEBUG_VERBOSE) 434fprintf(stderr,
"Chunk %d\n", chunk_num);
435fprintf(stderr,
"Queries : ");
436 for(num_queries = 0; query_list[num_queries] !=
UINT4_MAX; num_queries++)
437fprintf(stderr,
"%d ", query_list[num_queries]);
438fprintf(stderr,
"\n");
439fprintf(stderr,
"Contexts : ");
440 for(num_ctx = 0; num_ctx < num_contexts; num_ctx++)
441fprintf(stderr,
"%d ", context_list[num_ctx]);
442fprintf(stderr,
"\n");
443fprintf(stderr,
"Context starting offsets : ");
444 for(num_ctx_offsets = 0; offset_list[num_ctx_offsets] !=
UINT4_MAX;
446fprintf(stderr,
"%d ", offset_list[num_ctx_offsets]);
447fprintf(stderr,
"\n");
448 #elif defined(_DEBUG) 449 for(num_queries = 0; query_list[num_queries] !=
UINT4_MAX; num_queries++) ;
450 for(num_ctx = 0, max_ctx =
INT4_MIN; num_ctx < (
Int4)num_contexts; num_ctx++)
451max_ctx =
MAX(max_ctx, context_list[num_ctx]);
452 for(num_ctx_offsets = 0; offset_list[num_ctx_offsets] !=
UINT4_MAX;
458 Int4global_query = query_list[
i];
464 if(hitlist ==
NULL) {
465 #if defined(_DEBUG_VERBOSE) 466fprintf(stderr,
"No hits to query %d\n", global_query);
476 for(j = 0; j < contexts_per_query; j++) {
477split_points[j] = -1;
480 for(j = 0; j < contexts_per_query; j++) {
481 Int4local_context =
i* contexts_per_query + j;
482 if(context_list[local_context] >= 0) {
483split_points[context_list[local_context] % contexts_per_query] =
484offset_list[local_context];
488 #if defined(_DEBUG_VERBOSE) 489fprintf(stderr,
"query %d split points: ",
i);
490 for(j = 0; j < contexts_per_query; j++) {
491fprintf(stderr,
"%d ", split_points[j]);
493fprintf(stderr,
"\n");
499 for(k = 0; k < hsplist->
hspcnt; k++) {
503 ASSERT(local_context <= max_ctx);
504 ASSERT(local_context < num_ctx);
505 ASSERT(local_context < num_ctx_offsets);
508hsp->
context= context_list[local_context];
509hsp->
query.
offset+= offset_list[local_context];
510hsp->
query.
end+= offset_list[local_context];
520 results2->hitlist_array + global_query,
521contexts_per_query, split_points,
529 if(hitlist ==
NULL)
539fprintf(stderr,
"new results: %d queries\n",
results2->num_queries);
542 if(hitlist ==
NULL)
550 for(k = 0; k < hsplist->
hspcnt; k++) {
552fprintf(stderr,
"c %d q %d-%d s %d-%d score %d\n", hsp->
context,
562 sfree(context_list);
576 if(!hsp_stream || !batch)
596 if(num_hsplists == 0)
600target_oid = hsplist->
oid;
602 for(
i= 0;
i< num_hsplists;
i++) {
604 if(hsplist->
oid!= target_oid)
630 if(batch !=
NULL) {
642 if(batch !=
NULL) {
662hsp_stream->
program= program;
688hsp_stream->
writer= writer;
701 if(!hsp_stream || (hsp_stream->
x_lock&& lock)) {
705hsp_stream->
x_lock= lock;
715 if(!hsp_stream || !pipe) {
741 for(; p && p->
next; p = p->
next);
753 if(writer_info && *writer_info) {
754writer = ((*writer_info)->NewFnPtr) ((*writer_info)->params, query_info,
756 sfree(*writer_info);
758 ASSERT(writer_info && *writer_info ==
NULL);
769 while(
tmp->next) {
791p->
next= (
info->NewFnPtr) (
info->params, query_info);
794pipe = (
info->NewFnPtr) (
info->params, query_info);
810 for(index =
count; index < old_count; index++) {
829 for(index = 0; index <
results->num_queries; index++) {
830hit_list =
results->hitlist_array[index];
832 const intREF_HIT_NUM =
MAX(500, hitlist_size);
833 const intMIN_BUF_SZ = REF_HIT_NUM + 600;
836 doublebest_evalue = 0, evalue_limit = 0;
837 intmag = -180, pct = 90,
i= 0;
840 if(best_evalue != 0 ){
844mag =
MAX(mag*pct/100, mag +10);
849evalue_limit = (mag >= 0)? best_evalue*3: 9.9* pow(10, mag);
852 for(;
i< max_index;
i+=100) {
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
#define NUM_FRAMES
Number of frames to which we translate in translating searches.
EBlastStage
Enumeration for the stages in the BLAST search.
@ eTracebackSearch
Traceback stage.
@ ePrelimSearch
Preliminary stage.
Int2 Blast_HSPResultsReverseSort(BlastHSPResults *results)
Sort each hit list in the BLAST results by best e-value, in reverse order.
BlastHSPResults * Blast_HSPResultsFree(BlastHSPResults *results)
Deallocate memory for BLAST results.
Int2 Blast_HitListMerge(BlastHitList **old_hit_list_ptr, BlastHitList **combined_hit_list_ptr, Int4 contexts_per_query, Int4 *split_offsets, Int4 chunk_overlap_size, Boolean allow_gap)
Combine two hitlists; both HitLists must contain HSPs that represent alignments to the same query seq...
Int2 Blast_HSPResultsReverseOrder(BlastHSPResults *results)
Reverse order of HSP lists in each hit list in the BLAST results.
Int2 Blast_HitListSortByEvalue(BlastHitList *hit_list)
Sort BlastHitLIst bon evalue.
BlastHSPResults * Blast_HSPResultsNew(Int4 num_queries)
Initialize the results structure.
BlastHSPList * Blast_HSPListFree(BlastHSPList *hsp_list)
Deallocate memory for an HSP list structure as well as all it's components.
void Blast_HSPListSortByScore(BlastHSPList *hsp_list)
Sort the HSPs in an HSP list by score.
BlastHSPWriter * BlastHSPWriterNew(BlastHSPWriterInfo **writer_info, BlastQueryInfo *query_info, BLAST_SequenceBlk *query)
A generic function to create writer.
void BlastHSPStreamSimpleClose(BlastHSPStream *hsp_stream)
Closes the BlastHSPStream structure for writing without any sorting as done in BlastHSPStreamClose.
void BlastHSPStreamClose(BlastHSPStream *hsp_stream)
Prohibit any future writing to the HSP stream when all results are written.
BlastHSPPipe * BlastHSPPipeNew(BlastHSPPipeInfo **pipe_info, BlastQueryInfo *query_info)
A generic function to create pipe.
static void s_FinalizeWriter(BlastHSPStream *hsp_stream)
certain hspstreams (such as besthit and culling) uses its own data structure and therefore must be fi...
void s_TrimHitList(BlastHitList *hitlist, int count)
int BlastHSPStreamMerge(SSplitQueryBlk *squery_blk, Uint4 chunk_num, BlastHSPStream *stream1, BlastHSPStream *stream2)
Merge two HSPStreams.
static int s_SortHSPListByOid(const void *x, const void *y)
callback used to sort HSP lists in order of decreasing OID
int BlastHSPStreamWrite(BlastHSPStream *hsp_stream, BlastHSPList **hsp_list)
Write an HSP list to the collector HSP stream.
BlastHSPStreamResultBatch * Blast_HSPStreamResultBatchReset(BlastHSPStreamResultBatch *batch)
free the list of HSPLists within a batch
BlastHSPStream * BlastHSPStreamFree(BlastHSPStream *hsp_stream)
Default hit saving stream methods.
void BlastHSPStreamMappingClose(BlastHSPStream *hsp_stream, BlastMappingResults *results)
Closes BlastHSPStream structure for mapping and produces BlastMappingResults.
BlastHSPStream * BlastHSPStreamNew(EBlastProgramType program, const BlastExtensionOptions *extn_opts, Boolean sort_on_read, Int4 num_queries, BlastHSPWriter *writer)
Initialize the HSP stream.
const int kBlastHSPStream_Eof
Return value when the end of the stream is reached (applicable to read method only)
int BlastHSPStreamRegisterMTLock(BlastHSPStream *hsp_stream, MT_LOCK lock)
Attach a mutex lock to a stream to protect multiple access during writing.
const int kBlastHSPStream_Success
Standard success return value for BlastHSPStream methods.
void BlastHSPCBSStreamClose(BlastHSPStream *hsp_stream, int hitlist_size)
BlastHSPPipeInfo * BlastHSPPipeInfo_Add(BlastHSPPipeInfo **head, BlastHSPPipeInfo *node)
Adds node to the linked list starting a head, which should be NULL when initializing the linked list,...
int BlastHSPStreamRegisterPipe(BlastHSPStream *hsp_stream, BlastHSPPipe *pipe, EBlastStage stage)
Insert the user-specified pipe to the *end* of the pipeline.
void BlastHSPStreamTBackClose(BlastHSPStream *hsp_stream, BlastHSPResults *results)
Closing the HSP after traceback is done.
BlastHSPStreamResultBatch * Blast_HSPStreamResultBatchInit(Int4 num_hsplists)
create a new batch to hold HSP results
int BlastHSPStreamRead(BlastHSPStream *hsp_stream, BlastHSPList **hsp_list_out)
Read one HSP list from the results saved in an HSP list collector.
const int kBlastHSPStream_Error
Standard error return value for BlastHSPStream methods.
BlastHSPStreamResultBatch * Blast_HSPStreamResultBatchFree(BlastHSPStreamResultBatch *batch)
free a batch of HSP results.
int BlastHSPStreamBatchRead(BlastHSPStream *hsp_stream, BlastHSPStreamResultBatch *batch)
Batch read function for this BlastHSPStream implementation.
Declaration of ADT to save and retrieve lists of HSPs in the BLAST engine.
Private interfaces to support the multi-threaded traceback in conjunction with the BlastHSPStream.
Boolean Blast_QueryIsPssm(EBlastProgramType p)
Returns true if the query is PSSM.
Boolean Blast_QueryIsProtein(EBlastProgramType p)
Returns true if the query is protein.
EBlastProgramType
Defines the engine's notion of the different applications of the BLAST algorithm.
Various auxiliary BLAST utility functions.
Int1 BLAST_ContextToFrame(EBlastProgramType prog_number, Uint4 context_number)
This function translates the context number of a context into the frame of the sequence.
unsigned int BLAST_GetNumberOfContexts(EBlastProgramType program)
Get the number of contexts for a given program.
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
MT_LOCK MT_LOCK_Delete(MT_LOCK lk)
Decrement internal reference count by 1, and if it reaches 0, then destroy the handle,...
#define MT_LOCK_Do(lk, how)
Call "lk->handler(lk->data, how)".
@ eMT_Unlock
unlock critical section
@ eMT_Lock
lock critical section
Uint1 Boolean
bool replacment for C
#define TRUE
bool replacment for C indicating true.
#define FALSE
bool replacment for C indicating false.
#define UINT4_MAX
largest number represented by unsigned int.
#define ASSERT
macro for assert.
#define INT4_MIN
Smallest (most negative) number represented by signed int.
#define MAX(a, b)
returns larger of a and b.
Boolean SplitQueryBlk_AllowGap(SSplitQueryBlk *squery_blk)
Determines whether HSPs on different diagnonals may be merged.
Int2 SplitQueryBlk_GetQueryIndicesForChunk(const SSplitQueryBlk *squery_blk, Uint4 chunk_num, Uint4 **query_indices)
Retrieve an array of query indices for the requested chunk.
Int2 SplitQueryBlk_GetContextOffsetsForChunk(const SSplitQueryBlk *squery_blk, Uint4 chunk_num, Uint4 **context_offsets)
Retrieve an array of context offsets for the requested chunk.
Int2 SplitQueryBlk_GetQueryContextsForChunk(const SSplitQueryBlk *squery_blk, Uint4 chunk_num, Int4 **query_contexts, Uint4 *num_query_contexts)
Retrieve an array of query contexts for the requested chunk.
size_t SplitQueryBlk_GetChunkOverlapSize(const SSplitQueryBlk *squery_blk)
Returns the query chunk overlap size.
Structure to hold a sequence.
Options used for gapped extension These include: a.
Int4 compositionBasedStats
mode of compositional adjustment to use; if zero then compositional adjustment is not used
The structure to hold all HSPs for a given sequence after the gapped alignment.
Int4 oid
The ordinal id of the subject sequence this HSP list is for.
Int4 hspcnt
Number of HSPs saved.
BlastHSP ** hsp_array
Array of pointers to individual HSPs.
double best_evalue
Smallest e-value for HSPs in this list.
Int4 query_index
Index of the query which this HSPList corresponds to.
A wrap of data structure used to create a pipe.
ADT definition of BlastHSPPipe.
void * data
data structure
BlastHSPPipe * next
the next pipe in chain
BlastHSPPipeRunFn RunFnPtr
BlastHSPPipeFreeFn FreeFnPtr
The structure to contain all BLAST results, for multiple queries.
structure used to hold a collection of hits retrieved from the HSPStream
Int4 num_hsplists
number of lists of HSPs returned
BlastHSPList ** hsplist_array
array of HSP lists returned
Default implementation of BlastHSPStream.
BlastHSPWriter * writer
writer to be applied when writing
Int4 num_hsplists_alloc
number of entries in sorted_hsplists
Boolean writer_finalized
Is writer ever finalized?
Int4 num_hsplists
number of HSPlists saved
BlastHSPList ** sorted_hsplists
list of all HSPlists from 'results' combined, sorted in order of decreasing subject OID
BlastHSPResults * results
Structure for saving HSP lists.
EBlastProgramType program
BLAST program type.
Boolean results_sorted
Have the results already been sorted? Set to true after the first read call.
MT_LOCK x_lock
Mutex for writing and reading results.
BlastHSPPipe * tback_pipe
registered traceback pipeline
Boolean writer_initialized
Is writer already initialized?
SSortByScoreStruct * sort_by_score
BlastHSPPipe * pre_pipe
registered preliminary pipeline (unused for now)
A wrap of data structure used to create a writer.
ADT definition of BlastHSPWriter.
void * data
data structure
BlastHSPWriterFinalFn FinalFnPtr
BlastHSPWriterFreeFn FreeFnPtr
BlastHSPWriterRunFn RunFnPtr
BlastHSPWriterInitFn InitFnPtr
Structure holding all information about an HSP.
BlastSeg query
Query sequence info.
Int4 context
Context number of query.
BlastSeg subject
Subject sequence info.
Int4 score
This HSP's raw score.
The structure to contain all BLAST results for one query sequence.
BlastHSPList ** hsplist_array
Array of HSP lists for individual database hits.
Int4 hsplist_count
Filled size of the HSP lists array.
Structure that contains BLAST mapping results.
The query related information.
Int4 gapped_start
Where the gapped extension started.
Int2 frame
Translation frame.
Int4 offset
Start of hsp.
Auxiliary structure to allow sorting the results by score for the composition-based statistics code.
Int4 first_query_index
Index of the first query to try getting results from.
Boolean sort_on_read
Should the results be sorted on the first read call?
Structure to keep track of which query sequences are allocated to each query chunk.
voidp calloc(uInt items, uInt size)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4