| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
#include <assert.h> |
|---|
| 17 |
#include "ParsedPercentPairwiseAnalysis.hh" |
|---|
| 18 |
#include "PercentThresholdSlider.hh" |
|---|
| 19 |
#include "MappingView.hh" |
|---|
| 20 |
#include "AlignmentCloseupView.hh" |
|---|
| 21 |
|
|---|
| 22 |
#define DEFAULT_THRESHOLD 50 |
|---|
| 23 |
|
|---|
| 24 |
#include <FL/Fl_Pack.H> |
|---|
| 25 |
#include <FL/Fl_Button.H> |
|---|
| 26 |
#include <FL/Fl_Check_Button.H> |
|---|
| 27 |
|
|---|
| 28 |
#include "TextLabel.hh" |
|---|
| 29 |
#include "ColorPatch.hh" |
|---|
| 30 |
|
|---|
| 31 |
#include "PercentFeaturesContainer.hh" |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
ParsedPercentPairwiseAnalysis::ParsedPercentPairwiseAnalysis(iff::FeatureList * fl, gui::MappingView * view) |
|---|
| 36 |
{ |
|---|
| 37 |
name = fl->name(); |
|---|
| 38 |
_view = view; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
std::vector<gui::PercentFeature*> new_features; |
|---|
| 45 |
|
|---|
| 46 |
for (unsigned int j = 0; j < fl->n_features(); j++) { |
|---|
| 47 |
iff::Feature * iff_f = fl->get(j); |
|---|
| 48 |
gui::PercentFeature * f = new gui::PercentFeature(iff_f->start(), |
|---|
| 49 |
iff_f->end(), |
|---|
| 50 |
iff_f->orientation(), |
|---|
| 51 |
iff_f->score()); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
f->add_information(iff_f->information()); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
iff::Feature * other_iff_f = iff_f->pair_match(); |
|---|
| 58 |
f->other(other_iff_f->start(), other_iff_f->end()); |
|---|
| 59 |
|
|---|
| 60 |
std::string a, b; |
|---|
| 61 |
a = iff_f->get_aln(); |
|---|
| 62 |
b = other_iff_f->get_aln(); |
|---|
| 63 |
if (a.length() && b.length()) { |
|---|
| 64 |
assert(a.length() == b.length()); |
|---|
| 65 |
|
|---|
| 66 |
f->set_alignment(a, b); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
new_features.push_back(f); |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
_percent_features = new gui::PercentFeaturesContainer(new_features, |
|---|
| 73 |
DEFAULT_THRESHOLD); |
|---|
| 74 |
|
|---|
| 75 |
_map_cont = new gui::PercentMappingContainer(_percent_features); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
static void map_show_toggle_cb(Fl_Widget * w, void * p) |
|---|
| 79 |
{ |
|---|
| 80 |
gui::MappingContainer * map = (gui::MappingContainer *) p; |
|---|
| 81 |
Fl_Button * b = (Fl_Button *) w; |
|---|
| 82 |
|
|---|
| 83 |
map->visible(b->value()); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
class alignment_closeup_passthru { |
|---|
| 88 |
public: |
|---|
| 89 |
const gui::PercentMappingContainer * map; |
|---|
| 90 |
const gui::MappingView * view; |
|---|
| 91 |
const std::string name; |
|---|
| 92 |
alignment_closeup_passthru(gui::PercentMappingContainer * m, |
|---|
| 93 |
gui::MappingView * v, |
|---|
| 94 |
std::string n) |
|---|
| 95 |
: map(m), view(v), name(n) { }; |
|---|
| 96 |
}; |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
static void alignment_closeup_cb(Fl_Widget * w, void * p) |
|---|
| 101 |
{ |
|---|
| 102 |
alignment_closeup_passthru * container = (alignment_closeup_passthru *)p; |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
const gui::MappingView * view = container->view; |
|---|
| 106 |
const gui::PercentMappingContainer * map = container->map; |
|---|
| 107 |
const std::string name = container->name; |
|---|
| 108 |
|
|---|
| 109 |
gui::SimpleMappingContainer * simple; |
|---|
| 110 |
simple = new gui::SimpleMappingContainer(map->get_features_container()->copy_me()); |
|---|
| 111 |
|
|---|
| 112 |
AlignmentCloseupView * new_view = new \ |
|---|
| 113 |
AlignmentCloseupView(simple, view, 600, 600); |
|---|
| 114 |
|
|---|
| 115 |
std::string label = "Close-up of pairwise matches from '" + name + "'"; |
|---|
| 116 |
new_view->label(label.c_str()); |
|---|
| 117 |
|
|---|
| 118 |
new_view->show(); |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
void ParsedPercentPairwiseAnalysis::add_control_panel(Fl_Group * container, |
|---|
| 122 |
int &x, int &y, |
|---|
| 123 |
const int width) |
|---|
| 124 |
{ |
|---|
| 125 |
const unsigned int height = 30; |
|---|
| 126 |
const int start_y = y; |
|---|
| 127 |
|
|---|
| 128 |
gui::TextLabel * label = new gui::TextLabel(x + 5, y + 5, width - 10, height, |
|---|
| 129 |
name.c_str()); |
|---|
| 130 |
label->bold(true); |
|---|
| 131 |
label->box(FL_DOWN_BOX); |
|---|
| 132 |
y += height + 10; |
|---|
| 133 |
|
|---|
| 134 |
gui::PercentThresholdSlider * slider; |
|---|
| 135 |
slider = new gui::PercentThresholdSlider(x + 5, y + 5, width - 10, height, _percent_features->min(), _map_cont); |
|---|
| 136 |
|
|---|
| 137 |
y += height + 10; |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
Fl_Button * b = NULL; |
|---|
| 144 |
if (_percent_features->contains_alignments()) { |
|---|
| 145 |
b = new Fl_Button(x + 15, y + 5, 120, 25, "View alignments..."); |
|---|
| 146 |
|
|---|
| 147 |
b->color(FL_WHITE); |
|---|
| 148 |
b->labelsize(12); |
|---|
| 149 |
b->callback(alignment_closeup_cb, |
|---|
| 150 |
new alignment_closeup_passthru(_map_cont, _view, name)); |
|---|
| 151 |
y += height + 10; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
Fl_Pack * p = new Fl_Pack(x + 5, y + 5, width, height); |
|---|
| 155 |
|
|---|
| 156 |
Fl_Check_Button * check_b = new Fl_Check_Button(x + 5, y + 5, width, height); |
|---|
| 157 |
check_b->callback(map_show_toggle_cb, _map_cont); |
|---|
| 158 |
check_b->label("show comparison"); |
|---|
| 159 |
check_b->value(1); |
|---|
| 160 |
p->add(check_b); |
|---|
| 161 |
|
|---|
| 162 |
y += height + 10; |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
gui::TextLabel * cl = new gui::TextLabel(x + 5, |
|---|
| 166 |
y + 5, (width - 10) / 2, |
|---|
| 167 |
30, "Set color:"); |
|---|
| 168 |
gui::ColorPatch * c = new gui::ColorPatch(x + 5 + (width - 10) / 2, |
|---|
| 169 |
y + 5, (width - 10) / 2, |
|---|
| 170 |
height, |
|---|
| 171 |
_map_cont->color()); |
|---|
| 172 |
|
|---|
| 173 |
gui::ColorChangeListener_MappingContainer * listener = new |
|---|
| 174 |
gui::ColorChangeListener_MappingContainer(_map_cont); |
|---|
| 175 |
|
|---|
| 176 |
c->add_change_listener(listener); |
|---|
| 177 |
|
|---|
| 178 |
y += height + 10; |
|---|
| 179 |
|
|---|
| 180 |
Fl_Box * surround = new Fl_Box(x, start_y, width, y - start_y); |
|---|
| 181 |
surround->box(FL_DOWN_BOX); |
|---|
| 182 |
surround->color(FL_WHITE); |
|---|
| 183 |
container->add(surround); |
|---|
| 184 |
|
|---|
| 185 |
container->add(label); |
|---|
| 186 |
container->add(slider); |
|---|
| 187 |
if (b) { |
|---|
| 188 |
container->add(b); |
|---|
| 189 |
} |
|---|
| 190 |
container->add(p); |
|---|
| 191 |
container->add(cl); |
|---|
| 192 |
container->add(c); |
|---|
| 193 |
} |
|---|