NCBI C++ ToolKit
blast_seqsrc.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: blast_seqsrc.c 89480 2020-04-02 12:32:43Z fongah2 $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Christiam Camacho
27  *
28  *
29  */
30 
31 /** @file blast_seqsrc.c
32  * Definition of ADT to retrieve sequences for the BLAST engine and
33  * low level details of the implementation of the BlastSeqSrc framework.
34  */
35 
38 
39 /** Complete type definition of Blast Sequence Source ADT.
40  * The members of this structure should only be accessed by BlastSeqSrc
41  * implementations using the _BlastSeqSrcImpl_* functions.
42  */
43 struct BlastSeqSrc {
44 
45  BlastSeqSrcConstructor NewFnPtr; /**< Constructor */
46  BlastSeqSrcDestructor DeleteFnPtr; /**< Destructor */
47  BlastSeqSrcCopier CopyFnPtr; /**< Copier */
48 
49  /* Functions to set the number of threads in MT mode */
50  SetInt4FnPtr SetNumberOfThreads; /**< Set number of threads */
51 
52  /* Functions to get information about database as a whole */
53  GetInt4FnPtr GetNumSeqs; /**< Get number of sequences in set */
54  GetInt4FnPtr GetNumSeqsStats; /**< Number of sequences for statistical purposes. */
55  GetInt4FnPtr GetMaxSeqLen; /**< Get length of longest seq in set */
56  GetInt4FnPtr GetMinSeqLen; /**< Get length of longest seq in set */
57  GetInt4FnPtr GetAvgSeqLen; /**< Get average length of sequences in
58  the set */
59  GetInt8FnPtr GetTotLen; /**< Get tot length of all seqs in set */
60  GetInt8FnPtr GetTotLenStats; /**< Total length of all seqs for statistical purposes. */
61  GetStrFnPtr GetName; /**< Get the name of the database */
62  GetBoolFnPtr GetIsProt; /**< Find if database is a protein or
63  nucleotide */
64 
65  /* Functions that supports partial sequence fetching */
66  GetBoolFnPtr GetSupportsPartialFetching; /**< Find if database supports partial fetching */
67  SetSeqRangeFnPtr SetSeqRange; /**< Setting ranges for partial fetching */
68 
69  /* Functions that deal with individual sequences */
70  GetSeqBlkFnPtr GetSequence; /**< Retrieve individual sequence */
71  GetInt4FnPtr GetSeqLen; /**< Retrieve given sequence length */
72  ReleaseSeqBlkFnPtr ReleaseSequence; /**< Deallocate individual sequence
73  (if applicable) */
74 
75  /* Functions to iterate over sequences in the database */
76  AdvanceIteratorFnPtr IterNext; /**< Gets next oid from the iterator */
77 
78  ResetChunkIteratorFnPtr ResetChunkIterator; /**< Reset the implementation's
79  chunk "bookmark"
80  */
81 
82  void* DataStructure; /**< ADT holding the sequence data */
83 
84  char* InitErrorStr; /**< initialization error string */
85 #ifdef KAPPA_PRINT_DIAGNOSTICS
86  GetGisFnPtr GetGis; /**< Retrieve a sequence's gi(s) */
87 #endif /* KAPPA_PRINT_DIAGNOSTICS */
88 };
89 
91 {
92  BlastSeqSrc* retval = NULL;
93 
94  if (!bssn_info) {
95  return (BlastSeqSrc*) NULL;
96  }
97 
98  if ( !(retval = (BlastSeqSrc*) calloc(1, sizeof(BlastSeqSrc)))) {
99  return (BlastSeqSrc*) NULL;
100  }
101 
102  /* Save the constructor and invoke it */
103  if ((retval->NewFnPtr = bssn_info->constructor)) {
104  retval = (*retval->NewFnPtr)(retval, bssn_info->ctor_argument);
105  } else {
106  sfree(retval);
107  }
108 
109  return retval;
110 }
111 
113 {
114  BlastSeqSrcDestructor destructor_fnptr = NULL;
115  BlastSeqSrc* retval;
116 
117  if (!seq_src) {
118  return (BlastSeqSrc*) NULL;
119  }
120 
121  if (seq_src->InitErrorStr) {
122  sfree(seq_src->InitErrorStr);
123  }
124 
125  /* This could leave a memory leak if destructor function pointer is not
126  * initialized! It is the implementation's resposibility to provide this */
127  if ( !(destructor_fnptr = (*seq_src->DeleteFnPtr))) {
128  sfree(seq_src);
129  return (BlastSeqSrc*) NULL;
130  }
131 
132  retval = (BlastSeqSrc*) (*destructor_fnptr)(seq_src);
133  ASSERT(retval == NULL);
134  sfree(seq_src);
135  return retval;
136 }
137 
139 {
140  BlastSeqSrcCopier copy_fnptr = NULL;
141  BlastSeqSrc* retval = NULL;
142 
143  if (!seq_src) {
144  return (BlastSeqSrc*) NULL;
145  }
146 
147  if ( !(retval = (BlastSeqSrc*) BlastMemDup(seq_src, sizeof(BlastSeqSrc)))) {
148  return (BlastSeqSrc*) NULL;
149  }
150 
151  /* If copy function is not provided, just return a copy of the structure */
152  if ( !(copy_fnptr = (*seq_src->CopyFnPtr))) {
153  return retval;
154  }
155 
156  return (BlastSeqSrc*) (*copy_fnptr)(retval);
157 }
158 
160 {
161  if ( !seq_src || !seq_src->InitErrorStr ) {
162  return NULL;
163  }
164 
165  return strdup(seq_src->InitErrorStr);
166 }
167 
168 void BlastSeqSrcSetNumberOfThreads(BlastSeqSrc* seq_src, int n_threads)
169 {
170  if (!seq_src || !seq_src->SetNumberOfThreads) {
171  return;
172  }
173  (*seq_src->SetNumberOfThreads)(seq_src->DataStructure, n_threads);
174 }
175 
176 Int4
178 {
179  ASSERT(seq_src);
180  ASSERT(seq_src->GetNumSeqs);
181  return (*seq_src->GetNumSeqs)(seq_src->DataStructure, NULL);
182 }
183 
184 Int4
186 {
187  ASSERT(seq_src);
188  ASSERT(seq_src->GetNumSeqsStats);
189  return (*seq_src->GetNumSeqsStats)(seq_src->DataStructure, NULL);
190 }
191 
192 Int4
194 {
195  ASSERT(seq_src);
196  ASSERT(seq_src->GetMaxSeqLen);
197  return (*seq_src->GetMaxSeqLen)(seq_src->DataStructure, NULL);
198 }
199 
200 Int4
202 {
203  ASSERT(seq_src);
204  /* TODO this function may not be available for all seq_src */
205  return (seq_src->GetMinSeqLen) ?
206  (*seq_src->GetMinSeqLen)(seq_src->DataStructure, NULL)
208 }
209 
210 Int4
212 {
213  ASSERT(seq_src);
214  ASSERT(seq_src->GetAvgSeqLen);
215  return (*seq_src->GetAvgSeqLen)(seq_src->DataStructure, NULL);
216 }
217 
218 Int8
220 {
221  ASSERT(seq_src);
222  ASSERT(seq_src->GetTotLen);
223  return (*seq_src->GetTotLen)(seq_src->DataStructure, NULL);
224 }
225 
226 Int8
228 {
229  ASSERT(seq_src);
230  ASSERT(seq_src->GetTotLenStats);
231  return (*seq_src->GetTotLenStats)(seq_src->DataStructure, NULL);
232 }
233 
234 const char*
236 {
237  ASSERT(seq_src);
238  ASSERT(seq_src->GetName);
239  return (*seq_src->GetName)(seq_src->DataStructure, NULL);
240 }
241 
242 Boolean
244 {
245  ASSERT(seq_src);
246  ASSERT(seq_src->GetIsProt);
247  return (*seq_src->GetIsProt)(seq_src->DataStructure, NULL);
248 }
249 
250 Boolean
252 {
253  ASSERT(seq_src);
254  if (seq_src->GetSupportsPartialFetching) {
255  return (*seq_src->GetSupportsPartialFetching)(seq_src->DataStructure, NULL);
256  }
257  return FALSE;
258 }
259 
260 void
263 {
264  ASSERT(seq_src);
265  if (seq_src->SetSeqRange) {
266  (*seq_src->SetSeqRange)(seq_src->DataStructure, arg);
267  }
268 }
269 
270 Int2
272  BlastSeqSrcGetSeqArg* getseq_arg)
273 {
274  ASSERT(seq_src);
275  ASSERT(seq_src->GetSequence);
276  ASSERT(getseq_arg);
277  return (*seq_src->GetSequence)(seq_src->DataStructure, getseq_arg);
278 }
279 
280 Int4
281 BlastSeqSrcGetSeqLen(const BlastSeqSrc* seq_src, void* oid)
282 {
283  ASSERT(seq_src);
284  ASSERT(seq_src->GetSeqLen);
285  return (*seq_src->GetSeqLen)(seq_src->DataStructure, oid);
286 }
287 
288 void
290  BlastSeqSrcGetSeqArg* getseq_arg)
291 {
292  ASSERT(seq_src);
293  ASSERT(seq_src->ReleaseSequence);
294  ASSERT(getseq_arg);
295  (*seq_src->ReleaseSequence)(seq_src->DataStructure, getseq_arg);
296 }
297 
298 #ifdef KAPPA_PRINT_DIAGNOSTICS
299 
300 static const size_t kInitialGiListSize = 10;
301 
302 Blast_GiList*
303 Blast_GiListNew(void)
304 {
305  return Blast_GiListNewEx(kInitialGiListSize);
306 }
307 
308 Blast_GiList*
309 Blast_GiListNewEx(size_t list_size)
310 {
311  Blast_GiList* retval = (Blast_GiList*) calloc(1, sizeof(Blast_GiList));
312  if ( !retval ) {
313  return NULL;
314  }
315 
316  retval->data = (Int4*) calloc(list_size, sizeof(Int4));
317  if ( !retval->data ) {
318  return Blast_GiListFree(retval);
319  }
320  retval->num_allocated = list_size;
321 
322  return retval;
323 }
324 
325 Blast_GiList*
326 Blast_GiListFree(Blast_GiList* gilist)
327 {
328  if ( !gilist ) {
329  return NULL;
330  }
331  if (gilist->data) {
332  sfree(gilist->data);
333  }
334  sfree(gilist);
335  return NULL;
336 }
337 
338 Int2
339 Blast_GiList_ReallocIfNecessary(Blast_GiList* gilist)
340 {
341  ASSERT(gilist);
342 
343  if (gilist->num_used+1 > gilist->num_allocated) {
344  /* we need more room for elements */
345  gilist->num_allocated *= 2;
346  gilist->data = (Int4*) realloc(gilist->data,
347  gilist->num_allocated * sizeof(Int4));
348  if ( !gilist->data ) {
349  return kOutOfMemory;
350  }
351  }
352  return 0;
353 }
354 
355 Int2
356 Blast_GiList_Append(Blast_GiList* gilist, Int4 gi)
357 {
358  Int2 retval = 0;
359  ASSERT(gilist);
360 
361  if ( (retval = Blast_GiList_ReallocIfNecessary(gilist)) != 0) {
362  return retval;
363  }
364  gilist->data[gilist->num_used++] = gi;
365  return retval;
366 }
367 
368 Blast_GiList*
369 BlastSeqSrcGetGis(const BlastSeqSrc* seq_src, void* oid)
370 {
371  ASSERT(seq_src);
372  ASSERT(seq_src->GetSeqLen);
373  return (*seq_src->GetGis)(seq_src->DataStructure, oid);
374 }
375 
376 #endif /* KAPPA_PRINT_DIAGNOSTICS */
377 
378 /******************** BlastSeqSrcIterator API *******************************/
379 
381 {
382  return BlastSeqSrcIteratorNewEx(0);
383 }
384 
385 const unsigned int kBlastSeqSrcDefaultChunkSize = 1024;
386 
388 {
389  BlastSeqSrcIterator* itr = NULL;
390 
391  if (chunk_sz == 0)
392  chunk_sz = kBlastSeqSrcDefaultChunkSize;
393 
394  itr = (BlastSeqSrcIterator*) calloc(1, sizeof(BlastSeqSrcIterator));
395  if (!itr) {
396  return NULL;
397  }
398 
399  /* Should employ lazy initialization? */
400  itr->oid_list = (int*)malloc(chunk_sz * sizeof(int));
401  if (!itr->oid_list) {
402  sfree(itr);
403  return NULL;
404  }
405 
406  itr->chunk_sz = chunk_sz;
407  itr->current_pos = UINT4_MAX; /* mark iterator as uninitialized */
408 
409  return itr;
410 }
411 
413 {
414  if (!itr) {
415  return NULL;
416  }
417  if (itr->oid_list) {
418  sfree(itr->oid_list);
419  }
420 
421  sfree(itr);
422  return NULL;
423 }
424 
426  BlastSeqSrcIterator* itr)
427 {
428  ASSERT(seq_src);
429  ASSERT(itr);
430  ASSERT(seq_src->IterNext);
431 
432  return (*seq_src->IterNext)(seq_src->DataStructure, itr);
433 }
434 
435 void
437 {
438  ASSERT(seq_src);
439  ASSERT(seq_src->ResetChunkIterator);
440  (*seq_src->ResetChunkIterator)(seq_src->DataStructure);
441 }
442 
445 {
448  retv->capacity = num_ranges;
449  retv->num_ranges = 0;
450  retv->ranges = (Int4 *) malloc(2*num_ranges*sizeof(Int4));
451  return retv;
452 }
453 
456 {
457  if (arg) {
458  if (arg->ranges) {
459  sfree(arg->ranges);
460  }
461  sfree(arg);
462  }
463  return NULL;
464 }
465 
466 Int2
468  Int4 begin, Int4 end, Int4 len)
469 {
470  ASSERT(arg);
471  if ((arg->num_ranges+2) > arg->capacity) {
472  Int4 new_size = arg->capacity*2;
473  arg->ranges = (Int4*)realloc((void*)arg->ranges,
474  (sizeof(Int4)*new_size*2));
475  if (!arg->ranges) {
476  return 1;
477  }
478  arg->capacity = new_size;
479  }
480  begin = MAX(0, begin - BLAST_SEQSRC_OVERHANG);
481  end = MIN(end + BLAST_SEQSRC_OVERHANG, len);
482  arg->ranges[arg->num_ranges++] = begin;
483  arg->ranges[arg->num_ranges++] = end;
484  return 0;
485 }
486 
487 static int
488 BeginCompareHSPs(const void* x, const void* y)
489 {
490  Int4 *r1 = (Int4 *)x;
491  Int4 *r2 = (Int4 *)y;
492  return (*r1)-(*r2);
493 }
494 
495 void
497 {
498  Int4 i, j;
499  ASSERT(arg);
500  arg->num_ranges /= 2;
501  if (arg->num_ranges <= 1) return;
502  qsort(arg->ranges, arg->num_ranges, 2*sizeof(Int4), BeginCompareHSPs);
503  i=0;
504  for (j=1; j<arg->num_ranges; ++j) {
505  Int4 begin = arg->ranges[j*2];
506  Int4 end = arg->ranges[j*2+1];
507  ASSERT(begin >= arg->ranges[2*i]);
508  if (begin > arg->ranges[2*i+1] + BLAST_SEQSRC_MINGAP) {
509  /* insert as a new range */
510  ++i;
511  arg->ranges[i*2] = begin;
512  arg->ranges[i*2+1] = end;
513  } else if (end > arg->ranges[2*i+1]) {
514  /* merge into the previous range */
515  arg->ranges[i*2+1] = end;
516  }
517  }
518  arg->num_ranges = i+1;
519 }
520 
521 /*****************************************************************************/
522 
523 /* The following macros implement the "member functions" of the BlastSeqSrc
524  * structure so that its various fields can be accessed by the implementors of
525  * the BlastSeqSrc interface */
526 
527 #ifndef SKIP_DOXYGEN_PROCESSING
528 
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)
532 
533 #define DEFINE_BLAST_SEQ_SRC_ACCESSOR(member_type, member) \
534 member_type \
535 _BlastSeqSrcImpl_Get##member(const BlastSeqSrc* var) \
536 { \
537  if (var) \
538  return var->member; \
539  else \
540  return (member_type) NULL; \
541 }
542 
543 #define DEFINE_BLAST_SEQ_SRC_MUTATOR(member_type, member) \
544 void \
545 _BlastSeqSrcImpl_Set##member(BlastSeqSrc* var, member_type arg) \
546 { if (var) var->member = arg; }
547 
548 #endif
549 
550 /* Note there's no ; after these macros! */
554 
565 
568 
571 
575 
577 #ifdef KAPPA_PRINT_DIAGNOSTICS
578 DEFINE_BLAST_SEQ_SRC_MEMBER_FUNCTIONS(GetGisFnPtr, GetGis)
579 #endif /* KAPPA_PRINT_DIAGNOSTICS */
581  ResetChunkIterator)
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definition: blast_def.h:112
Int2 BlastSeqSrcSetRangesArgAddRange(BlastSeqSrcSetRangesArg *arg, Int4 begin, Int4 end, Int4 len)
add new range
Definition: blast_seqsrc.c:467
#define DEFINE_BLAST_SEQ_SRC_MEMBER_FUNCTIONS(member_type, member)
Definition: blast_seqsrc.c:529
Int4 BlastSeqSrcIteratorNext(const BlastSeqSrc *seq_src, BlastSeqSrcIterator *itr)
Increments the BlastSeqSrcIterator.
Definition: blast_seqsrc.c:425
Int8 BlastSeqSrcGetTotLenStats(const BlastSeqSrc *seq_src)
Get the total length of all sequences for calculation of expect value etc.
Definition: blast_seqsrc.c:227
BlastSeqSrcIterator * BlastSeqSrcIteratorFree(BlastSeqSrcIterator *itr)
Frees the BlastSeqSrcIterator structure.
Definition: blast_seqsrc.c:412
void BlastSeqSrcSetSeqRanges(const BlastSeqSrc *seq_src, BlastSeqSrcSetRangesArg *arg)
Setting the ranges for partial fetching.
Definition: blast_seqsrc.c:261
BlastSeqSrcIterator * BlastSeqSrcIteratorNewEx(unsigned int chunk_sz)
Allocate and initialize an iterator over a BlastSeqSrc.
Definition: blast_seqsrc.c:387
Int4 BlastSeqSrcGetSeqLen(const BlastSeqSrc *seq_src, void *oid)
Retrieve sequence length (number of residues/bases)
Definition: blast_seqsrc.c:281
Boolean BlastSeqSrcGetIsProt(const BlastSeqSrc *seq_src)
Find if the Blast Sequence Source contains protein or nucleotide sequences.
Definition: blast_seqsrc.c:243
BlastSeqSrc * BlastSeqSrcNew(const BlastSeqSrcNewInfo *bssn_info)
Allocates memory for a BlastSeqSrc structure and then invokes the constructor function defined in its...
Definition: blast_seqsrc.c:90
BlastSeqSrcIterator * BlastSeqSrcIteratorNew()
Allocate and initialize an iterator over a BlastSeqSrc with a default chunk size for MT-safe iteratio...
Definition: blast_seqsrc.c:380
void BlastSeqSrcSetRangesArgBuild(BlastSeqSrcSetRangesArg *arg)
build BlastSeqSrcSetRangesArg from range list
Definition: blast_seqsrc.c:496
void BlastSeqSrcReleaseSequence(const BlastSeqSrc *seq_src, BlastSeqSrcGetSeqArg *getseq_arg)
Deallocate individual sequence.
Definition: blast_seqsrc.c:289
BlastSeqSrc * BlastSeqSrcCopy(const BlastSeqSrc *seq_src)
Copy function: needed to guarantee thread safety.
Definition: blast_seqsrc.c:138
Int4 BlastSeqSrcGetAvgSeqLen(const BlastSeqSrc *seq_src)
Get the average length of all sequences in the sequence source.
Definition: blast_seqsrc.c:211
char * BlastSeqSrcGetInitError(const BlastSeqSrc *seq_src)
Function to retrieve NULL terminated string containing the description of an initialization error or ...
Definition: blast_seqsrc.c:159
void BlastSeqSrcSetNumberOfThreads(BlastSeqSrc *seq_src, int n_threads)
Set the number of threads for MT mode.
Definition: blast_seqsrc.c:168
Int4 BlastSeqSrcGetNumSeqs(const BlastSeqSrc *seq_src)
Get the number of sequences contained in the sequence source.
Definition: blast_seqsrc.c:177
Int8 BlastSeqSrcGetTotLen(const BlastSeqSrc *seq_src)
Get the total length of all sequences in the sequence source.
Definition: blast_seqsrc.c:219
BlastSeqSrc * BlastSeqSrcFree(BlastSeqSrc *seq_src)
Frees the BlastSeqSrc structure by invoking the destructor function set by the user-defined construct...
Definition: blast_seqsrc.c:112
Int4 BlastSeqSrcGetNumSeqsStats(const BlastSeqSrc *seq_src)
Get the number of sequences used for calculation of expect values etc.
Definition: blast_seqsrc.c:185
BlastSeqSrcSetRangesArg * BlastSeqSrcSetRangesArgNew(Int4 num_ranges)
new setrangearg
Definition: blast_seqsrc.c:444
const unsigned int kBlastSeqSrcDefaultChunkSize
How many database sequences to process in one database chunk.
Definition: blast_seqsrc.c:385
static int BeginCompareHSPs(const void *x, const void *y)
Definition: blast_seqsrc.c:488
Int4 BlastSeqSrcGetMaxSeqLen(const BlastSeqSrc *seq_src)
Get the length of the longest sequence in the sequence source.
Definition: blast_seqsrc.c:193
Boolean BlastSeqSrcGetSupportsPartialFetching(const BlastSeqSrc *seq_src)
Find if the Blast Sequence Source supports partial fetching.
Definition: blast_seqsrc.c:251
const char * BlastSeqSrcGetName(const BlastSeqSrc *seq_src)
Get the Blast Sequence source name (e.g.
Definition: blast_seqsrc.c:235
Int2 BlastSeqSrcGetSequence(const BlastSeqSrc *seq_src, BlastSeqSrcGetSeqArg *getseq_arg)
Retrieve an individual sequence.
Definition: blast_seqsrc.c:271
BlastSeqSrcSetRangesArg * BlastSeqSrcSetRangesArgFree(BlastSeqSrcSetRangesArg *arg)
free setrangearg
Definition: blast_seqsrc.c:455
Int4 BlastSeqSrcGetMinSeqLen(const BlastSeqSrc *seq_src)
Get the length of the longest sequence in the sequence source.
Definition: blast_seqsrc.c:201
void BlastSeqSrcResetChunkIterator(BlastSeqSrc *seq_src)
Reset the internal "bookmark" of the last chunk for iteration provided by this object.
Definition: blast_seqsrc.c:436
Declaration of ADT to retrieve sequences for the BLAST engine.
#define BLAST_SEQSRC_OVERHANG
Extension for each new range added.
Definition: blast_seqsrc.h:204
#define BLAST_SEQSRC_MINLENGTH
Default minimal sequence length.
Definition: blast_seqsrc.h:205
#define BLAST_SEQSRC_MINGAP
Minimal gap allowed in range list.
Definition: blast_seqsrc.h:203
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.
#define NULL
Definition: ncbistd.hpp:225
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
int i
int len
#define strdup
Definition: ncbi_ansi_ext.h:70
#define MIN(a, b)
returns smaller of a and b.
Definition: ncbi_std.h:112
void * BlastMemDup(const void *orig, size_t size)
Copies memory using memcpy and malloc.
Definition: ncbi_std.c:35
Uint1 Boolean
bool replacment for C
Definition: ncbi_std.h:94
#define UINT4_MAX
largest number represented by unsigned int.
Definition: ncbi_std.h:136
#define ASSERT
macro for assert.
Definition: ncbi_std.h:107
#define MAX(a, b)
returns larger of a and b.
Definition: ncbi_std.h:117
static Int4 GetSeqLen(DataBlkPtr entry)
Definition: sp_ascii.cpp:4014
const Int2 kOutOfMemory
Failure due to out-of-memory condition.
Definition: split_query.c:38
Structure used as the second argument to functions satisfying the GetSeqBlkFnPtr signature,...
Definition: blast_seqsrc.h:257
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.
Definition: blast_seqsrc.h:208
Int4 capacity
initial allocation
Definition: blast_seqsrc.h:213
Int4 * ranges
Ranges in sorted order [in].
Definition: blast_seqsrc.h:219
Int4 num_ranges
Number of actual ranges contained.
Definition: blast_seqsrc.h:216
Complete type definition of Blast Sequence Source ADT.
Definition: blast_seqsrc.c:43
GetInt4FnPtr GetMaxSeqLen
Get length of longest seq in set.
Definition: blast_seqsrc.c:55
GetInt4FnPtr GetSeqLen
Retrieve given sequence length.
Definition: blast_seqsrc.c:71
SetInt4FnPtr SetNumberOfThreads
Set number of threads.
Definition: blast_seqsrc.c:50
GetBoolFnPtr GetSupportsPartialFetching
Find if database supports partial fetching.
Definition: blast_seqsrc.c:66
SetSeqRangeFnPtr SetSeqRange
Setting ranges for partial fetching.
Definition: blast_seqsrc.c:67
GetInt4FnPtr GetNumSeqs
Get number of sequences in set.
Definition: blast_seqsrc.c:53
GetInt4FnPtr GetAvgSeqLen
Get average length of sequences in the set.
Definition: blast_seqsrc.c:57
GetInt4FnPtr GetNumSeqsStats
Number of sequences for statistical purposes.
Definition: blast_seqsrc.c:54
GetInt4FnPtr GetMinSeqLen
Get length of longest seq in set.
Definition: blast_seqsrc.c:56
GetSeqBlkFnPtr GetSequence
Retrieve individual sequence.
Definition: blast_seqsrc.c:70
GetInt8FnPtr GetTotLenStats
Total length of all seqs for statistical purposes.
Definition: blast_seqsrc.c:60
ResetChunkIteratorFnPtr ResetChunkIterator
Reset the implementation's chunk "bookmark".
Definition: blast_seqsrc.c:78
BlastSeqSrcConstructor NewFnPtr
Constructor.
Definition: blast_seqsrc.c:45
void * DataStructure
ADT holding the sequence data.
Definition: blast_seqsrc.c:82
ReleaseSeqBlkFnPtr ReleaseSequence
Deallocate individual sequence (if applicable)
Definition: blast_seqsrc.c:72
char * InitErrorStr
initialization error string
Definition: blast_seqsrc.c:84
GetBoolFnPtr GetIsProt
Find if database is a protein or nucleotide.
Definition: blast_seqsrc.c:62
BlastSeqSrcDestructor DeleteFnPtr
Destructor.
Definition: blast_seqsrc.c:46
BlastSeqSrcCopier CopyFnPtr
Copier.
Definition: blast_seqsrc.c:47
GetStrFnPtr GetName
Get the name of the database.
Definition: blast_seqsrc.c:61
AdvanceIteratorFnPtr IterNext
Gets next oid from the iterator.
Definition: blast_seqsrc.c:76
GetInt8FnPtr GetTotLen
Get tot length of all seqs in set.
Definition: blast_seqsrc.c:59
@ FALSE
Definition: testodbc.c:27
voidp malloc(uInt size)
voidp calloc(uInt items, uInt size)
Modified on Mon Feb 26 03:58:52 2024 by modify_doxy.py rev. 669887