Sequence::value_type motif_char;
Sequence::value_type seq_char;
- while (seq_i < seq->length())
+ while (seq_i < size())
{
// this is pretty much a straight translation of Nora's python code
// to match iupac letter codes
motif_char = toupper(a_motif[motif_i]);
- seq_char = toupper(seq->at(seq_i));
+ seq_char = toupper(seq->at(seq_start+seq_i));
if (motif_char =='N')
motif_i++;
else if (motif_char == seq_char)
*/
}
+BOOST_AUTO_TEST_CASE( sequence_motif_subseq)
+{
+ // when searching for a motif on a subsequence we should
+ // only search the subsequence ticket:199
+ string aaaa("AAAA");
+ string cccc("CCCC");
+ Sequence s1("AAAANCCCC", Sequence::reduced_dna_alphabet);
+
+ // this shouldn't show up
+ s1.add_motif(cccc);
+ BOOST_CHECK_EQUAL( s1.motifs().size(), 1 );
+
+ s1.add_motif(aaaa);
+ BOOST_CHECK_EQUAL( s1.motifs().size(), 2 );
+
+ Sequence subseq1 = s1.subseq(4,5);
+ BOOST_CHECK_EQUAL(subseq1.motifs().size(), 2);
+ subseq1.clear_motifs();
+ BOOST_CHECK_EQUAL(subseq1.motifs().size(), 0);
+ // this is outside of our subsequence, and so shouldn't be found
+ subseq1.add_motif(aaaa);
+ BOOST_CHECK_EQUAL( subseq1.motifs().size(), 0 );
+
+ subseq1.add_motif(cccc);
+ BOOST_CHECK_EQUAL( subseq1.motifs().size(), 1);
+ std::list<motif>::const_iterator motif_i = subseq1.motifs().begin();
+ BOOST_REQUIRE(motif_i != subseq1.motifs().end());
+ BOOST_CHECK_EQUAL(motif_i->begin, 1);
+ BOOST_CHECK_EQUAL(motif_i->end, 5);
+}
+
BOOST_AUTO_TEST_CASE( annot_test )
{
annot a(0, 10, "test", "thing");
"empty model now.");
}
- MussaRef m(new Mussa);
+ MussaRef new_m(new Mussa);
for(SequenceLocationModel::iterator itor = model.begin();
itor != model.end();
{
// append_sequence from a const Sequence & will make a copy
// for the shared pointer.
- m->append_sequence(itor->getSelectedSequence());
+ Sequence s = itor->getSelectedSequence();
+ s.clear_motifs();
+ new_m->append_sequence(s);
}
try {
- m->set_window(window->value());
- m->set_threshold(threshold->value());
- m->analyze();
- MussaWindow *mw = new MussaWindow(m);
+ new_m->set_window(window->value());
+ new_m->set_threshold(threshold->value());
+ new_m->analyze();
+
+ // copy over motifs
+ std::vector<Sequence> motifs_copy;
+ std::vector<Color> color_copy;
+ const Mussa::motif_set motifs = analysis->motifs();
+ boost::shared_ptr<AnnotationColors> mapper = analysis->colorMapper();
+ for(Mussa::motif_set::const_iterator motif_i = motifs.begin();
+ motif_i != motifs.end();
+ ++motif_i)
+ {
+ motifs_copy.push_back(*motif_i);
+ color_copy.push_back(mapper->lookup("motif", motif_i->get_sequence()));
+ }
+ new_m->set_motifs(motifs_copy, color_copy);
+ MussaWindow *mw = new MussaWindow(new_m);
mw->show();
model.clear();
hide();