Skip to content

Commit 646c9e5

Browse files
boratynggouriano
authored andcommitted
A fix for undercounting the longest chain in discontiguous MB lookup table JIRA SB-4280
git-svn-id: https://anonsvn.ncbi.nlm.nih.gov/repos/v1/trunk/c++@103530 78c7ea69-d796-4a43-9a09-de51944f1b03
1 parent 173c843 commit 646c9e5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/algo/blast/core/blast_nalookup.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,14 +800,18 @@ s_FillDiscMBTable(BLAST_SequenceBlk* query, BlastSeqLoc* location,
800800
longest_chain = 2;
801801
for (index = 0; index < mb_lt->hashsize / kCompressionFactor; index++)
802802
longest_chain = MAX(longest_chain, helper_array[index]);
803-
mb_lt->longest_chain = longest_chain;
803+
/* +1 because helper_array is not incremented for the first position of a
804+
word */
805+
mb_lt->longest_chain = longest_chain + 1;
804806
sfree(helper_array);
805807

806808
if (kTwoTemplates) {
807809
longest_chain = 2;
808810
for (index = 0; index < mb_lt->hashsize / kCompressionFactor; index++)
809811
longest_chain = MAX(longest_chain, helper_array2[index]);
810-
mb_lt->longest_chain += longest_chain;
812+
/* +1 because helper_array2 is not incremented for the first position of a
813+
word */
814+
mb_lt->longest_chain += longest_chain + 1;
811815
sfree(helper_array2);
812816
}
813817
return 0;

src/algo/blast/unit_tests/api/ntlookup_unit_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE(testDiscontiguousMBLookupTableCodingWordSize11) {
279279
BOOST_REQUIRE_EQUAL(16, (int)lookup->template_length);
280280
BOOST_REQUIRE_EQUAL(1, (int)lookup->template_type);
281281
BOOST_REQUIRE_EQUAL(1, lookup->scan_step);
282-
BOOST_REQUIRE_EQUAL(2, lookup->longest_chain);
282+
BOOST_REQUIRE_EQUAL(3, lookup->longest_chain);
283283
BOOST_REQUIRE_EQUAL(49, lookup->hashtable[2463300]);
284284
BOOST_REQUIRE_EQUAL(392, lookup->hashtable[1663305]);
285285
BOOST_REQUIRE_EQUAL(1049, lookup->hashtable[3586129]);
@@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(testDiscontiguousMBLookupTableCodingWordSize12) {
325325
BOOST_REQUIRE_EQUAL(16, (int)lookup->template_length);
326326
BOOST_REQUIRE_EQUAL(3, (int)lookup->template_type);
327327
BOOST_REQUIRE_EQUAL(1, lookup->scan_step);
328-
BOOST_REQUIRE_EQUAL(2, lookup->longest_chain);
328+
BOOST_REQUIRE_EQUAL(3, lookup->longest_chain);
329329
BOOST_REQUIRE_EQUAL(3631, lookup->hashtable[133875]);
330330
BOOST_REQUIRE_EQUAL(2092, lookup->hashtable[351221]);
331331
BOOST_REQUIRE_EQUAL(4951, lookup->hashtable[1336356]);
@@ -371,7 +371,7 @@ BOOST_AUTO_TEST_CASE(testDiscontiguousMBLookupTableOptimalWordSize11) {
371371
BOOST_REQUIRE_EQUAL(16, (int)lookup->template_length);
372372
BOOST_REQUIRE_EQUAL(2, (int)lookup->template_type);
373373
BOOST_REQUIRE_EQUAL(1, lookup->scan_step);
374-
BOOST_REQUIRE_EQUAL(2, lookup->longest_chain);
374+
BOOST_REQUIRE_EQUAL(3, lookup->longest_chain);
375375
BOOST_REQUIRE_EQUAL(36, lookup->hashtable[1353317]);
376376
BOOST_REQUIRE_EQUAL(375, lookup->hashtable[1955444]);
377377
BOOST_REQUIRE_EQUAL(5455, lookup->hashtable[1735012]);
@@ -417,7 +417,7 @@ BOOST_AUTO_TEST_CASE(testDiscontiguousMBLookupTableOptimalWordSize12) {
417417
BOOST_REQUIRE_EQUAL(16, (int)lookup->template_length);
418418
BOOST_REQUIRE_EQUAL(4, (int)lookup->template_type);
419419
BOOST_REQUIRE_EQUAL(1, lookup->scan_step);
420-
BOOST_REQUIRE_EQUAL(2, lookup->longest_chain);
420+
BOOST_REQUIRE_EQUAL(3, lookup->longest_chain);
421421
BOOST_REQUIRE_EQUAL(82, lookup->hashtable[9606485]);
422422
BOOST_REQUIRE_EQUAL(752, lookup->hashtable[15622537]);
423423
BOOST_REQUIRE_EQUAL(5408, lookup->hashtable[10084009]);
@@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(testDiscontiguousMBLookupTableTwoTemplatesWordSize11) {
465465
BOOST_REQUIRE_EQUAL(1, (int)lookup->two_templates);
466466
BOOST_REQUIRE_EQUAL(2, (int)lookup->second_template_type);
467467
BOOST_REQUIRE_EQUAL(1, lookup->scan_step);
468-
BOOST_REQUIRE_EQUAL(4, lookup->longest_chain);
468+
BOOST_REQUIRE_EQUAL(6, lookup->longest_chain);
469469
BOOST_REQUIRE_EQUAL(128, lookup->hashtable[1450605]);
470470
BOOST_REQUIRE_EQUAL(342, lookup->hashtable[4025953]);
471471
BOOST_REQUIRE_EQUAL(663, lookup->hashtable[3139906]);

0 commit comments

Comments
 (0)