kNumSeqs = 70;
70 const intkGiList[kNumSeqs] =
71{ 1786181, 1786192, 2367095, 1786217, 1786230, 1786240, 1786250,
721786262, 1786283, 1786298, 1786306, 1786315, 1786327, 1786339,
731786348, 1786358, 1786370, 1786383, 1786395, 1786402, 1786415,
742367098, 2367099, 1786454, 1786465, 2367103, 2367108, 1786501,
751786510, 1786520, 1786532, 1786542, 1786554, 1786568, 1786580,
761786596, 1786603, 1786614, 1786628, 1786639, 1786649, 1786660,
771786671, 1786683, 1786692, 1786705, 1786716, 1786728, 1786739,
781786751, 1786766, 1786782, 1786790, 1786800, 1786808, 1786819,
791786836, 1786849, 1786862, 1786875, 1786888, 1786896, 1786910,
801786920, 1786934, 1786947, 1786955, 1786967, 1786978, 1786988 };
85 for(index = 0; index < kNumSeqs; ++index) {
86sprintf(id_buffer,
"gi|%d", kGiList[index]);
88unique_ptr<SSeqLoc> sl(
91retval.push_back(*sl);
99 #ifdef KAPPA_PRINT_DIAGNOSTICS 102s_TestGetGis(
BlastSeqSrc* seqsrc,
constpair<string, bool>& dbinfo) {
103 const intgis[] = { 68737, 129295 };
105 CSeqDBseqdb(dbinfo.first, dbinfo.second
108seqdb.GiToOid(gis[0], oid);
109BOOST_REQUIRE(oid != -1);
111Blast_GiList* gilist = BlastSeqSrcGetGis(seqsrc, (
void*)&oid);
112 sort(&gilist->data[0], &gilist->data[gilist->num_used]);
113 for(
size_t i= 0;
i< gilist->num_used;
i++) {
114BOOST_REQUIRE_EQUAL(gilist->data[
i], gis[
i]);
116gilist = Blast_GiListFree(gilist);
117BOOST_REQUIRE(gilist ==
NULL);
121 constpair<string, bool> kDbInfo(
"nr",
true);
126BOOST_REQUIRE(error_str ==
NULL);
128s_TestGetGis(seq_src, kDbInfo);
134 constpair<string, bool> kDbInfo(
"nr",
true);
135 BlastSeqSrc* seq_src = ReaddbBlastSeqSrcInit(kDbInfo.first.c_str(),
136kDbInfo.second, 0, 0);
138BOOST_REQUIRE(error_str ==
NULL);
140s_TestGetGis(seq_src, kDbInfo);
154BOOST_REQUIRE(error_str !=
NULL);
160 const intkNumBytes = 4;
161 const intkSeqIndex = 40;
162 const Uint1kNcbi2naSeqBytes[kNumBytes] = { 48, 215, 159, 129 };
163 const Uint1kBlastnaSeqBytes[kNumBytes] = { 0, 3, 0, 0 };
166 const intkNumSeqs = (
int) sequences.size();
176 intindex, last_index=0;
177 Uint4length, max_len=0, avg_len=0;
183BOOST_REQUIRE_EQUAL(
sequence::GetLength(*sequences[index].seqloc, sequences[index].scope), length);
186max_len =
MAX(max_len, length);
189BOOST_REQUIRE(itr ==
NULL);
190BOOST_REQUIRE_EQUAL(kNumSeqs, last_index);
198seq_arg->
oid= kSeqIndex;
202sequences[kSeqIndex].scope),
205 for(index = 0; index < kNumBytes; ++index) {
206BOOST_REQUIRE_EQUAL(kNcbi2naSeqBytes[index],
214 for(index = 0; index < kNumBytes; ++index) {
215BOOST_REQUIRE_EQUAL(kBlastnaSeqBytes[index],
225 stringnull_db(
"");
228BOOST_REQUIRE(error_str !=
NULL);
236BOOST_REQUIRE(error_str !=
NULL);
244 const intkNumSeqs = 2004;
245 const intkRealNumSeqs = 1000;
246 const intkMaxLen = 875;
247 const intkMaxLenRange = 839;
248 const intkTotLen = 943942;
249 const intkTotLenRange = 478404;
250 const intkAvgLen = 471;
251 const intkSeqIndex = 1500;
252 const intkSeqLength = 715;
253 const intkNumBytes_2na = 4;
254 const intkNumBytes_4na = 5;
255 const intkNcbi2naSeqBytes[kNumBytes_2na] = { 159, 145, 213, 43 };
256 const intkBlastnaSeqBytes[kNumBytes_4na] = { 15, 2, 1, 3, 3 };
267 intindex, last_index=0;
268 Int8total_length = 0;
276max_length =
MAX(max_length, length);
277total_length += (
Int8) length;
280BOOST_REQUIRE(itr ==
NULL);
282BOOST_REQUIRE_EQUAL(kRealNumSeqs, last_index);
283BOOST_REQUIRE_EQUAL(kTotLenRange, (
int)total_length);
284BOOST_REQUIRE_EQUAL(kMaxLenRange, max_length);
288seq_arg->
oid= kSeqIndex;
291BOOST_REQUIRE_EQUAL(kSeqLength, seq_arg->
seq->
length);
292BOOST_REQUIRE_EQUAL(kSeqLength,
295 for(index = 0; index < kNumBytes_2na; ++index) {
296BOOST_REQUIRE_EQUAL(kNcbi2naSeqBytes[index],
304BOOST_REQUIRE(seq_arg !=
NULL);
305BOOST_REQUIRE(seq_arg->
seq!=
NULL);
307 for(index = 0; index < kNumBytes_4na; ++index) {
308BOOST_REQUIRE_EQUAL(kBlastnaSeqBytes[index],
319 const char* kDbName =
"data/seqn";
320 const Uint4kFirstSeq = 1000;
321 const Uint4kFinalSeq = 2000;
333 const char* kDbName =
"data/seqn";
334 const Uint4kFirstSeq = 1000;
335 const Uint4kFinalSeq = 2000;
348BOOST_REQUIRE_EQUAL(title, title2);
356 const char* kDbName =
"data/seqn";
357 const Uint4kFirstSeq = 1000;
358 const Uint4kFinalSeq = 2000;
373seq_arg1.
oid= seq_arg2.
oid= 5;
381BOOST_REQUIRE(seq_arg1.
seq);
382BOOST_REQUIRE(seq_arg2.
seq);
401 typedef structSSeqSrcTestInfo {
409 typedef enumECheckLengths {
419 classCSeqSrcTestThread :
public CThread 424SSeqSrcTestInfo* m_pTestInfo;
425ECheckLengths m_iCheckLengths;
428SSeqSrcTestInfo*
info, ECheckLengths cl)
429: m_pMutex(mutex), m_pTestInfo(
info), m_iCheckLengths(cl)
433~CSeqSrcTestThread() {}
435 virtual void*
Main(
void)
440 Int4length, max_len = 0;
448 if(m_iCheckLengths != eCheckNone) {
450max_len =
MAX(max_len, length);
451tot_len += (
Int8) length;
459m_pTestInfo->num_seqs += counter;
460m_pTestInfo->total_length += tot_len;
461m_pTestInfo->max_length =
MAX(m_pTestInfo->max_length, max_len);
465 virtual voidOnExit(
void) {}
478s_TestSeqSrcIteratorMT(
BlastSeqSrc** seq_src_ptr,
479ECheckLengths check_lengths,
480 intnum_threads,
intnumseqs)
482vector< CRef<CSeqSrcTestThread> > test_thread_v;
483test_thread_v.reserve(num_threads);
491seq_src = *seq_src_ptr;
496SSeqSrcTestInfo*
info=
497(SSeqSrcTestInfo*)
calloc(1,
sizeof(SSeqSrcTestInfo));
499 for(thr_index = 0; thr_index < num_threads; ++thr_index) {
501next_thread(
newCSeqSrcTestThread(seq_src, &mutex,
info,
503test_thread_v.push_back(next_thread);
506 for(thr_index = 0; thr_index < num_threads; ++thr_index) {
507test_thread_v[thr_index]->Join();
509BOOST_REQUIRE_EQUAL(numseqs,
info->num_seqs);
510 if(check_lengths != eCheckNone) {
512 info->total_length);
514(
int) (
info->total_length/
info->num_seqs));
515 if(check_lengths == eCheckTotalAndMax) {
538s_GetRangeBounds(
const string&
dbname,
boolis_prot,
539 intvol_start,
intvol_end,
intnum,
548 for(index = 0; index <= vol_start; ++index) {
550 CSeqDBseqdb(vol_name, prot_nucl);
557*first_seq = seqs_count - num;
558 for( ; index < vol_end; ++index) {
560 CSeqDBseqdb(vol_name, prot_nucl);
567*last_seq = seqs_count + num;
572s_TestSeqDbIterator(
const string&
dbname,
boolis_prot,
intfirst_seq,
573 intlast_seq,
intnthreads, ECheckLengths check_lengths)
577s_TestSeqSrcIteratorMT(&seq_src, check_lengths, nthreads,
578last_seq - first_seq);
584s_TestSeqDbIterator(
"patnt",
false, 0, 0, 2, eCheckNone);
590s_TestSeqDbIterator(
"patnt",
false, 0, 0, 4, eCheckNone);
596s_TestSeqDbIterator(
"patnt",
false, 0, 0, 20, eCheckNone);
603s_TestSeqDbIterator(
"patnt",
false, 1000, 10000, 2, eCheckNone);
610s_TestSeqDbIterator(
"patnt",
false, 1000, 10000, 4, eCheckNone);
617s_TestSeqDbIterator(
"patnt",
false, 1000, 10000, 20, eCheckNone);
623s_TestSeqDbIterator(
"nt",
false, 0, 0, 2, eCheckNone);
629s_TestSeqDbIterator(
"nt",
false, 0, 0, 4, eCheckNone);
635s_TestSeqDbIterator(
"nt",
false, 0, 0, 20, eCheckNone);
640 voids_TestSeqDbIterator_nt_range(
intnthreads)
642 const intkNumSeqs = 1000;
643 const stringkDbName(
"nt");
647s_GetRangeBounds(kDbName,
false, 0, 2, kNumSeqs, &first_seq, &last_seq,
649s_TestSeqDbIterator(kDbName,
false, first_seq, last_seq, nthreads,
657s_TestSeqDbIterator_nt_range(2);
664s_TestSeqDbIterator_nt_range(4);
671s_TestSeqDbIterator_nt_range(20);
677s_TestSeqDbIterator(
"UnitTest/pataa_multivol",
true, 0, 0, 2,
684s_TestSeqDbIterator(
"UnitTest/pataa_multivol",
true, 0, 0, 4,
691s_TestSeqDbIterator(
"UnitTest/pataa_multivol",
true, 0, 0, 20,
697 voids_TestSeqDbIterator_pataa_multi_range(
intnthreads)
699 const intkNumSeqs = 1000;
700 const stringkDbName(
"UnitTest/pataa_multivol");
704s_GetRangeBounds(kDbName,
true, 0, 1, kNumSeqs,
705&first_seq, &last_seq,
true);
706s_TestSeqDbIterator(kDbName,
true, first_seq, last_seq, nthreads,
714s_TestSeqDbIterator_pataa_multi_range(2);
721s_TestSeqDbIterator_pataa_multi_range(4);
728s_TestSeqDbIterator_pataa_multi_range(20);
734s_TestSeqDbIterator(
"UnitTest/pataa_emb",
true, 0, 0, 2, eCheckTotal);
740s_TestSeqDbIterator(
"UnitTest/pataa_emb",
true, 0, 0, 4, eCheckTotal);
746s_TestSeqDbIterator(
"UnitTest/pataa_emb",
true, 0, 0, 20, eCheckTotal);
752s_TestSeqDbIterator(
"pdbaa",
true, 0, 0, 2, eCheckTotal);
758s_TestSeqDbIterator(
"pdbaa",
true, 0, 0, 4, eCheckTotal);
764s_TestSeqDbIterator(
"pdbaa",
true, 0, 0, 20, eCheckTotal);
770s_TestSeqDbIterator(
"pdbnt",
false, 0, 0, 2, eCheckTotal);
776s_TestSeqDbIterator(
"pdbnt",
false, 0, 0, 4, eCheckTotal);
782s_TestSeqDbIterator(
"pdbnt",
false, 0, 0, 20, eCheckTotal);
788s_TestSeqDbIterator(
"pataa pdbaa",
true, 0, 0, 2, eCheckTotal);
794s_TestSeqDbIterator(
"pataa pdbaa",
true, 0, 0, 4, eCheckTotal);
800s_TestSeqDbIterator(
"pataa pdbaa",
true, 0, 0, 20, eCheckTotal);
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definitions which are dependant on the NCBI C++ Object Manager.
#define BLAST_SEQSRC_ERROR
Error while retrieving sequence.
Int4 BlastSeqSrcIteratorNext(const BlastSeqSrc *seq_src, BlastSeqSrcIterator *itr)
Increments the BlastSeqSrcIterator.
BlastSeqSrcIterator * BlastSeqSrcIteratorFree(BlastSeqSrcIterator *itr)
Frees the BlastSeqSrcIterator structure.
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.
void BlastSeqSrcReleaseSequence(const BlastSeqSrc *seq_src, BlastSeqSrcGetSeqArg *getseq_arg)
Deallocate individual sequence.
BlastSeqSrcIterator * BlastSeqSrcIteratorNew(void)
Allocate and initialize an iterator over a BlastSeqSrc with a default chunk size for MT-safe iteratio...
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 ...
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 BlastSeqSrcGetMaxSeqLen(const BlastSeqSrc *seq_src)
Get the length of the longest sequence in the sequence source.
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.
#define BLAST_SEQSRC_EOF
No more sequences available.
Various auxiliary BLAST utility functions.
BLAST_SequenceBlk * BlastSequenceBlkFree(BLAST_SequenceBlk *seq_blk)
Deallocate memory for a sequence block.
void BlastSequenceBlkClean(BLAST_SequenceBlk *seq_blk)
Deallocate memory only for the sequence in the sequence block.
BOOST_AUTO_TEST_SUITE_END() static int s_GetSegmentFlags(const CBioseq &bioseq)
ESeqType
Sequence types (eUnknown tries protein, then nucleotide).
string GetTitle() const
Returns the database title.
@ eFilteredAll
Values from alias files, or summation over all included sequences.
static CTestObjMgr & Instance()
int Main(int argc, const char *argv[])
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.
BlastSeqSrc * MultiSeqBlastSeqSrcInit(TSeqLocVector &seq_vector, EBlastProgramType program, bool dbscan_mode=false)
Initialize the sequence source structure.
@ eBlastEncodingNucleotide
Special encoding for preliminary stage of BLAST: permutation of NCBI4na.
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
uint8_t Uint1
1-byte (8-bit) unsigned integer
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
@ eNa_strand_both
in forward orientation
char * dbname(DBPROCESS *dbproc)
Get name of current database.
unsigned int
A callback function used to compare two keys in a database.
constexpr auto sort(_Init &&init)
int strcmp(const char *str1, const char *str2)
#define MAX(a, b)
returns larger of a and b.
Multi-threading â classes, functions, and features.
BOOST_AUTO_TEST_SUITE(psiblast_iteration)
Defines BLAST database access classes.
Implementation of the BlastSeqSrc interface for a vector of sequence locations.
Implementation of the BlastSeqSrc interface using the C++ BLAST databases API.
static void s_checkDbSeqSrcFunctions(BlastSeqSrc *seq_src, const char *dbname)
BOOST_AUTO_TEST_CASE(testMultiSeqSrc_FailureToInitialize)
static TSeqLocVector s_getSequences()
vector< SSeqLoc > TSeqLocVector
Vector of sequence locations.
Uint1 * sequence_start
Start of sequence, usually one byte before sequence as that byte is a NULL sentinel byte.
Int4 length
Length of sequence.
Uint1 * sequence
Sequence used for search (could be translation).
Structure used as the second argument to functions satisfying the GetSeqBlkFnPtr signature,...
Int4 oid
Oid in BLAST database, index in an array of sequences, etc [in].
EBlastEncoding encoding
Encoding of sequence, i.e.
BLAST_SequenceBlk * seq
Sequence to return, if NULL, it should allocated by GetSeqBlkFnPtr (using BlastSeqBlkNew or BlastSetU...
Complete type definition of Blast Sequence Source Iterator.
Complete type definition of Blast Sequence Source ADT.
Utility stuff for more convenient using of Boost.Test library.
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
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