track_indexes(path)
{
}
-
+
void ConservedPath::clear()
{
score = 0.0;
return true;
}
+vector<bool> ConservedPath::reverseComplimented() const
+{
+ vector<bool> reversed;
+ for (ConservedPath::const_iterator this_itor = begin();
+ this_itor != end();
+ ++this_itor)
+ {
+ if (*this_itor < 0)
+ reversed.push_back(true);
+ else
+ reversed.push_back(false);
+ }
+ return reversed;
+
+}
+
/////////////////////
ExtendedConservedPath::ExtendedConservedPath()
: ConservedPath(),
* that definition may not properly track reverse compliment
*/
bool nextTo(const ConservedPath& next) const;
+ //! indicate which elements of the path are reversed
+ std::vector<bool> reverseComplimented() const;
//! either number of conserved bases or average entropy
double score;
GLuint pair_key_0 = 0;
GLuint pair_key_1 = 0;
- selectedPaths.clear();
- selectedTracks.clear();
+ selected_paths.clear();
+ selected_tracks.clear();
std::cout << "hits = " << hits << std::endl;
ptr = (GLuint *) buffer;
psm_i = path_segments[path_index].find(k);
if (psm_i != path_segments[path_index].end()) {
Segment &seg = psm_i->second;
- selectedPaths.insert(seg.path_ids.begin(), seg.path_ids.end());
+ selected_paths.insert(seg.path_ids.begin(), seg.path_ids.end());
}
// else something else is wrong
} else {
break;
case MussaTrack:
objid = *ptr++; ++consumed_names;
- selectedTracks.insert(objid);
+ selected_tracks.insert(objid);
break;
default:
cout << "unknown type " << objtype << " ";
++pathid;
}
+const set<int>& GlSeqBrowser::selectedPaths() const
+{
+ return selected_paths;
+}
+
void GlSeqBrowser::update_viewport(float center, int new_zoom)
{
float max_width = max_ortho.width();
const Segment &s = psm_i->second;
// need to do something so we can detect our selection
vector<int> selected;
- set_intersection(selectedPaths.begin(), selectedPaths.end(),
+ set_intersection(selected_paths.begin(), selected_paths.end(),
s.path_ids.begin(), s.path_ids.end(),
back_inserter(selected));
if (not s.reversed) {
- if (selectedPaths.size() == 0 or selected.size() > 0) {
+ if (selected_paths.size() == 0 or selected.size() > 0) {
glColor3f(1.0, 0.0, 0.0);
} else {
glColor3f(1.0, 0.8, 0.8);
}
} else {
- if (selectedPaths.size() == 0 or selected.size() > 0) {
+ if (selected_paths.size() == 0 or selected.size() > 0) {
glColor3f(0.0, 0.0, 1.0);
} else {
glColor3f(0.8, 0.8, 1.0);
void clear_links();
//! define a path
void link(const std::vector<int>& path, const std::vector<bool>& isRC, int length);
+ //! returns the index of pathids based on order added by link
+ const std::set<int>& selectedPaths() const;
//! Provide a logical name for a type discriminator for our glName stack
enum FeatureType { MussaTrack, MussaSegment };
//! true if we have a selection
bool selectedMode;
//! indicate which paths are selected
- std::set<int> selectedPaths;
+ std::set<int> selected_paths;
//! which track is selected (it only makes sense to have one track selected).
- std::set<int> selectedTracks;
+ std::set<int> selected_tracks;
};
#endif
BOOST_CHECK_EQUAL( cp.size(), 1 );
}
+// does the reverse compliment test work?
+BOOST_AUTO_TEST_CASE ( conserved_path_reverse_compliment )
+{
+ vector<int> path;
+ path += 3,4,-5,1; // magic from boost assign
+
+ ConservedPath cp1(10, path);
+ vector<bool> reversed = cp1.reverseComplimented();
+
+ BOOST_CHECK_EQUAL( path.size(), reversed.size());
+ vector<int>::iterator path_i = path.begin();
+ vector<bool>::iterator reversed_i = reversed.begin();
+ for(; path_i != path.end() and reversed_i != reversed.end();
+ ++path_i, ++reversed_i)
+ {
+ // if we're less than zero our reversed flag should be true
+ BOOST_CHECK_EQUAL( *path_i < 0, *reversed_i);
+ }
+}
+
BOOST_AUTO_TEST_CASE ( extended_conserved_path_simple )
{
vector<int> path;
{
if (*highlight_i)
{
- ExtendedConservedPath& a_path = *pathz_i;
- selected_paths.push_back(a_path);
+ selected_paths.push_back(*pathz_i);
}
++highlight_i;
}
vector<fltk_motif> *some_motifs)
{
int seq_i;
- list<ExtendedConservedPath >::iterator pathz_i;
analysis_name = name;
seq_num = sq_num;
for(seq_i = 0; seq_i < seq_num; ++seq_i)
raw_sequence.push_back( (*S)[seq_i].get_seq() );
- for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
+ for(list<ExtendedConservedPath >::iterator pathz_i = P.begin();
+ pathz_i != P.end();
+ ++pathz_i)
{
show_aligns.push_back(true);
}
SeqView::draw_match_lines(double ch_width)
{
int i, y_loc;
- list<ExtendedConservedPath >::iterator pathz_i;
int i2, i3;
int x_start, y_start, x_end, y_end;
int window_length, win_i;
align_counter = 0;
- for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
+ for(list<ExtendedConservedPath >::iterator pathz_i = P.begin();
+ pathz_i != P.end();
+ ++pathz_i)
{
if (show_aligns[align_counter])
{
ExtendedConservedPath& a_path = *pathz_i;
window_length = a_path.window_size;
-
// determine which parts of the path are RC relative to first species
- rc_list.clear();
- for(i2 = 0; i2 < a_path.size()-1; i2++)
- {
- if (a_path[i2] < 0)
- rc_list.push_back(true);
- else
- rc_list.push_back(false);
- }
+ rc_list = a_path.reverseComplimented();
// loop over each bp in the conserved region for all sequences
for(win_i = 0; win_i < window_length; win_i++)
for(i = 0; i < seq_num ; i++)
{
//cout << (*pathz_i)[i+1] << endl;
- seq_align_offsets.push_back( abs((*pathz_i)[i+1]) );
+ seq_align_offsets.push_back( abs((*pathz_i).track_indexes[i]) );
// for testing purposes: to see everything in the short test sequences
//seq_align_offsets.push_back(0);
}
vector<int> a_path;
int window_length;
-
cout << "fumish\n";
seq_box->toggle_align(which_align);
seq_box->redraw();
some_menu_data = new menu_align_data_bundle;
some_menu_data->swm_ptr = this;
some_menu_data->which_align = align_number;
- align_id_ostr << (*align_iter)[0] << ": ";
- for(i = 1; i <= seq_num; i++)
- align_id_ostr << (*align_iter)[i] << ", ";
+ align_id_ostr << (*align_iter).window_size << ": ";
+ for(i = 0; i != seq_num; i++)
+ align_id_ostr << (*align_iter).track_indexes[i] << ", ";
align_id_string = align_id_ostr.str();
choose_align_menu->add((const char*)align_id_string.c_str(), 0,
(Fl_Callback *) set_align_cb,
++align_iter;
}
- /*
- show_align_menu->add("f&ee");
- show_align_menu->add("f&ie");
- show_align_menu->add("f&oe");
- show_align_menu->add("f&um");
- */
-
Fl_Button *test_but = new Fl_Button(375, 2, 150, 30, "Toggle Motifs");
test_but->color(FL_WHITE,FL_BLUE);
test_but->box(FL_BORDER_BOX);
Fl::visual(FL_DOUBLE|FL_INDEX);
show();
}
-
-
-
-/*
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 2;
- choose_align_menu->add("f&ie", FL_ALT+'i', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 3;
- choose_align_menu->add("f&oe", FL_ALT+'o', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 4;
- choose_align_menu->add("f&um", FL_ALT+'u', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-*/
-
-
-
-
# Input
HEADERS += mussa_exceptions.hpp \
qui/MussaWindow.hpp \
+ qui/MussaAlignedWindow.hpp \
qui/ThresholdWidget.hpp \
qui/ImageScaler.hpp \
qui/ImageSaveDialog.hpp \
alg/sequence.hpp
SOURCES += mussagl.cpp \
qui/MussaWindow.cpp \
+ qui/MussaAlignedWindow.cpp \
qui/ThresholdWidget.cpp \
qui/ImageScaler.cpp \
qui/ImageSaveDialog.cpp \
--- /dev/null
+#include "qui/MussaAlignedWindow.hpp"
+
+#include <QVBoxLayout>
+
+using namespace std;
+
+MussaAlignedWindow::MussaAlignedWindow(Mussa& m,
+ const set<int>& sel_paths,
+ QWidget *parent)
+ : QWidget(parent),
+ analysis(m),
+ selected_paths(sel_paths)
+
+{
+ browser.setSequences(analysis.sequences(), analysis.colorMapper());
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(&browser);
+ setLayout(layout);
+}
+
--- /dev/null
+#ifndef MUSSA_ALIGNED_WINDOW_H
+#define MUSSA_ALIGNED_WINDOW_H
+
+#include <set>
+
+#include <QWidget>
+#include "alg/mussa.hpp"
+#include "qui/seqbrowser/SequenceBrowserWidget.hpp"
+
+//! Show sequence alignments
+class MussaAlignedWindow : public QWidget
+{
+public:
+ MussaAlignedWindow(Mussa& m, const std::set<int>& sel_paths, QWidget *parent=0);
+
+protected:
+ Mussa &analysis;
+ const std::set<int>& selected_paths;
+
+ SequenceBrowserWidget browser;
+};
+#endif
#include <QWhatsThis>
#include "qui/MussaWindow.hpp"
+#include "qui/MussaAlignedWindow.hpp"
#include "mussa_exceptions.hpp"
#include <iostream>
"You can load motif annotations via "
"'File->Load Motif List' menu option."));
- whatsThisAction = QWhatsThis::createAction(this);
- whatsThisAction->setIcon(QIcon("icons/help.png"));
-
//Save pixel map action
saveBrowserPixmapAction = new QAction(tr("Save to image..."), this);
connect(saveBrowserPixmapAction, (SIGNAL(triggered())),
&browser, SLOT(promptSaveBrowserPixmap()));
saveBrowserPixmapAction->setIcon(QIcon("icons/image2.png"));
+
+ viewMussaAlignmentAction = new QAction(tr("View mussa alignment"), this);
+ connect(viewMussaAlignmentAction, SIGNAL(triggered()),
+ this, SLOT(viewMussaAlignment() ));
+ viewMussaAlignmentAction->setWhatsThis(tr("Create a zoomed in window "
+ "showing alignment of the seqcomp "
+ "defined paths"));
+
+ whatsThisAction = QWhatsThis::createAction(this);
+ whatsThisAction->setIcon(QIcon("icons/help.png"));
+
}
void MussaWindow::setupMainMenu()
newMenu->addAction(closeAction);
newMenu = menuBar()->addMenu(tr("&View"));
+ newMenu->addAction(viewMussaAlignmentAction);
newMenu->addAction(showMussaViewToolbarAction);
newMenu = menuBar()->addMenu(tr("&Help"));
QMessageBox::warning(this, QObject::tr("mussa"), QObject::tr("Not implemented yet"));
}
+void MussaWindow::viewMussaAlignment()
+{
+ const set<int>& selected_paths = browser.selectedPaths();
+ if (selected_paths.size() == 0 ) {
+ QMessageBox::warning(this,
+ QObject::tr("mussa"),
+ QObject::tr("you should probably select some paths "
+ "first"));
+ } else {
+ QWidget *ma_win = new MussaAlignedWindow(*analysis, selected_paths);
+ ma_win->show();
+ }
+}
+
void MussaWindow::updateAnalysis()
{
cout << "analysis updated" << endl;
void setSoftThreshold(int thres);
void showMussaToolbar();
+
+ //! open new window showing our alignment
+ void viewMussaAlignment();
protected:
Mussa *analysis;
QAction *saveMotifListAction;
QAction *showMussaViewToolbarAction;
QAction *toggleMotifsAction;
- QAction *whatsThisAction;
QAction *saveBrowserPixmapAction;
+ QAction *whatsThisAction;
+ QAction *viewMussaAlignmentAction;
//! initialze the actions
void setupActions();
#include <vector>
#include <GL/gl.h>
+#include <set>
+
#include "alg/mussa.hpp"
#include "alg/glsequence.hpp"
#include "alg/glseqbrowser.hpp"
scrollable_browser.browser().link(path, isRC, length);
}
+const std::set<int> SequenceBrowserWidget::selectedPaths() const
+{
+ return scrollable_browser.browser().selectedPaths();
+}
+
/* This could theoretically be pushed down to some set
* of signals and slots connecting SequenceDescriptions and
* some signal emitted by the browser's viewportChanged code
void clear_links();
//! set per species links
void link(const std::vector<int> &path, const std::vector<bool>& isRC, int length);
+ // return set of pathids defined by order of link calls
+ const std::set<int> selectedPaths() const;
public slots:
//! set the zoom level of our browser