13 #include <boost/filesystem/path.hpp>
14 namespace fs = boost::filesystem;
16 //#include "qui/mussa_setup_dialog/SequenceSetupWidget.hpp"
17 #include "qui/mussa_setup_dialog/SequenceSetupFrame.hpp"
18 #include "qui/mussa_setup_dialog/MussaSetupWidget.hpp"
19 #include "qui/mussa_setup_dialog/SetupInfo.hpp"
20 #include "alg/mussa.hpp"
21 #include "mussa_exceptions.hpp"
23 MussaSetupWidget::MussaSetupWidget(QWidget *parent)
25 createPushButton(tr("Create")),
26 cancelPushButton(tr("Cancel")),
31 QLabel *analysisNameLabel = new QLabel(tr("Analysis Name"));
32 analysisNameLabel->setBuddy(&analysisNameLineEdit);
35 QLabel *windowLabel = new QLabel(tr("Window (nt)"));
36 windowLabel->setBuddy(&windowLineEdit);
39 QLabel *thresholdLabel = new QLabel(tr("Threshold (nt)"));
40 thresholdLabel->setBuddy(&thresholdLineEdit);
42 // Number of sequences
43 QLabel *numOfSequencesLabel = new QLabel(tr("Number of sequences"));
44 numOfSequencesLabel->setBuddy(&numOfSequencesSpinBox);
45 numOfSequencesSpinBox.setMinimum(1);
47 //Sequence setup frame
48 seqSetupFrame = new SequenceSetupFrame;
50 connect(&numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
51 seqSetupFrame, SLOT(changeSequenceCount(int)));
53 numOfSequencesSpinBox.setValue(2);
55 // Create Experiment Button
56 connect(&createPushButton, SIGNAL(pressed()),
57 this, SLOT(mussaCreatePushed()));
60 connect(&cancelPushButton, SIGNAL(pressed()),
61 this, SLOT(mussaCancelPushed()));
64 QHBoxLayout *row1Layout = new QHBoxLayout;
65 QHBoxLayout *row2Layout = new QHBoxLayout;
66 QVBoxLayout *mainLayout = new QVBoxLayout;
67 QHBoxLayout *buttonLayout = new QHBoxLayout;
69 row1Layout->addWidget(analysisNameLabel);
70 row1Layout->addWidget(&analysisNameLineEdit);
72 row2Layout->addWidget(windowLabel);
73 row2Layout->addWidget(&windowLineEdit);
74 row2Layout->addWidget(thresholdLabel);
75 row2Layout->addWidget(&thresholdLineEdit);
76 row2Layout->addWidget(numOfSequencesLabel);
77 row2Layout->addWidget(&numOfSequencesSpinBox);
79 buttonLayout->addWidget(&createPushButton);
80 buttonLayout->addWidget(&cancelPushButton);
82 mainLayout->addLayout(row1Layout);
83 mainLayout->addLayout(row2Layout);
84 mainLayout->addWidget(seqSetupFrame);
85 mainLayout->addLayout(buttonLayout);
86 setLayout(mainLayout);
90 void MussaSetupWidget::mussaCreatePushed()
92 emit createButtonPushed();
95 void MussaSetupWidget::mussaCancelPushed()
97 emit cancelButtonPushed();
100 Mussa* MussaSetupWidget::getMussaObject()
102 Mussa *mussa = new Mussa;
108 list<SetupInfo *> setupInfoList = seqSetupFrame->getSetupInfo();
110 for (list<SetupInfo *>::iterator setup_item = setupInfoList.begin();
111 setup_item != setupInfoList.end();
114 std::string seqNative = (*setup_item)->getSeqFile();
115 std::string annotNative = (*setup_item)->getAnnotFile();
116 fastaIndex = (*setup_item)->getFastaIndex();
117 start = (*setup_item)->getSubSeqStart();
118 end = (*setup_item)->getSubSeqEnd();
120 fs::path seqFile(seqNative, fs::native);
121 fs::path annotFile(annotNative, fs::native);
122 mussa->load_sequence(seqFile, annotFile, fastaIndex, start, end);
124 setupInfoList.clear();
126 int win_size = windowLineEdit.text().toInt();
127 int threshold = thresholdLineEdit.text().toInt();
128 if (win_size == 0 or threshold == 0) {
129 throw mussa_load_error("must set analysis parameters");
131 mussa->set_window(win_size);
132 mussa->set_threshold(threshold);
133 mussa->set_analysis_mode(Mussa::TransitiveNway);
134 //mussa->set_entropy(0); // might want to add this at some point
141 //MussaSetupWidget::MussaSetupWidget(const MussaSetupWidget& msw)
142 // : analysisNameLineEdit(msw.analysisNameLineEdit),
143 // windowLineEdit(msw.windowLineEdit),
144 // thresholdLineEdit(msw.thresholdLineEdit),
145 // numOfSequencesLineEdit(msw.numOfSequencesLineEdit),
146 // seqSetupFrame(msw.seqSetupFrame)