X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=blobdiff_plain;f=qui%2Fmotif_editor%2Ftest%2FTestMotifEditor.hpp;h=af01cb86e087fe5c1e33dde8936000bb13449cab;hp=273473a2e53fc229aae914afed500635fc503a88;hb=8b38b5bc63e5c62983d0814aa75d3f88b9116e49;hpb=4b9dd885cdfef6d73c82bae5f112a063588766a9 diff --git a/qui/motif_editor/test/TestMotifEditor.hpp b/qui/motif_editor/test/TestMotifEditor.hpp index 273473a..af01cb8 100644 --- a/qui/motif_editor/test/TestMotifEditor.hpp +++ b/qui/motif_editor/test/TestMotifEditor.hpp @@ -60,6 +60,57 @@ private slots: QVERIFY(sequences2[0]->motifs().size() == 1); QVERIFY(sequences2[1]->motifs().size() == 0); QVERIFY(cm->lookup("motif", "AAGG") == Color(0.0, 1.0, 0.0)); + QVERIFY(m->colorMapper()->lookup("motif", "AAGG") == Color(0.0, 1.0, 0.0)); + + QVERIFY(editor->get_analysis() == m); + QVERIFY(editor->get_model() == model); + QVERIFY(m->colorMapper() == cm); + } + + void testEditMotifApply() { + std::vector motifs; + motifs.push_back("AAGG"); + std::vector colors; + colors.push_back(Color(0.0, 0.0, 1.0)); + + MussaRef m(new Mussa); + m->append_sequence("AAAAGGGG"); + m->append_sequence("AAAACCCC"); + m->set_motifs(motifs, colors); + + // do the sequences have the right motifs? + std::vector sequences1(m->sequences()); + QVERIFY(sequences1[0]->get_sequence() == "AAAAGGGG"); + QVERIFY(sequences1[1]->get_sequence() == "AAAACCCC"); + QVERIFY(sequences1[0]->motifs().size() == 1); + QVERIFY(sequences1[1]->motifs().size() == 0); + + // get color + boost::shared_ptr cm(m->colorMapper()); + QVERIFY(cm->lookup("motif", "AAGG") == Color(0.0, 0.0, 1.0)); + + MotifEditor *editor(new MotifEditor(m)); + MotifModel *model(editor->get_model()); + // the AATT motif and the empty motif + QVERIFY(model->size() == 2); + QModelIndex row0_color(model->index(0, MotifModel::ColorCell)); + QModelIndex row0_sequence(model->index(0, MotifModel::SequenceCell)); + QVERIFY(model->data(row0_sequence) == "AAGG"); + + // change contents of cell + model->setData(row0_sequence, QVariant("AACC")); + // this is equivalent to pressing apply + editor->updateAnalysisMotifs(); + QVERIFY(model->data(row0_sequence) == "AACC"); + + // does the mussa analysis have the right data? + std::vector sequences2(m->sequences()); + QVERIFY(sequences2[0]->motifs().size() == 0); + QVERIFY(sequences2[1]->motifs().size() == 1); + QVERIFY(cm->lookup("motif", "AACC") == Color(0.0, 0.0, 1.0)); + QVERIFY(m->colorMapper()->lookup("motif", "AACC") == Color(0.0, 0.0, 1.0)); + QVERIFY(cm->lookup("motif", "AAGG") == Color(0.0, 0.0, 0.0)); + QVERIFY(m->colorMapper()->lookup("motif", "AAGG") == Color(0.0, 0.0, 0.0)); QVERIFY(editor->get_analysis() == m); QVERIFY(editor->get_model() == model);