iqbal-lab-org / gramtools

Genome inference from a population reference graph
MIT License
92 stars 15 forks source link

Something odd with sites object in unit test for forward bidir search #32

Closed iqbal-lab closed 6 years ago

iqbal-lab commented 8 years ago

In test Long_site_and_repeated_snp_on_edge_of_site at commit 2a41ce162e87b7d69c89eb079343705551be5803

We have prg = gacatagacacacagt5gtcgcctcgtcggctttgagt6gtcgctgctccacacagagact5ggtgctagac7c8a7ccagctgctccacacagaga and

  //read aligns across sites 5 and 7, allele 1 in both cases                                                                                                              
    query="tagacacacagtgtcgcctcgtcggctttgagtggtgctagacccca";

First the unit test does a bidir backward search and all the unti test assertions pass

` EXPECT_EQ(true,first_del); EXPECT_EQ(1,sa_intervals.size()); EXPECT_EQ(no_occ,1);

EXPECT_EQ(sites.front().front().first, 7);
EXPECT_EQ(sites.front().front().second.front(), 1);
EXPECT_EQ(sites.front().front().second.size(), 1);
EXPECT_EQ(sites.front().back().first, 5);
EXPECT_EQ(sites.front().back().second.front(), 1);
EXPECT_EQ(sites.front().back().second.size(), 1);`

If we print the sites variable we see this

p sites
$1 = std::list = {[0] = std::vector of length 2, capacity 100 = {{first = 7, second= std::vector of length 1, capacity 1 = {1}}, {first = 5, second = std::vector of length 1, capacity 1 = {1}}}} 

Then we clear variables:

sa_intervals.clear(); sa_intervals_rev.clear(); sites.clear();

and search with the bidir forwards search. Now as soon as we finish the forward search, we print sites and see this:

p sites $3 = std::list = {[0] = std::vector of length 4, capacity 4 = {{first = 5, second =std::vector of length 3, capacity 3 = {1, 2, 1}}, {first = 5, second = std::vector of length 4, capacity 4 = {1, 2, 1, 2}}, {first = 7, second = std::vector of length 4, capacity 4 = {1, 2, 1, 2}}, {first = 7, second = std::vector of length 5, capacity 5 = {1, 2, 1, 2, 1}}}}

That doesnt look right to me at all, and when we get to the assertions we have this code

EXPECT_EQ(sites.front().front().first, 5); EXPECT_EQ(sites.front().front().second.front(), 1); EXPECT_EQ(sites.front().front().second.size(), 1); EXPECT_EQ(sites.front().back().first, 7); EXPECT_EQ(sites.front().back().second.front(), 1); EXPECT_EQ(sites.front().back().second.size(), 1);

and this output `./test/unittest_bidir_search_bwd_fwd.cpp:586: Failure Value of: 1 Expected: sites.front().front().second.size() Which is: 3

./test/unittest_bidir_search_bwd_fwd.cpp:589: Failure Value of: 1 Expected: sites.front().back().second.size() Which is: 5 `

iqbal-lab commented 8 years ago

So looks like in the forward search we are not adding to sites object properly.

iqbal-lab commented 8 years ago

In commit 318a43b5656560fa65fdcc538a7ea5f7ea8f318b I've added a similar check in an earlier unit test (2SNPs) and that also fails:

[ RUN ] BackwardSearchTest.TwoSNPs ./test/unittest_bidir_search_bwd_fwd.cpp:229: Failure Value of: 1 Expected: sites.front().back().second.size() Which is: 3 [ FAILED ] BackwardSearchTest.TwoSNPs (476 ms)

iqbal-lab commented 8 years ago

I notice we clear empty_allele differently in fwd and bwd

ffranr commented 6 years ago

No longer relevant.