NCBI C++ ToolKit
seqsrc_seqdb.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seqsrc_seqdb.cpp 95001 2021-09-27 15:55:19Z 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: Ilya Dondoshansky
27 *
28 */
29 
30 /// @file seqsrc_seqdb.cpp
31 /// Implementation of the BlastSeqSrc interface for a C++ BLAST databases API
32 
33 #include <ncbi_pch.hpp>
39 #include "blast_setup.hpp"
40 
41 /** @addtogroup AlgoBlast
42  *
43  * @{
44  */
45 
46 #ifndef SKIP_DOXYGEN_PROCESSING
49 USING_SCOPE(blast);
50 #endif /* SKIP_DOXYGEN_PROCESSING */
51 
52 /// Simple container to support SeqSrc-local data.
54  /// Constructor.
56  : copied(false)
57  {
58  }
59 
60  /// Constructor.
62  : seqdb((CSeqDBExpert*) ptr),
63  mask_algo_id(id),
64  mask_type(type),
65  copied(false),
67  {
68  }
69 
70  /// Make a copy of this object, sharing the same SeqDB object.
72  {
74  }
75 
76  /// Convenience to allow datap->method to use SeqDB methods.
78  {
79  _ASSERT(! seqdb.Empty());
80  return &*seqdb;
81  }
82 
83  /// Convenience to allow datap->method to use SeqDB methods.
85  {
86  _ASSERT(! seqdb.Empty());
87  return *seqdb;
88  }
89 
90  /// SeqDB object.
92 
93  /// Algorithm ID and type for mask data fetching.
96  bool copied;
97  bool isProtein;
98 
99 #if ((!defined(NCBI_COMPILER_WORKSHOP) || (NCBI_COMPILER_VERSION > 550)) && \
100  (!defined(NCBI_COMPILER_MIPSPRO)) )
101  /// Ranges of the sequence to include (for masking).
103 #endif
104 };
105 
107 
108 extern "C" {
109 
110 #ifdef KAPPA_PRINT_DIAGNOSTICS
111 
112 static Blast_GiList*
113 s_SeqDbGetGiList(void* seqdb_handle, void* args)
114 {
115  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
116 
117  Int4* oid = (Int4*) args;
118 
119  if (!datap || !oid)
120  return NULL;
121 
122  vector<TGi> gis;
123  datap->GetGis(*oid, gis);
124 
125  Blast_GiList* retval = Blast_GiListNewEx(gis.size());
126  copy(gis.begin(), gis.end(), retval->data);
127  retval->num_used = gis.size();
128 
129  return retval;
130 }
131 
132 #endif /* KAPPA_PRINT_DIAGNOSTICS */
133 
134 /// Retrieves the length of the longest sequence in the BlastSeqSrc.
135 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
136 static Int4
137 s_SeqDbGetMaxLength(void* seqdb_handle, void*)
138 {
139  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
140  return seqdb.GetMaxLength();
141 }
142 
143 /// Retrieves the length of the shortest sequence in the BlastSeqSrc.
144 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
145 static Int4
146 s_SeqDbGetMinLength(void* seqdb_handle, void*)
147 {
148  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
149  return seqdb.GetMinLength();
150 }
151 
152 /// Setting number of threads in MT mode
153 /// @param n_threads number of threads [in]
154 static void
155 s_SeqDbSetNumberOfThreads(void* seqdb_handle, int n)
156 {
157  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
158  seqdb.SetNumberOfThreads(n);
159 }
160 
161 /// Retrieves the number of sequences in the BlastSeqSrc.
162 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
163 static Int4
164 s_SeqDbGetNumSeqs(void* seqdb_handle, void*)
165 {
166  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
167  return seqdb.GetNumSeqs();
168 }
169 
170 /// Retrieves the number of sequences from alias file to be used for
171 // search-space calculations.
172 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
173 static Int4
174 s_SeqDbGetNumSeqsStats(void* seqdb_handle, void*)
175 {
176  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
177  return seqdb.GetNumSeqsStats();
178 }
179 
180 /// Retrieves the total length of all sequences in the BlastSeqSrc.
181 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
182 static Int8
183 s_SeqDbGetTotLen(void* seqdb_handle, void*)
184 {
185  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
186  return seqdb.GetTotalLength();
187 }
188 
189 /// Retrieves the total length of all sequences from alias file
190 // to be used for search space calculations.
191 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
192 static Int8
193 s_SeqDbGetTotLenStats(void* seqdb_handle, void*)
194 {
195  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
196  return seqdb.GetTotalLengthStats();
197 }
198 
199 /// Retrieves the average length of sequences in the BlastSeqSrc.
200 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
201 /// @param ignoreme Unused by this implementation [in]
202 static Int4
203 s_SeqDbGetAvgLength(void* seqdb_handle, void* ignoreme)
204 {
205  Int8 total_length = s_SeqDbGetTotLen(seqdb_handle, ignoreme);
206  Int4 num_seqs = MAX(1, s_SeqDbGetNumSeqs(seqdb_handle, ignoreme));
207 
208  return (Int4) (total_length/num_seqs);
209 }
210 
211 /// Retrieves the name of the BLAST database.
212 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
213 static const char*
214 s_SeqDbGetName(void* seqdb_handle, void*)
215 {
216  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
217  return seqdb.GetDBNameList().c_str();
218 }
219 
220 /// Checks whether database is protein or nucleotide.
221 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
222 /// @return TRUE if database is protein, FALSE if nucleotide.
223 static Boolean
224 s_SeqDbGetIsProt(void* seqdb_handle, void*)
225 {
226  TSeqDBData * datap = (TSeqDBData *) seqdb_handle;
227 
228  return datap->isProtein;
229 }
230 
231 /// Determine if partial fetching should be enabled
232 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
233 static Boolean
234 s_SeqDbGetSupportsPartialFetching(void* seqdb_handle, void*)
235 {
236  TSeqDBData * datap = (TSeqDBData *) seqdb_handle;
237 
238  if (datap->isProtein == true) {
239  // don't bother doing this for proteins as the sequences are
240  // never long enough to cause performance degredation
241  return false;
242  }
243 
244  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
245 
246  // If longest sequence is below this we quit
247  static const int kMaxLengthCutoff = 5000;
248  if (seqdb.GetMaxLength() < kMaxLengthCutoff) {
249  return false;
250  }
251 
252  // If average length is below this amount we quit
253  static const int kAvgLengthCutoff = 2048;
254  Int8 total_length = seqdb.GetTotalLength();
255  Int4 num_seqs = MAX(1, seqdb.GetNumSeqs());
256  if ((Int4)(total_length/num_seqs) < kAvgLengthCutoff) {
257  return false;
258  }
259 
260  return true;
261 }
262 
263 
264 /// Set sequence ranges for partial fetching
265 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
266 /// @param args Pointer to BlastSeqSrcSetRangesArg structure [in]
267 static void
268 s_SeqDbSetRanges(void* seqdb_handle, BlastSeqSrcSetRangesArg* args)
269 {
270  if (!seqdb_handle || !args) return;
271 
272  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
273 
274  CSeqDB::TRangeList ranges;
275  for (int i=0; i< args->num_ranges; ++i) {
276  ranges.insert(pair<int,int> (args->ranges[i*2], args->ranges[i*2+1]));
277  }
278 
279  seqdb.SetOffsetRanges(args->oid, ranges, false, false);
280 }
281 
282 /// Retrieves the sequence meeting the criteria defined by its second argument.
283 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
284 /// @param args Pointer to BlastSeqSrcGetSeqArg structure [in]
285 /// @return return codes defined in blast_seqsrc.h
286 static Int2
287 s_SeqDbGetSequence(void* seqdb_handle, BlastSeqSrcGetSeqArg* args)
288 {
289  Int4 oid = -1, len = 0;
290  Boolean has_sentinel_byte;
291 
292  if (!seqdb_handle || !args)
293  return BLAST_SEQSRC_ERROR;
294 
295  TSeqDBData * datap = (TSeqDBData *) seqdb_handle;
296 
297  CSeqDBExpert & seqdb = **datap;
298 
299  oid = args->oid;
300 
301  // If we are asked to check for OID exclusion, and if the database
302  // has a GI list, then we check whether all the seqids have been
303  // removed by filtering. If so we return an error. The traceback
304  // code will exclude this HSP list.
305 
306  if (args->check_oid_exclusion) {
307  if (! seqdb.GetIdSet().Blank()) {
308  list< CRef<CSeq_id> > seqids = seqdb.GetSeqIDs(oid);
309 
310  if (seqids.empty()) {
311  return BLAST_SEQSRC_EXCLUDED;
312  }
313  }
314  }
315 
316 #if ((!defined(NCBI_COMPILER_WORKSHOP) || (NCBI_COMPILER_VERSION > 550)) && \
317  (!defined(NCBI_COMPILER_MIPSPRO)) )
318  if (datap->mask_type != eNoSubjMasking) {
319  ASSERT(datap->mask_algo_id != -1);
320  seqdb.GetMaskData(oid, datap->mask_algo_id, datap->seq_ranges);
321  }
322 #endif
323 
324  datap->copied = false;
325 
326  if ( args->encoding == eBlastEncodingNucleotide
327  || args->encoding == eBlastEncodingNcbi4na
328  || (datap->mask_type == eHardSubjMasking
329  && !(datap->seq_ranges.empty())
330  && args->check_oid_exclusion)) datap->copied = true;
331 
332  has_sentinel_byte = (args->encoding == eBlastEncodingNucleotide);
333 
334  /* free buffers if necessary */
335  if (args->seq) BlastSequenceBlkClean(args->seq);
336 
337  /* This occurs if the pre-selected partial sequence in the traceback stage
338  * was too small to perform the traceback. Only do this for nucleotide
339  * sequences as proteins are not long enough to be of significance */
340  if (args->reset_ranges && datap->isProtein == false) {
342  }
343 
344  const char *buf;
345  len = 0;
346  if (datap->copied) {
347  if ( datap->isProtein || args->ranges == NULL){
348  len = seqdb.GetAmbigSeqAlloc(oid,
349  const_cast<char **>(&buf),
350  has_sentinel_byte,
351  eMalloc,
352  ((datap->mask_type == eHardSubjMasking) ?
353  &(datap->seq_ranges) : NULL));
354 
355  }
356  else {
357  CSeqDB::TSequenceRanges partial_ranges;
358  for (int i=0; i< args->ranges->num_ranges; ++i) {
360  v.first = args->ranges->ranges[i*2];
361  v.second = args->ranges->ranges[i*2+1];
362  partial_ranges.push_back(v);
363  }
364  len = seqdb.GetAmbigPartialSeq(oid,
365  const_cast<char **>(&buf),
366  has_sentinel_byte,
367  eMalloc,
368  &partial_ranges,
369  ((datap->mask_type == eHardSubjMasking) ?
370  &(datap->seq_ranges) : NULL));
371 
372  }
373  }
374  else {
375  len = seqdb.GetSequence(oid, &buf);
376  }
377 
378  if (len <= 0) return BLAST_SEQSRC_ERROR;
379 
380  BlastSetUp_SeqBlkNew((Uint1*)buf, len, &args->seq, datap->copied);
381 
382  /* If there is no sentinel byte, and buffer is allocated, i.e. this is
383  the traceback stage of a translated search, set "sequence" to the same
384  position as "sequence_start". */
385  if (datap->copied && !has_sentinel_byte)
386  args->seq->sequence = args->seq->sequence_start;
387 
388  /* For preliminary stage, even though sequence buffer points to a memory
389  mapped location, we still need to call ReleaseSequence. This can only be
390  guaranteed by making the engine believe tat sequence is allocated.
391  */
392  if (!datap->copied) args->seq->sequence_allocated = TRUE;
393 
394  args->seq->oid = oid;
395 
396 #if ((!defined(NCBI_COMPILER_WORKSHOP) || (NCBI_COMPILER_VERSION > 550)) && \
397  (!defined(NCBI_COMPILER_MIPSPRO)) )
398  /* If masks have not been consumed (scanning phase), pass on to engine */
399  if (datap->mask_type != eNoSubjMasking) {
400  if (BlastSeqBlkSetSeqRanges(args->seq,
401  (SSeqRange*) datap->seq_ranges.get_data(),
402  datap->seq_ranges.size() + 1, false, datap->mask_type) != 0) {
403  return BLAST_SEQSRC_ERROR;
404  }
405  }
406 #endif
407 
408  return BLAST_SEQSRC_SUCCESS;
409 }
410 
411 /// Returns the memory allocated for the sequence buffer to the CSeqDB
412 /// interface.
413 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
414 /// @param args Pointer to the BlastSeqSrcGetSeqArgs structure,
415 /// containing sequence block with the buffer that needs to be deallocated. [in]
416 static void
418 {
419  TSeqDBData * datap = (TSeqDBData *) seqdb_handle;
420 
421  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
422 
423  _ASSERT(seqdb_handle);
424  _ASSERT(args);
425  _ASSERT(args->seq);
426 
427  if (args->seq->sequence_start_allocated) {
428  if (datap->copied) sfree(args->seq->sequence_start);
430  args->seq->sequence_start = NULL;
431  }
432  if (args->seq->sequence_allocated) {
433  if (datap->copied) sfree(args->seq->sequence);
434  else seqdb.RetSequence((const char**)&args->seq->sequence);
435  args->seq->sequence_allocated = FALSE;
436  args->seq->sequence = NULL;
437  }
438 
439  if (args->ranges) {
441  }
442 }
443 
444 /// Retrieve length of a given database sequence.
445 /// @param seqdb_handle Pointer to initialized CSeqDB object [in]
446 /// @param args Pointer to integer indicating ordinal id [in]
447 /// @return Length of the database sequence or BLAST_SEQSRC_ERROR.
448 static Int4
449 s_SeqDbGetSeqLen(void* seqdb_handle, void* args)
450 {
451  Int4* oid = (Int4*) args;
452 
453  if (!seqdb_handle || !oid)
454  return BLAST_SEQSRC_ERROR;
455 
456  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
457  return seqdb.GetSeqLength(*oid);
458 }
459 
460 /// Assigns next chunk of the database to the sequence source iterator.
461 /// @param seqdb_handle Reference to the database object, cast to void* to
462 /// satisfy the signature requirement. [in]
463 /// @param itr Iterator over the database sequence source. [in|out]
464 static Int2
465 s_SeqDbGetNextChunk(void* seqdb_handle, BlastSeqSrcIterator* itr)
466 {
467  if (!seqdb_handle || !itr)
468  return BLAST_SEQSRC_ERROR;
469 
470  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
471 
472  vector<int> oid_list;
473 
474  CSeqDB::EOidListType chunk_type =
475  seqdb.GetNextOIDChunk(itr->oid_range[0], itr->oid_range[1],
476  itr->chunk_sz, oid_list);
477 
478  if (itr->oid_range[1] <= itr->oid_range[0])
479  return BLAST_SEQSRC_EOF;
480 
481  if (chunk_type == CSeqDB::eOidRange) {
482  itr->itr_type = eOidRange;
483  itr->current_pos = itr->oid_range[0];
484  } else if (chunk_type == CSeqDB::eOidList) {
485  Uint4 new_sz = (Uint4) oid_list.size();
486  itr->itr_type = eOidList;
487  if (new_sz > 0) {
488  itr->current_pos = 0;
489  Uint4 index;
490  if (itr->chunk_sz < new_sz) {
491  sfree(itr->oid_list);
492  itr->oid_list = (int *) malloc (new_sz * sizeof(int));
493  }
494  itr->chunk_sz = new_sz;
495  for (index = 0; index < new_sz; ++index)
496  itr->oid_list[index] = oid_list[index];
497  } else {
498  return s_SeqDbGetNextChunk(seqdb_handle, itr);
499  }
500  }
501 
502  return BLAST_SEQSRC_SUCCESS;
503 }
504 
505 /// Finds the next not searched ordinal id in the iteration over BLAST database.
506 /// @param seqdb_handle Reference to the database object, cast to void* to
507 /// satisfy the signature requirement. [in]
508 /// @param itr Iterator of the BlastSeqSrc pointed by ptr. [in]
509 /// @return Next ordinal id.
510 static Int4
511 s_SeqDbIteratorNext(void* seqdb_handle, BlastSeqSrcIterator* itr)
512 {
513  Int4 retval = BLAST_SEQSRC_EOF;
514  Int4 status = BLAST_SEQSRC_SUCCESS;
515 
516  _ASSERT(seqdb_handle);
517  _ASSERT(itr);
518 
519  /* If internal iterator is uninitialized/invalid, retrieve the next chunk
520  from the BlastSeqSrc */
521  if (itr->current_pos == UINT4_MAX) {
522  status = s_SeqDbGetNextChunk(seqdb_handle, itr);
523  if (status == BLAST_SEQSRC_ERROR || status == BLAST_SEQSRC_EOF) {
524  return status;
525  }
526  }
527 
528  Uint4 last_pos = 0;
529 
530  if (itr->itr_type == eOidRange) {
531  retval = itr->current_pos;
532  last_pos = itr->oid_range[1];
533  } else if (itr->itr_type == eOidList) {
534  retval = itr->oid_list[itr->current_pos];
535  last_pos = itr->chunk_sz;
536  } else {
537  /* Unsupported/invalid iterator type! */
538  fprintf(stderr, "Invalid iterator type: %d\n", itr->itr_type);
539  abort();
540  }
541 
542  ++itr->current_pos;
543  if (itr->current_pos >= last_pos) {
544  itr->current_pos = UINT4_MAX; /* invalidate internal iteration */
545  }
546 
547  return retval;
548 }
549 
550 /// Resets CSeqDB's internal chunk bookmark
551 /// @param seqdb_handle Reference to the database object, cast to void* to
552 /// satisfy the signature requirement. [in]
553 static void
554 s_SeqDbResetChunkIterator(void* seqdb_handle)
555 {
556  _ASSERT(seqdb_handle);
557  CSeqDB & seqdb = **(TSeqDBData *) seqdb_handle;
559  seqdb.FlushOffsetRangeCache();
560 }
561 
562 }
563 
566 BEGIN_SCOPE(blast)
567 
568 /// Encapsulates the arguments needed to initialize CSeqDB.
570 public:
571  /// Constructor
572  CSeqDbSrcNewArgs(const string& db, bool is_prot,
573  Uint4 first_oid = 0, Uint4 final_oid = 0,
574  Int4 mask_algo_id = -1,
576  : m_DbName(db), m_IsProtein(is_prot),
577  m_FirstDbSeq(first_oid), m_FinalDbSeq(final_oid),
578  m_MaskAlgoId(mask_algo_id), m_MaskType(mask_type)
579  {}
580 
581  /// Getter functions for the private fields
582  const string GetDbName() const { return m_DbName; }
583  /// Returns database type: protein or nucleotide
584  char GetDbType() const { return m_IsProtein ? 'p' : 'n'; }
585  /// Returns first database ordinal id covered by this BlastSeqSrc
586  Uint4 GetFirstOid() const { return m_FirstDbSeq; }
587  /// Returns last database ordinal id covered by this BlastSeqSrc
588  Uint4 GetFinalOid() const { return m_FinalDbSeq; }
589  /// Returns the default filtering algorithm to use with sequence data
590  /// extracted from this BlastSeqSrc
591  Int4 GetMaskAlgoId() const { return m_MaskAlgoId; }
592  ESubjectMaskingType GetMaskType() const { return m_MaskType; }
593 
594 private:
595  string m_DbName; ///< Database name
596  bool m_IsProtein; ///< Is this database protein?
597  Uint4 m_FirstDbSeq; ///< Ordinal id of the first sequence to search
598  Uint4 m_FinalDbSeq; ///< Ordinal id of the last sequence to search
599  /// filtering algorithm ID to use when retrieving sequence data
602 };
603 
604 extern "C" {
605 
606 /// SeqDb sequence source destructor: frees its internal data structure
607 /// @param seq_src BlastSeqSrc structure to free [in]
608 /// @return NULL
609 static BlastSeqSrc*
611 {
612  if (!seq_src)
613  return NULL;
614 
615  TSeqDBData * datap = static_cast<TSeqDBData*>
617 
618  delete datap;
619  return NULL;
620 }
621 
622 /// SeqDb sequence source copier: creates a new reference to the CSeqDB object
623 /// and copies the rest of the BlastSeqSrc structure.
624 /// @param seq_src BlastSeqSrc structure to copy [in]
625 /// @return Pointer to the new BlastSeqSrc.
626 static BlastSeqSrc*
628 {
629  if (!seq_src)
630  return NULL;
631 
632  TSeqDBData * datap = static_cast<TSeqDBData*>
634 
635  _BlastSeqSrcImpl_SetDataStructure(seq_src, (void*) datap->clone());
636 
637  return seq_src;
638 }
639 
640 /// Initializes the data structure and function pointers in a SeqDb based
641 /// BlastSeqSrc.
642 /// @param retval Structure to populate [in] [out]
643 /// @param seqdb Reference to a CSeqDB object [in]
644 static void
646 {
647  _ASSERT(retval);
648  _ASSERT(datap);
649 
650  /* Initialize the BlastSeqSrc structure fields with user-defined function
651  * pointers and seqdb */
654  _BlastSeqSrcImpl_SetDataStructure (retval, (void*) datap);
672 #ifdef KAPPA_PRINT_DIAGNOSTICS
673  _BlastSeqSrcImpl_SetGetGis (retval, & s_SeqDbGetGiList);
674 #endif /* KAPPA_PRINT_DIAGNOSTICS */
675 }
676 
677 /// Populates a BlastSeqSrc, creating a new reference to the already existing
678 /// SeqDb object.
679 /// @param retval Original BlastSeqSrc [in]
680 /// @param args Pointer to a reference to CSeqDB object [in]
681 /// @return retval
682 static BlastSeqSrc*
683 s_SeqDbSrcSharedNew(BlastSeqSrc* retval, void* args)
684 {
685  _ASSERT(retval);
686  _ASSERT(args);
687 
688  TSeqDBData * datap = (TSeqDBData *) args;
689 
690  s_InitNewSeqDbSrc(retval, datap->clone());
691 
692  return retval;
693 }
694 
695 /// SeqDb sequence source constructor
696 /// @param retval BlastSeqSrc structure (already allocated) to populate [in]
697 /// @param args Pointer to internal CSeqDbSrcNewArgs structure (@sa
698 /// CSeqDbSrcNewArgs) [in]
699 /// @return Updated seq_src structure (with all function pointers initialized
700 static BlastSeqSrc*
701 s_SeqDbSrcNew(BlastSeqSrc* retval, void* args)
702 {
703  _ASSERT(retval);
704  _ASSERT(args);
705 
706  CSeqDbSrcNewArgs* seqdb_args = (CSeqDbSrcNewArgs*) args;
707  _ASSERT(seqdb_args);
708 
709  TSeqDBData * datap = new TSeqDBData;
710 
711  try {
712  bool is_protein = (seqdb_args->GetDbType() == 'p');
713 
714  datap->seqdb.Reset(new CSeqDBExpert(seqdb_args->GetDbName(),
715  (is_protein
717  : CSeqDB::eNucleotide)));
718 
719  datap->seqdb->SetIterationRange(seqdb_args->GetFirstOid(),
720  seqdb_args->GetFinalOid());
721 
722  datap->mask_algo_id = seqdb_args->GetMaskAlgoId();
723  datap->mask_type = seqdb_args->GetMaskType();
724  datap->isProtein = is_protein;
725 
726  // Validate that the masking algorithm is supported
727  if (datap->mask_algo_id > 0) {
728  vector<int> supported_algorithms;
729  datap->seqdb->GetAvailableMaskAlgorithms(supported_algorithms);
730  if (find(supported_algorithms.begin(),
731  supported_algorithms.end(),
732  datap->mask_algo_id) == supported_algorithms.end()) {
733  CNcbiOstrstream oss;
734  oss << "Masking algorithm ID " << datap->mask_algo_id << " is "
735  << "not supported in " <<
736  (is_protein ? "protein" : "nucleotide") << " '"
737  << seqdb_args->GetDbName() << "' BLAST database";
738  string msg = CNcbiOstrstreamToString(oss);
739  throw runtime_error(msg);
740  }
741  }
742 
743  } catch (const ncbi::CException& e) {
745  strdup(e.ReportThis(eDPF_ErrCodeExplanation).c_str()));
746  } catch (const std::exception& e) {
747  _BlastSeqSrcImpl_SetInitErrorStr(retval, strdup(e.what()));
748  } catch (...) {
750  strdup("Caught unknown exception from CSeqDB constructor"));
751  }
752 
753  /* Initialize the BlastSeqSrc structure fields with user-defined function
754  * pointers and seqdb */
755 
756  s_InitNewSeqDbSrc(retval, datap);
757 
758  return retval;
759 }
760 
761 }
762 
764 SeqDbBlastSeqSrcInit(const string& dbname, bool is_prot,
765  Uint4 first_seq, Uint4 last_seq,
766  Int4 mask_algo_id, ESubjectMaskingType mask_type)
767 {
768  BlastSeqSrcNewInfo bssn_info;
769  BlastSeqSrc* seq_src = NULL;
770  CSeqDbSrcNewArgs seqdb_args(dbname, is_prot, first_seq, last_seq,
771  mask_algo_id, mask_type);
772 
773  bssn_info.constructor = &s_SeqDbSrcNew; // FIXME: shouldn't this be s_SeqDbSrcSharedNew?
774  bssn_info.ctor_argument = (void*) &seqdb_args;
775  seq_src = BlastSeqSrcNew(&bssn_info);
776  return seq_src;
777 }
778 
781  Int4 mask_algo_id,
782  ESubjectMaskingType mask_type)
783 {
784  BlastSeqSrcNewInfo bssn_info;
785  BlastSeqSrc * seq_src = NULL;
786 
787  TSeqDBData data(seqdb, mask_algo_id, mask_type);
788 
789  bssn_info.constructor = & s_SeqDbSrcSharedNew;
790  bssn_info.ctor_argument = (void*) & data;
791  seq_src = BlastSeqSrcNew(& bssn_info);
792  return seq_src;
793 }
794 
795 
796 END_SCOPE(blast)
798 
799 /* @} */
ESubjectMaskingType
Define the possible subject masking types.
Definition: blast_def.h:235
@ eHardSubjMasking
Definition: blast_def.h:238
@ eNoSubjMasking
Definition: blast_def.h:236
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definition: blast_def.h:112
#define BLAST_SEQSRC_ERROR
Error while retrieving sequence.
Definition: blast_seqsrc.h:291
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
#define BLAST_SEQSRC_SUCCESS
Successful sequence retrieval.
Definition: blast_seqsrc.h:293
#define BLAST_SEQSRC_EXCLUDED
Sequence excluded due to filtering.
Definition: blast_seqsrc.h:290
BlastSeqSrcSetRangesArg * BlastSeqSrcSetRangesArgFree(BlastSeqSrcSetRangesArg *arg)
free setrangearg
Definition: blast_seqsrc.c:455
#define BLAST_SEQSRC_EOF
No more sequences available.
Definition: blast_seqsrc.h:292
Definitions needed for implementing the BlastSeqSrc interface and low level details of the implementa...
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetReleaseSequence(BlastSeqSrc *var, ReleaseSeqBlkFnPtr arg)
Definition: blast_seqsrc.c:574
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetResetChunkIterator(BlastSeqSrc *var, ResetChunkIteratorFnPtr arg)
Definition: blast_seqsrc.c:581
NCBI_XBLAST_EXPORT void * _BlastSeqSrcImpl_GetDataStructure(const BlastSeqSrc *var)
Definition: blast_seqsrc.c:555
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetTotLenStats(BlastSeqSrc *var, GetInt8FnPtr arg)
Definition: blast_seqsrc.c:564
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetSequence(BlastSeqSrc *var, GetSeqBlkFnPtr arg)
Definition: blast_seqsrc.c:572
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetNumSeqsStats(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:559
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetTotLen(BlastSeqSrc *var, GetInt8FnPtr arg)
Definition: blast_seqsrc.c:563
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetSeqLen(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:573
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetIsProt(BlastSeqSrc *var, GetBoolFnPtr arg)
Definition: blast_seqsrc.c:567
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetDataStructure(BlastSeqSrc *var, void *arg)
Definition: blast_seqsrc.c:555
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetCopyFnPtr(BlastSeqSrc *var, BlastSeqSrcCopier arg)
Definition: blast_seqsrc.c:553
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetAvgSeqLen(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:562
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetIterNext(BlastSeqSrc *var, AdvanceIteratorFnPtr arg)
Definition: blast_seqsrc.c:576
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetMinSeqLen(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:561
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetInitErrorStr(BlastSeqSrc *var, char *arg)
Definition: blast_seqsrc.c:556
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetSetNumberOfThreads(BlastSeqSrc *var, SetInt4FnPtr arg)
Definition: blast_seqsrc.c:557
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetDeleteFnPtr(BlastSeqSrc *var, BlastSeqSrcDestructor arg)
Definition: blast_seqsrc.c:552
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetName(BlastSeqSrc *var, GetStrFnPtr arg)
Definition: blast_seqsrc.c:566
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetMaxSeqLen(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:560
@ eOidRange
Data is a range of contiguous ordinal ids (indices)
@ eOidList
Data is a list of discontiguous ordinal ids (indices)
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetNumSeqs(BlastSeqSrc *var, GetInt4FnPtr arg)
Definition: blast_seqsrc.c:558
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetSetSeqRange(BlastSeqSrc *var, SetSeqRangeFnPtr arg)
Definition: blast_seqsrc.c:570
NCBI_XBLAST_EXPORT void _BlastSeqSrcImpl_SetGetSupportsPartialFetching(BlastSeqSrc *var, GetBoolFnPtr arg)
Definition: blast_seqsrc.c:569
Internal auxiliary setup classes/functions for C++ BLAST APIs.
Various auxiliary BLAST utility functions.
Int2 BlastSeqBlkSetSeqRanges(BLAST_SequenceBlk *seq_blk, SSeqRange *seq_ranges, Uint4 num_seq_ranges, Boolean copy_seq_ranges, ESubjectMaskingType mask_type)
Sets the seq_range and related fields appropriately in the BLAST_SequenceBlk structure.
Definition: blast_util.c:182
Int2 BlastSetUp_SeqBlkNew(const Uint1 *buffer, Int4 length, BLAST_SequenceBlk **seq_blk, Boolean buffer_allocated)
Allocates memory for *sequence_blk and then populates it.
Definition: blast_util.c:101
void BlastSequenceBlkClean(BLAST_SequenceBlk *seq_blk)
Deallocate memory only for the sequence in the sequence block.
Definition: blast_util.c:220
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CSeqDBExpert.
Definition: seqdbexpert.hpp:55
bool Blank() const
Check if an ID list is blank.
CSeqDB.
Definition: seqdb.hpp:161
int GetMinLength() const
Returns the length of the shortest sequence in the database.
Definition: seqdb.cpp:710
Uint8 GetTotalLength() const
Returns the sum of the lengths of all available sequences.
Definition: seqdb.cpp:685
void SetIterationRange(int oid_begin, int oid_end)
Set Iteration Range.
Definition: seqdb.cpp:1093
void GetAvailableMaskAlgorithms(vector< int > &algorithms)
Get a list of algorithm IDs for which mask data exists.
Definition: seqdb.cpp:1227
const string & GetDBNameList() const
Get list of database names.
Definition: seqdb.cpp:760
list< CRef< CSeq_id > > GetSeqIDs(int oid) const
Gets a list of sequence identifiers.
Definition: seqdb.cpp:765
void ResetInternalChunkBookmark()
Resets this object's internal chunk bookmark, which is used when the oid_state argument to GetNextOID...
Definition: seqdb.cpp:755
EOidListType
Indicates how block of OIDs was returned.
Definition: seqdb.hpp:167
@ eOidRange
Definition: seqdb.hpp:169
@ eOidList
Definition: seqdb.hpp:168
int GetMaxLength() const
Returns the length of the largest sequence in the database.
Definition: seqdb.cpp:705
int GetSeqLength(int oid) const
Returns the sequence length in base pairs or residues.
Definition: seqdb.cpp:400
@ eNucleotide
Definition: seqdb.hpp:175
@ eProtein
Definition: seqdb.hpp:174
void SetOffsetRanges(int oid, const TRangeList &offset_ranges, bool append_ranges, bool cache_data)
Apply a range of offsets to a database sequence.
Definition: seqdb.cpp:1295
int GetAmbigPartialSeq(int oid, char **buffer, int nucl_code, ESeqDBAllocType strategy, TSequenceRanges *partial_ranges, TSequenceRanges *masks=NULL) const
Definition: seqdb.cpp:612
void RetSequence(const char **buffer) const
Returns any resources associated with the sequence.
Definition: seqdb.cpp:523
int GetNumSeqs() const
Returns the number of sequences available.
Definition: seqdb.cpp:670
EOidListType GetNextOIDChunk(int &begin_chunk, int &end_chunk, int oid_size, vector< int > &oid_list, int *oid_state=NULL)
Return a chunk of OIDs, and update the OID bookmark.
Definition: seqdb.cpp:739
int GetSequence(int oid, const char **buffer) const
Get a pointer to raw sequence data.
Definition: seqdb.cpp:530
int GetNumSeqsStats() const
Returns the number of sequences available.
Definition: seqdb.cpp:675
int GetAmbigSeqAlloc(int oid, char **buffer, int nucl_code, ESeqDBAllocType strategy, TSequenceRanges *masks=NULL) const
Get a pointer to sequence data with ambiguities.
Definition: seqdb.cpp:591
void SetNumberOfThreads(int num_threads, bool force_mt=false)
Setting the number of threads.
Definition: seqdb.cpp:1321
Uint8 GetTotalLengthStats() const
Returns the sum of the lengths of all available sequences.
Definition: seqdb.cpp:695
void GetMaskData(int oid, const vector< int > &algo_ids, TSequenceRanges &ranges)
Get masked ranges of a sequence.
Definition: seqdb.hpp:1408
CSeqDBIdSet GetIdSet() const
Get IdSet list attached to this database.
Definition: seqdb.cpp:1125
void FlushOffsetRangeCache()
Flush all offset ranges cached.
Definition: seqdb.cpp:1316
Encapsulates the arguments needed to initialize CSeqDB.
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
#define false
Definition: bool.h:36
char data[12]
Definition: iconv.c:80
static BlastSeqSrc * s_SeqDbSrcCopy(BlastSeqSrc *seq_src)
SeqDb sequence source copier: creates a new reference to the CSeqDB object and copies the rest of the...
bool m_IsProtein
Is this database protein?
CSeqDBExpert & operator*()
Convenience to allow datap->method to use SeqDB methods.
ESubjectMaskingType GetMaskType() const
ESubjectMaskingType m_MaskType
static Int4 s_SeqDbGetNumSeqs(void *seqdb_handle, void *)
Retrieves the number of sequences in the BlastSeqSrc.
CRef< CSeqDBExpert > seqdb
SeqDB object.
static Int4 s_SeqDbGetNumSeqsStats(void *seqdb_handle, void *)
Retrieves the number of sequences from alias file to be used for.
static Boolean s_SeqDbGetSupportsPartialFetching(void *seqdb_handle, void *)
Determine if partial fetching should be enabled.
BlastSeqSrc * SeqDbBlastSeqSrcInit(const string &dbname, bool is_prot, Uint4 first_seq=0, Uint4 last_seq=0, Int4 mask_algo_id=-1, ESubjectMaskingType mask_type=eNoSubjMasking)
Initialize the sequence source structure.
USING_SCOPE(blast)
CSeqDbSrcNewArgs(const string &db, bool is_prot, Uint4 first_oid=0, Uint4 final_oid=0, Int4 mask_algo_id=-1, ESubjectMaskingType mask_type=eNoSubjMasking)
Constructor.
static void s_InitNewSeqDbSrc(BlastSeqSrc *retval, TSeqDBData *datap)
Initializes the data structure and function pointers in a SeqDb based BlastSeqSrc.
CSeqDBExpert * operator->()
Convenience to allow datap->method to use SeqDB methods.
ESubjectMaskingType mask_type
int mask_algo_id
Algorithm ID and type for mask data fetching.
static void s_SeqDbResetChunkIterator(void *seqdb_handle)
Resets CSeqDB's internal chunk bookmark.
const string GetDbName() const
Getter functions for the private fields.
static void s_SeqDbSetNumberOfThreads(void *seqdb_handle, int n)
Setting number of threads in MT mode.
static Int4 s_SeqDbIteratorNext(void *seqdb_handle, BlastSeqSrcIterator *itr)
Finds the next not searched ordinal id in the iteration over BLAST database.
static Int4 s_SeqDbGetAvgLength(void *seqdb_handle, void *ignoreme)
Retrieves the average length of sequences in the BlastSeqSrc.
static const char * s_SeqDbGetName(void *seqdb_handle, void *)
Retrieves the name of the BLAST database.
CSeqDB::TSequenceRanges seq_ranges
Ranges of the sequence to include (for masking).
static BlastSeqSrc * s_SeqDbSrcNew(BlastSeqSrc *retval, void *args)
SeqDb sequence source constructor.
static BlastSeqSrc * s_SeqDbSrcFree(BlastSeqSrc *seq_src)
SeqDb sequence source destructor: frees its internal data structure.
SSeqDB_SeqSrc_Data(CSeqDB *ptr, int id, ESubjectMaskingType type)
Constructor.
static void s_SeqDbSetRanges(void *seqdb_handle, BlastSeqSrcSetRangesArg *args)
Set sequence ranges for partial fetching.
Uint4 m_FirstDbSeq
Ordinal id of the first sequence to search.
static Boolean s_SeqDbGetIsProt(void *seqdb_handle, void *)
Checks whether database is protein or nucleotide.
static Int4 s_SeqDbGetSeqLen(void *seqdb_handle, void *args)
Retrieve length of a given database sequence.
SSeqDB_SeqSrc_Data()
Constructor.
Uint4 GetFinalOid() const
Returns last database ordinal id covered by this BlastSeqSrc.
Uint4 GetFirstOid() const
Returns first database ordinal id covered by this BlastSeqSrc.
SSeqDB_SeqSrc_Data TSeqDBData
Int4 GetMaskAlgoId() const
Returns the default filtering algorithm to use with sequence data extracted from this BlastSeqSrc.
SSeqDB_SeqSrc_Data * clone()
Make a copy of this object, sharing the same SeqDB object.
static void s_SeqDbReleaseSequence(void *seqdb_handle, BlastSeqSrcGetSeqArg *args)
Returns the memory allocated for the sequence buffer to the CSeqDB interface.
static Int2 s_SeqDbGetNextChunk(void *seqdb_handle, BlastSeqSrcIterator *itr)
Assigns next chunk of the database to the sequence source iterator.
Int4 m_MaskAlgoId
filtering algorithm ID to use when retrieving sequence data
static Int4 s_SeqDbGetMinLength(void *seqdb_handle, void *)
Retrieves the length of the shortest sequence in the BlastSeqSrc.
USING_NCBI_SCOPE
string m_DbName
Database name.
static Int4 s_SeqDbGetMaxLength(void *seqdb_handle, void *)
Retrieves the length of the longest sequence in the BlastSeqSrc.
static Int8 s_SeqDbGetTotLen(void *seqdb_handle, void *)
Retrieves the total length of all sequences in the BlastSeqSrc.
char GetDbType() const
Returns database type: protein or nucleotide.
static Int2 s_SeqDbGetSequence(void *seqdb_handle, BlastSeqSrcGetSeqArg *args)
Retrieves the sequence meeting the criteria defined by its second argument.
Uint4 m_FinalDbSeq
Ordinal id of the last sequence to search.
static Int8 s_SeqDbGetTotLenStats(void *seqdb_handle, void *)
Retrieves the total length of all sequences from alias file.
static BlastSeqSrc * s_SeqDbSrcSharedNew(BlastSeqSrc *retval, void *args)
Populates a BlastSeqSrc, creating a new reference to the already existing SeqDb object.
@ eBlastEncodingNcbi4na
NCBI4na.
@ eBlastEncodingNucleotide
Special encoding for preliminary stage of BLAST: permutation of NCBI4na.
#define NULL
Definition: ncbistd.hpp:225
@ eDPF_ErrCodeExplanation
Error explanation (default)
Definition: ncbidiag.hpp:702
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
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
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
char * dbname(DBPROCESS *dbproc)
Get name of current database.
Definition: dblib.c:6929
char * buf
int i
yy_size_t n
int len
#define strdup
Definition: ncbi_ansi_ext.h:70
Uint1 Boolean
bool replacment for C
Definition: ncbi_std.h:94
#define TRUE
bool replacment for C indicating true.
Definition: ncbi_std.h:97
#define FALSE
bool replacment for C indicating false.
Definition: ncbi_std.h:101
#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
void abort()
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
@ eMalloc
Defines `expert' version of CSeqDB interfaces.
Implementation of the BlastSeqSrc interface using the C++ BLAST databases API.
Uint4 GetSequenceType(const CBioseq_Handle &bsh)
Return a (corrected) set of flags identifying the sequence type.
Definition: sequtils.cpp:42
Uint1 * sequence_start
Start of sequence, usually one byte before sequence as that byte is a NULL sentinel byte.
Definition: blast_def.h:244
Int4 oid
The ordinal id of the current sequence.
Definition: blast_def.h:250
Boolean sequence_allocated
TRUE if memory has been allocated for sequence.
Definition: blast_def.h:251
Uint1 * sequence
Sequence used for search (could be translation).
Definition: blast_def.h:243
Boolean sequence_start_allocated
TRUE if memory has been allocated for sequence_start.
Definition: blast_def.h:253
Structure used as the second argument to functions satisfying the GetSeqBlkFnPtr signature,...
Definition: blast_seqsrc.h:257
Int4 oid
Oid in BLAST database, index in an array of sequences, etc [in].
Definition: blast_seqsrc.h:259
Boolean reset_ranges
This option allows the BLAST engine to communicate with the BlastSeqSrc that the offset ranges for a ...
Definition: blast_seqsrc.h:273
EBlastEncoding encoding
Encoding of sequence, i.e.
Definition: blast_seqsrc.h:263
Boolean check_oid_exclusion
Check whether an OID is excluded due to overlapping filtering.
Definition: blast_seqsrc.h:279
BlastSeqSrcSetRangesArg * ranges
Definition: blast_seqsrc.h:286
BLAST_SequenceBlk * seq
Sequence to return, if NULL, it should allocated by GetSeqBlkFnPtr (using BlastSeqBlkNew or BlastSetU...
Definition: blast_seqsrc.h:284
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...
BlastSeqSrcItrType itr_type
Indicates which member to access: oid_list or oid_range.
int oid_range[2]
This is a half-closed interval [a,b)
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 * ranges
Ranges in sorted order [in].
Definition: blast_seqsrc.h:219
Int4 num_ranges
Number of actual ranges contained.
Definition: blast_seqsrc.h:216
Int4 oid
Oid in BLAST database, index in an array of sequences, etc [in].
Definition: blast_seqsrc.h:210
Complete type definition of Blast Sequence Source ADT.
Definition: blast_seqsrc.c:43
Structure to represent a range.
Definition: seqdb.hpp:225
List of sequence offset ranges.
Definition: seqdb.hpp:236
void push_back(const value_type &element)
Append extra element at the end.
Definition: seqdb.hpp:309
Simple container to support SeqSrc-local data.
A structure containing two integers, used e.g.
Definition: blast_def.h:155
Definition: type.c:6
#define _ASSERT
voidp malloc(uInt size)
Modified on Sat Apr 13 11:49:16 2024 by modify_doxy.py rev. 669887