X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=blobdiff_plain;f=alg%2Ftest%2Ftest_sequence.cpp;h=9faa8d069c156376ce945202527664b9955d47e6;hp=82ff14be6c1ff40c6d9ce1155def83c0c5e4dda7;hb=15f9eb9d7ba5ffe32cbe7bc67a9d85b714c27871;hpb=9d76ff624ae315a1262d6ceba1faeb68484ebd85 diff --git a/alg/test/test_sequence.cpp b/alg/test/test_sequence.cpp index 82ff14b..9faa8d0 100644 --- a/alg/test/test_sequence.cpp +++ b/alg/test/test_sequence.cpp @@ -586,6 +586,22 @@ BOOST_AUTO_TEST_CASE( annotation_load_no_species_name ) BOOST_CHECK_EQUAL( annots[0]->annotations()->get("type"), "type"); } +// when we do a subsequence (or something that calls copy_children) +// the annotations need to be updated to have the right parent +BOOST_AUTO_TEST_CASE( update_annotations_seqref ) +{ + Sequence s1("AAAAGGGG"); + s1.add_annotation("A", "A", 0, 4); + BOOST_CHECK_EQUAL(s1.annotations().size(), 1); + BOOST_CHECK_EQUAL(s1.seqspan(), s1.annotations().front()->parent() ); + + Sequence subseq1(s1.subseq(2,4)); + BOOST_CHECK_EQUAL(subseq1.annotations().size(), 1); + BOOST_CHECK_EQUAL(subseq1.annotations().front()->parentStart(), 0 ); + BOOST_CHECK_EQUAL(subseq1.annotations().front()->parentStop(), 2 ); + BOOST_CHECK_EQUAL(subseq1.seqspan(), subseq1.annotations().front()->parent() ); +} + // ticket:83 when you try to load a sequence from a file that doesn't // have fasta headers it crashes. BOOST_AUTO_TEST_CASE( sequence_past_end ) @@ -840,22 +856,22 @@ BOOST_AUTO_TEST_CASE( subseq_annotation_test ) BOOST_REQUIRE_EQUAL( annots_list.size(), 4 ); std::vector annots(annots_list.begin(), annots_list.end()); - BOOST_CHECK_EQUAL( annots[0]->start(), 0); + BOOST_CHECK_EQUAL( annots[0]->parentStart(), 0); BOOST_CHECK_EQUAL( annots[0]->size(), 5); BOOST_REQUIRE( annots[0]->annotations() ); BOOST_CHECK_EQUAL( annots[0]->annotations()->name(), "0-10"); - BOOST_CHECK_EQUAL( annots[1]->start(), 5); - BOOST_CHECK_EQUAL( annots[1]->size(), 10); + BOOST_CHECK_EQUAL( annots[1]->parentStart(), 5); + BOOST_CHECK_EQUAL( annots[1]->size(), 5); BOOST_REQUIRE( annots[1]->annotations() ); BOOST_CHECK_EQUAL( annots[1]->annotations()->name(), "10-20"); - BOOST_CHECK_EQUAL( annots[2]->start(), 0); + BOOST_CHECK_EQUAL( annots[2]->parentStart(), 0); BOOST_CHECK_EQUAL( annots[2]->size(), 10); BOOST_REQUIRE( annots[2]->annotations() ); BOOST_CHECK_EQUAL( annots[2]->annotations()->name(), "0-20"); - BOOST_CHECK_EQUAL( annots[3]->start(), 3); + BOOST_CHECK_EQUAL( annots[3]->parentStart(), 3); BOOST_CHECK_EQUAL( annots[3]->size(), 7); BOOST_REQUIRE( annots[3]->annotations() ); BOOST_CHECK_EQUAL( annots[3]->annotations()->name(), "8-12");