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 )
BOOST_REQUIRE_EQUAL( annots_list.size(), 4 );
std::vector<SeqSpanRef> 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");