85 #ifdef KAPPA_PRINT_DIAGNOSTICS
127 if ( !(destructor_fnptr = (*seq_src->
DeleteFnPtr))) {
132 retval = (
BlastSeqSrc*) (*destructor_fnptr)(seq_src);
152 if ( !(copy_fnptr = (*seq_src->
CopyFnPtr))) {
298 #ifdef KAPPA_PRINT_DIAGNOSTICS
300 static const size_t kInitialGiListSize = 10;
303 Blast_GiListNew(
void)
305 return Blast_GiListNewEx(kInitialGiListSize);
309 Blast_GiListNewEx(
size_t list_size)
311 Blast_GiList* retval = (Blast_GiList*)
calloc(1,
sizeof(Blast_GiList));
317 if ( !retval->data ) {
318 return Blast_GiListFree(retval);
320 retval->num_allocated = list_size;
326 Blast_GiListFree(Blast_GiList* gilist)
339 Blast_GiList_ReallocIfNecessary(Blast_GiList* gilist)
343 if (gilist->num_used+1 > gilist->num_allocated) {
345 gilist->num_allocated *= 2;
346 gilist->data = (
Int4*) realloc(gilist->data,
347 gilist->num_allocated *
sizeof(
Int4));
348 if ( !gilist->data ) {
356 Blast_GiList_Append(Blast_GiList* gilist,
Int4 gi)
361 if ( (retval = Blast_GiList_ReallocIfNecessary(gilist)) != 0) {
364 gilist->data[gilist->num_used++] = gi;
369 BlastSeqSrcGetGis(
const BlastSeqSrc* seq_src,
void* oid)
474 (
sizeof(
Int4)*new_size*2));
513 }
else if (end > arg->
ranges[2*
i+1]) {
527 #ifndef SKIP_DOXYGEN_PROCESSING
529 #define DEFINE_BLAST_SEQ_SRC_MEMBER_FUNCTIONS(member_type, member) \
530 DEFINE_BLAST_SEQ_SRC_ACCESSOR(member_type, member) \
531 DEFINE_BLAST_SEQ_SRC_MUTATOR(member_type, member)
533 #define DEFINE_BLAST_SEQ_SRC_ACCESSOR(member_type, member) \
535 _BlastSeqSrcImpl_Get##member(const BlastSeqSrc* var) \
538 return var->member; \
540 return (member_type) NULL; \
543 #define DEFINE_BLAST_SEQ_SRC_MUTATOR(member_type, member) \
545 _BlastSeqSrcImpl_Set##member(BlastSeqSrc* var, member_type arg) \
546 { if (var) var->member = arg; }
577 #ifdef KAPPA_PRINT_DIAGNOSTICS
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Int2 BlastSeqSrcSetRangesArgAddRange(BlastSeqSrcSetRangesArg *arg, Int4 begin, Int4 end, Int4 len)
add new range
#define DEFINE_BLAST_SEQ_SRC_MEMBER_FUNCTIONS(member_type, member)
Int4 BlastSeqSrcIteratorNext(const BlastSeqSrc *seq_src, BlastSeqSrcIterator *itr)
Increments the BlastSeqSrcIterator.
Int8 BlastSeqSrcGetTotLenStats(const BlastSeqSrc *seq_src)
Get the total length of all sequences for calculation of expect value etc.
BlastSeqSrcIterator * BlastSeqSrcIteratorFree(BlastSeqSrcIterator *itr)
Frees the BlastSeqSrcIterator structure.
void BlastSeqSrcSetSeqRanges(const BlastSeqSrc *seq_src, BlastSeqSrcSetRangesArg *arg)
Setting the ranges for partial fetching.
BlastSeqSrcIterator * BlastSeqSrcIteratorNewEx(unsigned int chunk_sz)
Allocate and initialize an iterator over a BlastSeqSrc.
Int4 BlastSeqSrcGetSeqLen(const BlastSeqSrc *seq_src, void *oid)
Retrieve sequence length (number of residues/bases)
Boolean BlastSeqSrcGetIsProt(const BlastSeqSrc *seq_src)
Find if the Blast Sequence Source contains protein or nucleotide sequences.
BlastSeqSrc * BlastSeqSrcNew(const BlastSeqSrcNewInfo *bssn_info)
Allocates memory for a BlastSeqSrc structure and then invokes the constructor function defined in its...
BlastSeqSrcIterator * BlastSeqSrcIteratorNew()
Allocate and initialize an iterator over a BlastSeqSrc with a default chunk size for MT-safe iteratio...
void BlastSeqSrcSetRangesArgBuild(BlastSeqSrcSetRangesArg *arg)
build BlastSeqSrcSetRangesArg from range list
void BlastSeqSrcReleaseSequence(const BlastSeqSrc *seq_src, BlastSeqSrcGetSeqArg *getseq_arg)
Deallocate individual sequence.
BlastSeqSrc * BlastSeqSrcCopy(const BlastSeqSrc *seq_src)
Copy function: needed to guarantee thread safety.
Int4 BlastSeqSrcGetAvgSeqLen(const BlastSeqSrc *seq_src)
Get the average length of all sequences in the sequence source.
char * BlastSeqSrcGetInitError(const BlastSeqSrc *seq_src)
Function to retrieve NULL terminated string containing the description of an initialization error or ...
void BlastSeqSrcSetNumberOfThreads(BlastSeqSrc *seq_src, int n_threads)
Set the number of threads for MT mode.
Int4 BlastSeqSrcGetNumSeqs(const BlastSeqSrc *seq_src)
Get the number of sequences contained in the sequence source.
Int8 BlastSeqSrcGetTotLen(const BlastSeqSrc *seq_src)
Get the total length of all sequences in the sequence source.
BlastSeqSrc * BlastSeqSrcFree(BlastSeqSrc *seq_src)
Frees the BlastSeqSrc structure by invoking the destructor function set by the user-defined construct...
Int4 BlastSeqSrcGetNumSeqsStats(const BlastSeqSrc *seq_src)
Get the number of sequences used for calculation of expect values etc.
BlastSeqSrcSetRangesArg * BlastSeqSrcSetRangesArgNew(Int4 num_ranges)
new setrangearg
const unsigned int kBlastSeqSrcDefaultChunkSize
How many database sequences to process in one database chunk.
static int BeginCompareHSPs(const void *x, const void *y)
Int4 BlastSeqSrcGetMaxSeqLen(const BlastSeqSrc *seq_src)
Get the length of the longest sequence in the sequence source.
Boolean BlastSeqSrcGetSupportsPartialFetching(const BlastSeqSrc *seq_src)
Find if the Blast Sequence Source supports partial fetching.
const char * BlastSeqSrcGetName(const BlastSeqSrc *seq_src)
Get the Blast Sequence source name (e.g.
Int2 BlastSeqSrcGetSequence(const BlastSeqSrc *seq_src, BlastSeqSrcGetSeqArg *getseq_arg)
Retrieve an individual sequence.
BlastSeqSrcSetRangesArg * BlastSeqSrcSetRangesArgFree(BlastSeqSrcSetRangesArg *arg)
free setrangearg
Int4 BlastSeqSrcGetMinSeqLen(const BlastSeqSrc *seq_src)
Get the length of the longest sequence in the sequence source.
void BlastSeqSrcResetChunkIterator(BlastSeqSrc *seq_src)
Reset the internal "bookmark" of the last chunk for iteration provided by this object.
Declaration of ADT to retrieve sequences for the BLAST engine.
#define BLAST_SEQSRC_OVERHANG
Extension for each new range added.
#define BLAST_SEQSRC_MINLENGTH
Default minimal sequence length.
#define BLAST_SEQSRC_MINGAP
Minimal gap allowed in range list.
Definitions needed for implementing the BlastSeqSrc interface and low level details of the implementa...
const char *(* GetStrFnPtr)(void *seqsrc_impl, void *arg)
Function pointer typedef to return a null terminated string, used to return the name of a BlastSeqSrc...
BlastSeqSrc *(* BlastSeqSrcDestructor)(BlastSeqSrc *seqrc)
Function pointer typedef to deallocate a BlastSeqSrc structure, always returns NULL.
void(* SetInt4FnPtr)(void *seqsrc_impl, int arg)
Function pointer typedef to set a 4-byte integer.
void(* ReleaseSeqBlkFnPtr)(void *seqsrc_impl, BlastSeqSrcGetSeqArg *arg)
Function pointer typedef to release sequences obtained from the data structure embedded in the BlastS...
BlastSeqSrc *(* BlastSeqSrcConstructor)(BlastSeqSrc *seqsrc, void *arg)
Function pointer typedef to create a new BlastSeqSrc structure.
Int8(* GetInt8FnPtr)(void *seqsrc_impl, void *arg)
Function pointer typedef to return a 8-byte integer.
Boolean(* GetBoolFnPtr)(void *seqsrc_impl, void *arg)
Function pointer typedef to return a boolean value, used to return whether a given BlastSeqSrc implem...
Int4(* GetInt4FnPtr)(void *seqsrc_impl, void *arg)
Function pointer typedef to return a 4-byte integer.
void(* SetSeqRangeFnPtr)(void *seqsrc_impl, BlastSeqSrcSetRangesArg *arg)
Function pointer typedef to set partial fetching range.
void(* ResetChunkIteratorFnPtr)(void *seqsrc_impl)
Function pointer typedef to reset the internal "bookmark" of the last chunk provided for iteration by...
BlastSeqSrc *(* BlastSeqSrcCopier)(BlastSeqSrc *)
Function pointer typedef to modify the contents of a BlastSeqSrc structure, copied by BlastSeqSrcCopy...
Int2(* GetSeqBlkFnPtr)(void *seqsrc_impl, BlastSeqSrcGetSeqArg *arg)
Function pointer typedef to retrieve sequences from data structure embedded in the BlastSeqSrc struct...
Int4(* AdvanceIteratorFnPtr)(void *seqsrc_impl, BlastSeqSrcIterator *itr)
Function pointer typedef to obtain the next ordinal id to fetch from the BlastSeqSrc structure.
SBlastSequence GetSequence(const objects::CSeq_loc &sl, EBlastEncoding encoding, objects::CScope *scope, objects::ENa_strand strand=objects::eNa_strand_plus, ESentinelType sentinel=eSentinels, std::string *warnings=NULL)
Retrieves a sequence using the object manager.
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
int64_t Int8
8-byte (64-bit) signed integer
#define MIN(a, b)
returns smaller of a and b.
void * BlastMemDup(const void *orig, size_t size)
Copies memory using memcpy and malloc.
Uint1 Boolean
bool replacment for C
#define FALSE
bool replacment for C indicating false.
#define UINT4_MAX
largest number represented by unsigned int.
#define ASSERT
macro for assert.
#define MAX(a, b)
returns larger of a and b.
static const sljit_gpr r1
static const sljit_gpr r2
static Int4 GetSeqLen(DataBlkPtr entry)
const Int2 kOutOfMemory
Failure due to out-of-memory condition.
Structure used as the second argument to functions satisfying the GetSeqBlkFnPtr signature,...
Complete type definition of Blast Sequence Source Iterator.
unsigned int chunk_sz
Size of the chunks to advance over the BlastSeqSrc, also size of oid_list member, this is provided to...
int * oid_list
Array of ordinal ids used when itr_type is eOidList.
unsigned int current_pos
Keep track of this iterator's current position, implementations use UINT4_MAX to indicate this is uni...
Complete type definition of the structure used to create a new BlastSeqSrc.
BlastSeqSrcConstructor constructor
User-defined function to initialize a BlastSeqSrc structure.
void * ctor_argument
Argument to the above function.
Structure used as the argument to function SetRanges.
Int4 capacity
initial allocation
Int4 * ranges
Ranges in sorted order [in].
Int4 num_ranges
Number of actual ranges contained.
Complete type definition of Blast Sequence Source ADT.
GetInt4FnPtr GetMaxSeqLen
Get length of longest seq in set.
GetInt4FnPtr GetSeqLen
Retrieve given sequence length.
SetInt4FnPtr SetNumberOfThreads
Set number of threads.
GetBoolFnPtr GetSupportsPartialFetching
Find if database supports partial fetching.
SetSeqRangeFnPtr SetSeqRange
Setting ranges for partial fetching.
GetInt4FnPtr GetNumSeqs
Get number of sequences in set.
GetInt4FnPtr GetAvgSeqLen
Get average length of sequences in the set.
GetInt4FnPtr GetNumSeqsStats
Number of sequences for statistical purposes.
GetInt4FnPtr GetMinSeqLen
Get length of longest seq in set.
GetSeqBlkFnPtr GetSequence
Retrieve individual sequence.
GetInt8FnPtr GetTotLenStats
Total length of all seqs for statistical purposes.
ResetChunkIteratorFnPtr ResetChunkIterator
Reset the implementation's chunk "bookmark".
BlastSeqSrcConstructor NewFnPtr
Constructor.
void * DataStructure
ADT holding the sequence data.
ReleaseSeqBlkFnPtr ReleaseSequence
Deallocate individual sequence (if applicable)
char * InitErrorStr
initialization error string
GetBoolFnPtr GetIsProt
Find if database is a protein or nucleotide.
BlastSeqSrcDestructor DeleteFnPtr
Destructor.
BlastSeqSrcCopier CopyFnPtr
Copier.
GetStrFnPtr GetName
Get the name of the database.
AdvanceIteratorFnPtr IterNext
Gets next oid from the iterator.
GetInt8FnPtr GetTotLen
Get tot length of all seqs in set.
voidp calloc(uInt items, uInt size)