void seqcomp();
};
+//! provide a simple name to point to our Mussa shared_ptr
+typedef boost::shared_ptr<Mussa> MussaRef;
#endif
#include "alg/parse_options.hpp"
MussaOptions::MussaOptions()
- : analysis(0),
- useGUI(true),
+ : useGUI(true),
runAsPythonInterpeter(false)
{
}
std::cout << options << std::endl;
return;
}
-
- opts.analysis = new Mussa();
+
+ MussaRef new_mussa(new Mussa);
+ opts.analysis = new_mussa;
// currently we can only have one analysis loaded, so
// running trumps viewing.
#define _PARSE_OPTIONS_H_
#include <string>
-
-class Mussa;
+#include <alg/mussa.hpp>
//! collect information about runtime options
struct MussaOptions
MussaOptions();
//! pointer to our analysis, if its null, feel free to die
- Mussa *analysis;
+ MussaRef analysis;
//! Location of documentation
std::string doc_dir;
//! should we use the gui?
#include <iostream>
using namespace std;
-MussaAlignedWindow::MussaAlignedWindow(Mussa& m,
- const set<int>& sel_paths,
+MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
+ const set<int>& sel_paths,
QWidget *parent)
: QMainWindow(parent),
analysis(m),
alignTB(0)
{
setupActions();
- browser.setSequences(analysis.sequences(), analysis.colorMapper());
- setSelectedPaths(m, sel_paths);
+ browser.setSequences(analysis->sequences(), analysis->colorMapper());
+ setSelectedPaths(analysis, sel_paths);
setAlignment(0);
double zoom_level = browser.zoomToSequence();
}
-void MussaAlignedWindow::setSelectedPaths(Mussa &m, const set<int>& sel_paths)
+void MussaAlignedWindow::setSelectedPaths(MussaRef m, const set<int>& sel_paths)
{
// sets are sorted
set<int>::iterator sel_i = sel_paths.begin();
- list<ConservedPath>::const_iterator path_i = m.paths().refined_pathz.begin();
- list<ConservedPath>::const_iterator path_end = m.paths().refined_pathz.end();
- size_t path_size = m.paths().refined_pathz.size();
+ list<ConservedPath>::const_iterator path_i = m->paths().refined_pathz.begin();
+ list<ConservedPath>::const_iterator path_end = m->paths().refined_pathz.end();
+ size_t path_size = m->paths().refined_pathz.size();
size_t pathid=0;
selected_paths.reserve(sel_paths.size());
if (view_paths[count])
filtered_paths.push_back(*path_i);
}
- analysis.createLocalAlignment(filtered_paths.begin(),
- filtered_paths.end(),
- result,
- reversed);
+ analysis->createLocalAlignment(filtered_paths.begin(),
+ filtered_paths.end(),
+ result,
+ reversed);
list<ConservedPath::path_type>::const_iterator result_i = result.begin();
list<vector<bool> >::const_iterator reversed_i = reversed.begin();
#include <set>
+#include <boost/shared_ptr.hpp>
+
#include <QMainWindow>
#include <QMenu>
#include <QToolBar>
public:
//! construct an aligned window for an analysis and selected paths
- MussaAlignedWindow(Mussa&, const std::set<int>&, QWidget *parent=0);
+ /*! \param analysis is a shared_ptr to a mussa analysis
+ * \param paths is a set of "paths" AKA integer offsets into the sequences stored in mussa
+ * \param parent is the typical Qt pointer to a parent widget
+ */
+ MussaAlignedWindow(MussaRef analysis, const std::set<int>& paths, QWidget *parent=0);
public slots:
//! use selected_paths[pathid] to set the starting position of our sequence
protected:
// figure out what Alignments we have (needed for setupAlignmentMenus)
- void setSelectedPaths(Mussa &m, const std::set<int>& sel_paths);
+ void setSelectedPaths(MussaRef m, const std::set<int>& sel_paths);
// create our cations
void setupActions();
// create our menus
void setupAlignmentMenus();
void computeMatchLines();
- Mussa& analysis;
+ MussaRef analysis;
//std::vector<Sequence> sequences;
//const std::set<int>& selected_paths;
std::vector<ConservedPath> selected_paths;
using namespace std;
-MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
+MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
QMainWindow(parent),
analysis(analysis_),
default_dir(QDir::home().absolutePath().toStdString(), fs::native),
addToolBar(mussaViewTB);
statusBar()->showMessage("Welcome to mussa", 2000);
- connect(analysis, SIGNAL(progress(const std::string&, int, int)),
- this, SLOT(updateProgress(const std::string&, int, int)));
+ // FIXME: we should start refactoring the connect call to updateAnalysis or something
+ if (analysis) {
+ connect(analysis.get(), SIGNAL(progress(const std::string&, int, int)),
+ this, SLOT(updateProgress(const std::string&, int, int)));
+ }
updateTitle();
updateAnalysis();
}
-void MussaWindow::setAnalysis(Mussa *new_analysis)
+void MussaWindow::setAnalysis(MussaRef new_analysis)
{
if (new_analysis != 0) {
// only switch mussas if we loaded without error
clear();
- delete analysis;
- analysis = new_analysis;
+ analysis.swap(new_analysis);
updateTitle();
updateAnalysis();
}
if (not isClearingAnalysisSafe()) return;
if (setup_analysis_dialog->exec()) {
- Mussa *m = 0;
- m = setup_analysis_dialog->getMussa();
- setAnalysis(m);
+ setAnalysis(setup_analysis_dialog->getMussa());
}
} catch(mussa_error e) {
QString msg(e.what());
// but this should work for the moment.
if (not isClearingAnalysisSafe()) return;
- Mussa *m = new Mussa;
+ MussaRef m(new Mussa);
fs::path converted_path(mupa_path.toStdString(), fs::native);
- connect(m, SIGNAL(progress(const std::string&, int, int)),
+ connect(m.get(), SIGNAL(progress(const std::string&, int, int)),
this, SLOT(updateProgress(const std::string&, int, int)));
m->load_mupa_file(converted_path);
m->analyze();
// but this should work for the moment.
if (not isClearingAnalysisSafe()) return;
- Mussa *m = new Mussa;
+ MussaRef m(new Mussa);
fs::path converted_path(muway_dir.toStdString(), fs::native);
- connect(m, SIGNAL(progress(const std::string&, int, int)),
+ connect(m.get(), SIGNAL(progress(const std::string&, int, int)),
this, SLOT(updateProgress(const std::string&, int, int)));
m->load(converted_path);
// only switch mussas if we loaded without error
void MussaWindow::newMussaWindow()
{
- Mussa *a = new Mussa();
+ MussaRef a(new Mussa);
MussaWindow *win = new MussaWindow(a);
win->default_dir = default_dir;
win->show();
"first"));
} else {
boost::shared_ptr<MussaAlignedWindow> ma_win(
- new MussaAlignedWindow(*analysis, selected_paths)
+ new MussaAlignedWindow(analysis, selected_paths)
);
aligned_windows.push_back(ma_win);
Q_OBJECT
public:
- MussaWindow(Mussa* analysis=0, QWidget *parent=0);
+ MussaWindow(MussaRef analysis=0, QWidget *parent=0);
//! reset any attached window
void clear();
//! switch to a new analysis
- void setAnalysis(Mussa *new_analysis);
+ void setAnalysis(MussaRef new_analysis);
//! ask the user what to do if we're going to lose data
//! returns true if getting rid of this analysis is safe
void changedAnnotations();
protected:
- //! reference to our analysis
- Mussa *analysis;
+ //! shared_ptr to our analysis
+ MussaRef analysis;
//! the default directory we should loand and save from
boost::filesystem::path default_dir;
std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
"empty model now.");
}
- std::auto_ptr<Mussa> m(new Mussa);
-
+ MussaRef m(new Mussa);
+
for(SequenceLocationModel::iterator itor = model.begin();
itor != model.end();
++itor)
m->set_window(window->value());
m->set_threshold(threshold->value());
m->analyze();
- MussaWindow *mw = new MussaWindow(m.get());
+ MussaWindow *mw = new MussaWindow(m);
mw->show();
model.clear();
hide();
using namespace std;
-MotifEditor::MotifEditor(Mussa *m, QWidget *parent)
+MotifEditor::MotifEditor(MussaRef m, QWidget *parent)
: QWidget(parent),
analysis(m),
editor_layout(new QVBoxLayout(parent)),
Q_OBJECT
public:
- MotifEditor(Mussa* m, QWidget *parent=0);
+ MotifEditor(MussaRef m, QWidget *parent=0);
//! update our window title
void updateTitle();
void changedMotifs();
private:
- Mussa* analysis;
+ MussaRef analysis;
QPushButton *applyButton;
QVBoxLayout *editor_layout;
done(0);
}
-Mussa* MussaSetupDialog::getMussa()
+MussaRef MussaSetupDialog::getMussa()
{
return setupWidget->getMussaObject();
}
#include <QDialog>
#include <QWidget>
+#include "alg/mussa.hpp"
+
class MussaSetupWidget;
-class Mussa;
+
class MussaSetupDialog : public QDialog
{
public:
MussaSetupDialog(QWidget *parent = 0, Qt::WFlags f = 0);
- Mussa* getMussa();
+ MussaRef getMussa();
public slots:
void accept();
emit cancelButtonPushed();
}
-Mussa* MussaSetupWidget::getMussaObject()
+MussaRef MussaSetupWidget::getMussaObject()
{
- Mussa *mussa = new Mussa;
+ MussaRef mussa(new Mussa);
int fastaIndex;
int start;
class SequenceSetupFrame;
-class Mussa;
+#include "alg/mussa.hpp"
class MussaSetupWidget : public QWidget
{
MussaSetupWidget(QWidget *parent = 0);
// MussaSetupWidget(const MussaSetupWidget&);
- Mussa* getMussaObject();
+ MussaRef getMussaObject();
signals:
void createButtonPushed();