updateAnalysis();
}
+void MussaWindow::setAnalysis(Mussa *new_analysis)
+{
+ if (new_analysis != 0) {
+ // only switch mussas if we loaded without error
+ delete analysis;
+ analysis = new_analysis;
+ updateAnalysis();
+ }
+}
+
void MussaWindow::setupActions()
{
// we really don't want to run this more than once.
msg += (char *)glGetString(GL_VERSION);
msg += "\n";
QMessageBox::about(this, tr("About mussa"), msg);
- /*
- tr("Welcome to Multiple Species Sequence Analysis\n"
- "(c) 2005-2006 California Institute of Technology\n"
- "Tristan De Buysscher, Diane Trout\n"));
- */
-
}
void MussaWindow::createNewAnalysis()
{
MussaSetupDialog *msd = new MussaSetupDialog(this);
- if (msd->exec())
- {
- std::cout << "New mussa exp. defined!\n";
- Mussa *m = 0;
- m = msd->getMussa();
- std::cout << " Mussa Object at: " << m << "\n";
- delete m;
- }
- else
- {
- std::cout << "New mussa exp. aborted!\n";
+ try {
+ if (msd->exec()) {
+ Mussa *m = 0;
+ m = msd->getMussa();
+ setAnalysis(m);
+ } else {
+ std::cout << "New mussa exp. aborted!\n";
+ }
+ } catch(mussa_error e) {
+ QString msg(e.what());
+ QMessageBox::warning(this, tr("Create New Analysis"), msg);
}
delete msd;
}
Mussa *m = new Mussa;
m->load_mupa_file(mupa_path.toStdString());
m->analyze(0, 0, Mussa::TransitiveNway, 0.0);
- // only switch mussas if we loaded without error
- delete analysis;
- analysis = m;
- updateAnalysis();
+ setAnalysis(m);
} catch (mussa_load_error e) {
QString msg("Unable to load ");
msg += mupa_path;
Mussa *m = new Mussa;
m->load(muway_dir.toStdString());
// only switch mussas if we loaded without error
- delete analysis;
- analysis = m;
- updateAnalysis();
+ setAnalysis(m);
} catch (mussa_load_error e) {
QString msg("Unable to load ");
msg += muway_dir;
#include <list>
+using namespace std;
+
//#include "qui/mussa_setup_dialog/SequenceSetupWidget.hpp"
#include "qui/mussa_setup_dialog/SequenceSetupFrame.hpp"
#include "qui/mussa_setup_dialog/MussaSetupWidget.hpp"
#include "qui/mussa_setup_dialog/SetupInfo.hpp"
#include "alg/mussa.hpp"
+#include "mussa_exceptions.hpp"
MussaSetupWidget::MussaSetupWidget(QWidget *parent)
: QWidget(parent),
- analysisNameLineEdit(0),
- windowLineEdit(0),
- thresholdLineEdit(0),
- numOfSequencesSpinBox(0),
- createPushButton(0),
- cancelPushButton(0),
+ createPushButton(tr("Create")),
+ cancelPushButton(tr("Cancel")),
seqSetupFrame(0)
{
// Analysis name
- analysisNameLineEdit = new QLineEdit;
QLabel *analysisNameLabel = new QLabel(tr("Analysis Name"));
- analysisNameLabel->setBuddy(analysisNameLineEdit);
+ analysisNameLabel->setBuddy(&analysisNameLineEdit);
// Window
- windowLineEdit = new QLineEdit;
QLabel *windowLabel = new QLabel(tr("Window"));
- windowLabel->setBuddy(windowLineEdit);
+ windowLabel->setBuddy(&windowLineEdit);
// Threshold
- thresholdLineEdit = new QLineEdit;
QLabel *thresholdLabel = new QLabel(tr("Threshold"));
- thresholdLabel->setBuddy(thresholdLineEdit);
+ thresholdLabel->setBuddy(&thresholdLineEdit);
// Number of sequences
- numOfSequencesSpinBox = new QSpinBox;
QLabel *numOfSequencesLabel = new QLabel(tr("Number of sequences"));
- numOfSequencesLabel->setBuddy(numOfSequencesSpinBox);
- numOfSequencesSpinBox->setMinimum(1);
-
+ numOfSequencesLabel->setBuddy(&numOfSequencesSpinBox);
+ numOfSequencesSpinBox.setMinimum(1);
//Sequence setup frame
seqSetupFrame = new SequenceSetupFrame;
- connect(numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
+ connect(&numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
seqSetupFrame, SLOT(changeSequenceCount(int)));
- numOfSequencesSpinBox->setValue(1);
+ numOfSequencesSpinBox.setValue(2);
// Create Experiment Button
- createPushButton = new QPushButton(tr("Create"));
- connect(createPushButton, SIGNAL(pressed()),
+ connect(&createPushButton, SIGNAL(pressed()),
this, SLOT(mussaCreatePushed()));
// Cancle Button
- cancelPushButton = new QPushButton(tr("Cancel"));
- connect(cancelPushButton, SIGNAL(pressed()),
+ connect(&cancelPushButton, SIGNAL(pressed()),
this, SLOT(mussaCancelPushed()));
// LAYOUT
QHBoxLayout *buttonLayout = new QHBoxLayout;
row1Layout->addWidget(analysisNameLabel);
- row1Layout->addWidget(analysisNameLineEdit);
+ row1Layout->addWidget(&analysisNameLineEdit);
row2Layout->addWidget(windowLabel);
- row2Layout->addWidget(windowLineEdit);
+ row2Layout->addWidget(&windowLineEdit);
row2Layout->addWidget(thresholdLabel);
- row2Layout->addWidget(thresholdLineEdit);
+ row2Layout->addWidget(&thresholdLineEdit);
row2Layout->addWidget(numOfSequencesLabel);
- row2Layout->addWidget(numOfSequencesSpinBox);
+ row2Layout->addWidget(&numOfSequencesSpinBox);
- buttonLayout->addWidget(createPushButton);
- buttonLayout->addWidget(cancelPushButton);
+ buttonLayout->addWidget(&createPushButton);
+ buttonLayout->addWidget(&cancelPushButton);
mainLayout->addLayout(row1Layout);
mainLayout->addLayout(row2Layout);
Mussa* MussaSetupWidget::getMussaObject()
{
Mussa *mussa = new Mussa;
-
-
std::string seqFile;
std::string annotFile;
int start;
int end;
- std::list<SetupInfo *> setupInfoList = seqSetupFrame->getSetupInfo();
+ list<SetupInfo *> setupInfoList = seqSetupFrame->getSetupInfo();
- const int count = setupInfoList.size();
-
- SetupInfo *setupInfo = 0;
- for (int i=0; i < count; i++)
+ for (list<SetupInfo *>::iterator setup_item = setupInfoList.begin();
+ setup_item != setupInfoList.end();
+ ++setup_item)
{
- setupInfo = setupInfoList.back();
- setupInfoList.pop_back();
-
- seqFile = setupInfo->getSeqFile();
- annotFile = setupInfo->getAnnotFile();
- fastaIndex = setupInfo->getFastaIndex();
- start = setupInfo->getSubSeqStart();
- end = setupInfo->getSubSeqEnd();
-
+ seqFile = (*setup_item)->getSeqFile();
+ annotFile = (*setup_item)->getAnnotFile();
+ fastaIndex = (*setup_item)->getFastaIndex();
+ start = (*setup_item)->getSubSeqStart();
+ end = (*setup_item)->getSubSeqEnd();
+
mussa->load_sequence(seqFile, annotFile, fastaIndex, start, end);
- delete setupInfo;
}
-
- mussa->analyze(0, 0, Mussa::TransitiveNway, 0.0);
+ setupInfoList.clear();
+
+ int win_size = windowLineEdit.text().toInt();
+ int threshold = thresholdLineEdit.text().toInt();
+ if (win_size == 0 or threshold == 0) {
+ throw mussa_load_error("must set analysis parameters");
+ } else {
+ mussa->analyze(win_size, threshold, Mussa::TransitiveNway, 0.0);
+ }
return mussa;
}