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 analysisNameLineEdit(new QLineEdit),
26 windowEdit(new QSpinBox),
27 thresholdEdit(new QSpinBox),
28 numOfSequencesSpinBox(new QSpinBox),
29 createPushButton(new QPushButton(tr("Create"))),
30 cancelPushButton(new QPushButton(tr("Cancel"))),
35 QLabel *analysisNameLabel = new QLabel(tr("Analysis Name"));
36 analysisNameLabel->setBuddy(analysisNameLineEdit);
39 windowEdit->setMinimum(1);
40 windowEdit->setValue(30);
41 QLabel *windowLabel = new QLabel(tr("Window (nt)"));
42 windowLabel->setBuddy(windowEdit);
45 thresholdEdit->setMinimum(1);
46 thresholdEdit->setMaximum(windowEdit->value());
47 thresholdEdit->setValue(21);
48 QLabel *thresholdLabel = new QLabel(tr("Threshold (nt)"));
49 thresholdLabel->setBuddy(thresholdEdit);
50 connect(windowEdit, SIGNAL(valueChanged(int)),
51 this, SLOT(updateThreshold(int)));
53 // Number of sequences
54 QLabel *numOfSequencesLabel = new QLabel(tr("Number of sequences"));
55 numOfSequencesLabel->setBuddy(numOfSequencesSpinBox);
56 numOfSequencesSpinBox->setMinimum(1);
58 //Sequence setup frame
59 seqSetupFrame = new SequenceSetupFrame;
61 connect(numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
62 seqSetupFrame, SLOT(changeSequenceCount(int)));
64 numOfSequencesSpinBox->setValue(2);
66 // Create Experiment Button
67 connect(createPushButton, SIGNAL(pressed()),
68 this, SLOT(mussaCreatePushed()));
71 connect(cancelPushButton, SIGNAL(pressed()),
72 this, SLOT(mussaCancelPushed()));
75 QHBoxLayout *row1Layout = new QHBoxLayout;
76 QHBoxLayout *row2Layout = new QHBoxLayout;
77 QVBoxLayout *mainLayout = new QVBoxLayout;
78 QHBoxLayout *buttonLayout = new QHBoxLayout;
80 row1Layout->addWidget(analysisNameLabel);
81 row1Layout->addWidget(analysisNameLineEdit);
83 row2Layout->addWidget(thresholdLabel);
84 row2Layout->addWidget(thresholdEdit);
85 row2Layout->addWidget(windowLabel);
86 row2Layout->addWidget(windowEdit);
87 row2Layout->addWidget(numOfSequencesLabel);
88 row2Layout->addWidget(numOfSequencesSpinBox);
90 buttonLayout->addStretch(1);
91 buttonLayout->addWidget(createPushButton);
92 buttonLayout->addWidget(cancelPushButton);
94 mainLayout->addLayout(row1Layout);
95 mainLayout->addLayout(row2Layout);
96 mainLayout->addWidget(seqSetupFrame);
97 mainLayout->addLayout(buttonLayout);
98 setLayout(mainLayout);
101 void MussaSetupWidget::mussaCreatePushed()
103 emit createButtonPushed();
106 void MussaSetupWidget::mussaCancelPushed()
108 emit cancelButtonPushed();
111 void MussaSetupWidget::updateThreshold(int new_threshold)
113 thresholdEdit->setMaximum(new_threshold);
116 MussaRef MussaSetupWidget::getMussaObject()
118 MussaRef mussa = Mussa::init();
124 list<SetupInfo *> setupInfoList = seqSetupFrame->getSetupInfo();
126 for (list<SetupInfo *>::reverse_iterator setup_item = setupInfoList.rbegin();
127 setup_item != setupInfoList.rend();
130 std::string seqName = (*setup_item)->getName();
131 std::string seqNative = (*setup_item)->getSeqFile();
132 std::string annotNative = (*setup_item)->getAnnotFile();
133 fastaIndex = (*setup_item)->getFastaIndex();
134 start = (*setup_item)->getSubSeqStart();
135 end = (*setup_item)->getSubSeqEnd();
137 fs::path seqFile(seqNative, fs::native);
138 fs::path annotFile(annotNative, fs::native);
139 mussa->load_sequence(seqFile, annotFile, fastaIndex, start, end, &seqName);
141 setupInfoList.clear();
143 int win_size = windowEdit->value();
144 int threshold = thresholdEdit->value();
145 std::string name = analysisNameLineEdit->text().toStdString();
146 if (win_size == 0 or threshold == 0) {
147 throw mussa_load_error("must set analysis parameters");
149 mussa->set_name(name);
150 mussa->set_window(win_size);
151 mussa->set_threshold(threshold);
152 mussa->set_analysis_mode(Mussa::TransitiveNway);
153 //mussa->set_entropy(0); // might want to add this at some point