A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/seqsrc__unit__test_8cpp_source.html below:

NCBI C++ ToolKit: src/algo/blast/unit_tests/api/seqsrc_unit_test.cpp Source File

48 #ifdef KAPPA_PRINT_DIAGNOSTICS 50 #include <algo/blast/api/seqsrc_readdb.h> 68  const int

kNumSeqs = 70;

70  const int

kGiList[kNumSeqs] =

71

{ 1786181, 1786192, 2367095, 1786217, 1786230, 1786240, 1786250,

72

1786262, 1786283, 1786298, 1786306, 1786315, 1786327, 1786339,

73

1786348, 1786358, 1786370, 1786383, 1786395, 1786402, 1786415,

74

2367098, 2367099, 1786454, 1786465, 2367103, 2367108, 1786501,

75

1786510, 1786520, 1786532, 1786542, 1786554, 1786568, 1786580,

76

1786596, 1786603, 1786614, 1786628, 1786639, 1786649, 1786660,

77

1786671, 1786683, 1786692, 1786705, 1786716, 1786728, 1786739,

78

1786751, 1786766, 1786782, 1786790, 1786800, 1786808, 1786819,

79

1786836, 1786849, 1786862, 1786875, 1786888, 1786896, 1786910,

80

1786920, 1786934, 1786947, 1786955, 1786967, 1786978, 1786988 };

85  for

(index = 0; index < kNumSeqs; ++index) {

86

sprintf(id_buffer,

"gi|%d"

, kGiList[index]);

88

unique_ptr<SSeqLoc> sl(

91

retval.push_back(*sl);

99 #ifdef KAPPA_PRINT_DIAGNOSTICS 102

s_TestGetGis(

BlastSeqSrc

* seqsrc,

const

pair<string, bool>& dbinfo) {

103  const int

gis[] = { 68737, 129295 };

105  CSeqDB

seqdb(dbinfo.first, dbinfo.second

108

seqdb.GiToOid(gis[0], oid);

109

BOOST_REQUIRE(oid != -1);

111

Blast_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

++) {

114

BOOST_REQUIRE_EQUAL(gilist->data[

i

], gis[

i

]);

116

gilist = Blast_GiListFree(gilist);

117

BOOST_REQUIRE(gilist ==

NULL

);

121  const

pair<string, bool> kDbInfo(

"nr"

,

true

);

126

BOOST_REQUIRE(error_str ==

NULL

);

128

s_TestGetGis(seq_src, kDbInfo);

134  const

pair<string, bool> kDbInfo(

"nr"

,

true

);

135  BlastSeqSrc

* seq_src = ReaddbBlastSeqSrcInit(kDbInfo.first.c_str(),

136

kDbInfo.second, 0, 0);

138

BOOST_REQUIRE(error_str ==

NULL

);

140

s_TestGetGis(seq_src, kDbInfo);

154

BOOST_REQUIRE(error_str !=

NULL

);

160  const int

kNumBytes = 4;

161  const int

kSeqIndex = 40;

162  const Uint1

kNcbi2naSeqBytes[kNumBytes] = { 48, 215, 159, 129 };

163  const Uint1

kBlastnaSeqBytes[kNumBytes] = { 0, 3, 0, 0 };

166  const int

kNumSeqs = (

int

) sequences.size();

176  int

index, last_index=0;

177  Uint4

length, max_len=0, avg_len=0;

183

BOOST_REQUIRE_EQUAL(

sequence::GetLength

(*sequences[index].seqloc, sequences[index].scope), length);

186

max_len =

MAX

(max_len, length);

189

BOOST_REQUIRE(itr ==

NULL

);

190

BOOST_REQUIRE_EQUAL(kNumSeqs, last_index);

198

seq_arg->

oid

= kSeqIndex;

202

sequences[kSeqIndex].scope),

205  for

(index = 0; index < kNumBytes; ++index) {

206

BOOST_REQUIRE_EQUAL(kNcbi2naSeqBytes[index],

214  for

(index = 0; index < kNumBytes; ++index) {

215

BOOST_REQUIRE_EQUAL(kBlastnaSeqBytes[index],

225  string

null_db(

""

);

228

BOOST_REQUIRE(error_str !=

NULL

);

236

BOOST_REQUIRE(error_str !=

NULL

);

244  const int

kNumSeqs = 2004;

245  const int

kRealNumSeqs = 1000;

246  const int

kMaxLen = 875;

247  const int

kMaxLenRange = 839;

248  const int

kTotLen = 943942;

249  const int

kTotLenRange = 478404;

250  const int

kAvgLen = 471;

251  const int

kSeqIndex = 1500;

252  const int

kSeqLength = 715;

253  const int

kNumBytes_2na = 4;

254  const int

kNumBytes_4na = 5;

255  const int

kNcbi2naSeqBytes[kNumBytes_2na] = { 159, 145, 213, 43 };

256  const int

kBlastnaSeqBytes[kNumBytes_4na] = { 15, 2, 1, 3, 3 };

267  int

index, last_index=0;

268  Int8

total_length = 0;

276

max_length =

MAX

(max_length, length);

277

total_length += (

Int8

) length;

280

BOOST_REQUIRE(itr ==

NULL

);

282

BOOST_REQUIRE_EQUAL(kRealNumSeqs, last_index);

283

BOOST_REQUIRE_EQUAL(kTotLenRange, (

int

)total_length);

284

BOOST_REQUIRE_EQUAL(kMaxLenRange, max_length);

288

seq_arg->

oid

= kSeqIndex;

291

BOOST_REQUIRE_EQUAL(kSeqLength, seq_arg->

seq

->

length

);

292

BOOST_REQUIRE_EQUAL(kSeqLength,

295  for

(index = 0; index < kNumBytes_2na; ++index) {

296

BOOST_REQUIRE_EQUAL(kNcbi2naSeqBytes[index],

304

BOOST_REQUIRE(seq_arg !=

NULL

);

305

BOOST_REQUIRE(seq_arg->

seq

!=

NULL

);

307  for

(index = 0; index < kNumBytes_4na; ++index) {

308

BOOST_REQUIRE_EQUAL(kBlastnaSeqBytes[index],

319  const char

* kDbName =

"data/seqn"

;

320  const Uint4

kFirstSeq = 1000;

321  const Uint4

kFinalSeq = 2000;

333  const char

* kDbName =

"data/seqn"

;

334  const Uint4

kFirstSeq = 1000;

335  const Uint4

kFinalSeq = 2000;

348

BOOST_REQUIRE_EQUAL(title, title2);

356  const char

* kDbName =

"data/seqn"

;

357  const Uint4

kFirstSeq = 1000;

358  const Uint4

kFinalSeq = 2000;

373

seq_arg1.

oid

= seq_arg2.

oid

= 5;

381

BOOST_REQUIRE(seq_arg1.

seq

);

382

BOOST_REQUIRE(seq_arg2.

seq

);

401 typedef struct

SSeqSrcTestInfo {

409 typedef enum

ECheckLengths {

419 class

CSeqSrcTestThread :

public CThread 424

SSeqSrcTestInfo* m_pTestInfo;

425

ECheckLengths m_iCheckLengths;

428

SSeqSrcTestInfo*

info

, ECheckLengths cl)

429

: m_pMutex(mutex), m_pTestInfo(

info

), m_iCheckLengths(cl)

433

~CSeqSrcTestThread() {}

435  virtual void

*

Main

(

void

)

440  Int4

length, max_len = 0;

448  if

(m_iCheckLengths != eCheckNone) {

450

max_len =

MAX

(max_len, length);

451

tot_len += (

Int8

) length;

459

m_pTestInfo->num_seqs += counter;

460

m_pTestInfo->total_length += tot_len;

461

m_pTestInfo->max_length =

MAX

(m_pTestInfo->max_length, max_len);

465  virtual void

OnExit(

void

) {}

478

s_TestSeqSrcIteratorMT(

BlastSeqSrc

** seq_src_ptr,

479

ECheckLengths check_lengths,

480  int

num_threads,

int

numseqs)

482

vector< CRef<CSeqSrcTestThread> > test_thread_v;

483

test_thread_v.reserve(num_threads);

491

seq_src = *seq_src_ptr;

496

SSeqSrcTestInfo*

info

=

497

(SSeqSrcTestInfo*)

calloc

(1,

sizeof

(SSeqSrcTestInfo));

499  for

(thr_index = 0; thr_index < num_threads; ++thr_index) {

501

next_thread(

new

CSeqSrcTestThread(seq_src, &mutex,

info

,

503

test_thread_v.push_back(next_thread);

506  for

(thr_index = 0; thr_index < num_threads; ++thr_index) {

507

test_thread_v[thr_index]->Join();

509

BOOST_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) {

538

s_GetRangeBounds(

const string

&

dbname

,

bool

is_prot,

539  int

vol_start,

int

vol_end,

int

num,

548  for

(index = 0; index <= vol_start; ++index) {

550  CSeqDB

seqdb(vol_name, prot_nucl);

557

*first_seq = seqs_count - num;

558  for

( ; index < vol_end; ++index) {

560  CSeqDB

seqdb(vol_name, prot_nucl);

567

*last_seq = seqs_count + num;

572

s_TestSeqDbIterator(

const string

&

dbname

,

bool

is_prot,

int

first_seq,

573  int

last_seq,

int

nthreads, ECheckLengths check_lengths)

577

s_TestSeqSrcIteratorMT(&seq_src, check_lengths, nthreads,

578

last_seq - first_seq);

584

s_TestSeqDbIterator(

"patnt"

,

false

, 0, 0, 2, eCheckNone);

590

s_TestSeqDbIterator(

"patnt"

,

false

, 0, 0, 4, eCheckNone);

596

s_TestSeqDbIterator(

"patnt"

,

false

, 0, 0, 20, eCheckNone);

603

s_TestSeqDbIterator(

"patnt"

,

false

, 1000, 10000, 2, eCheckNone);

610

s_TestSeqDbIterator(

"patnt"

,

false

, 1000, 10000, 4, eCheckNone);

617

s_TestSeqDbIterator(

"patnt"

,

false

, 1000, 10000, 20, eCheckNone);

623

s_TestSeqDbIterator(

"nt"

,

false

, 0, 0, 2, eCheckNone);

629

s_TestSeqDbIterator(

"nt"

,

false

, 0, 0, 4, eCheckNone);

635

s_TestSeqDbIterator(

"nt"

,

false

, 0, 0, 20, eCheckNone);

640 void

s_TestSeqDbIterator_nt_range(

int

nthreads)

642  const int

kNumSeqs = 1000;

643  const string

kDbName(

"nt"

);

647

s_GetRangeBounds(kDbName,

false

, 0, 2, kNumSeqs, &first_seq, &last_seq,

649

s_TestSeqDbIterator(kDbName,

false

, first_seq, last_seq, nthreads,

657

s_TestSeqDbIterator_nt_range(2);

664

s_TestSeqDbIterator_nt_range(4);

671

s_TestSeqDbIterator_nt_range(20);

677

s_TestSeqDbIterator(

"UnitTest/pataa_multivol"

,

true

, 0, 0, 2,

684

s_TestSeqDbIterator(

"UnitTest/pataa_multivol"

,

true

, 0, 0, 4,

691

s_TestSeqDbIterator(

"UnitTest/pataa_multivol"

,

true

, 0, 0, 20,

697 void

s_TestSeqDbIterator_pataa_multi_range(

int

nthreads)

699  const int

kNumSeqs = 1000;

700  const string

kDbName(

"UnitTest/pataa_multivol"

);

704

s_GetRangeBounds(kDbName,

true

, 0, 1, kNumSeqs,

705

&first_seq, &last_seq,

true

);

706

s_TestSeqDbIterator(kDbName,

true

, first_seq, last_seq, nthreads,

714

s_TestSeqDbIterator_pataa_multi_range(2);

721

s_TestSeqDbIterator_pataa_multi_range(4);

728

s_TestSeqDbIterator_pataa_multi_range(20);

734

s_TestSeqDbIterator(

"UnitTest/pataa_emb"

,

true

, 0, 0, 2, eCheckTotal);

740

s_TestSeqDbIterator(

"UnitTest/pataa_emb"

,

true

, 0, 0, 4, eCheckTotal);

746

s_TestSeqDbIterator(

"UnitTest/pataa_emb"

,

true

, 0, 0, 20, eCheckTotal);

752

s_TestSeqDbIterator(

"pdbaa"

,

true

, 0, 0, 2, eCheckTotal);

758

s_TestSeqDbIterator(

"pdbaa"

,

true

, 0, 0, 4, eCheckTotal);

764

s_TestSeqDbIterator(

"pdbaa"

,

true

, 0, 0, 20, eCheckTotal);

770

s_TestSeqDbIterator(

"pdbnt"

,

false

, 0, 0, 2, eCheckTotal);

776

s_TestSeqDbIterator(

"pdbnt"

,

false

, 0, 0, 4, eCheckTotal);

782

s_TestSeqDbIterator(

"pdbnt"

,

false

, 0, 0, 20, eCheckTotal);

788

s_TestSeqDbIterator(

"pataa pdbaa"

,

true

, 0, 0, 2, eCheckTotal);

794

s_TestSeqDbIterator(

"pataa pdbaa"

,

true

, 0, 0, 4, eCheckTotal);

800

s_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