8 #include "qui/mussa_setup_dialog/SequenceSetupWidget.hpp"
9 #include "qui/mussa_setup_dialog/SequenceSetupFrame.hpp"
13 SequenceSetupWidget::SequenceSetupWidget(SequenceSetupFrame *setupFrame_,
19 fastaIndexLineEdit(0),
22 setupFrame(setupFrame_)
24 // we really need the setupFrame, so lets declare that requirement
25 assert(setupFrame != 0);
28 sequenceNameEdit = new QLineEdit();
29 sequenceNameEdit->setWhatsThis(tr("Name of input sequence"));
30 QLabel *sequenceNameLabel = new QLabel(tr("Sequence name:"));
31 sequenceNameLabel->setBuddy(sequenceNameEdit);
32 sequenceNameLabel->setWhatsThis(tr("Name of input sequence"));
34 // Sequence file location line
35 sequenceLineEdit = new QLineEdit();
36 sequenceLineEdit->setWhatsThis(tr("File path to input sequence"));
37 //const IsFileValidator *fileValidator = new IsFileValidator(this);
38 //sequenceLineEdit->setValidator(fileValidator);
39 QLabel *sequenceLabel = new QLabel("Sequence Filename:");
40 sequenceLabel->setBuddy(sequenceLineEdit);
41 sequenceLabel->setWhatsThis(tr("File path to input sequence"));
43 QPushButton *sequenceButton = new QPushButton(tr("Browse..."));
44 sequenceButton->setWhatsThis(tr("Browse for input sequence"));
45 connect(sequenceButton, SIGNAL(clicked()),
46 this, SLOT(promptForFastaFile()));
49 annotLineEdit = new QLineEdit();
50 annotLineEdit->setWhatsThis(tr("Annotation file path for above input sequence"));
51 //const IsFileValidator *fileValidator2 = new IsFileValidator(this);
52 //annotLineEdit->setValidator(fileValidator2);
53 QLabel *annotLabel = new QLabel(tr("Annotation Filename:"));
54 annotLabel->setBuddy(annotLineEdit);
55 annotLabel->setWhatsThis(tr("Annotation file path for above input sequence"));
57 QPushButton *annotButton = new QPushButton(tr("Browse..."));
58 annotButton->setWhatsThis(tr("Browse for annotation file for above input sequence"));
59 connect(annotButton, SIGNAL(clicked()),
60 this, SLOT(promptForAnnotFile()));
63 fastaIndexLineEdit = new QLineEdit();
64 fastaIndexLineEdit->setWhatsThis(tr("When a FASTA file contains more then one FASTA record, provide a 1 based index (first record is index 1) to select which one to use."));
65 //fastaIndexLineEdit->setMaximumWidth(100);
67 QLabel *fastaIndexLabel = new QLabel(tr("Fasta Index:"));
68 fastaIndexLabel->setBuddy(fastaIndexLineEdit);
69 fastaIndexLabel->setWhatsThis(tr("When a FASTA file contains more then one FASTA record, provide a 1 based index (first record is index 1) to select which one to use."));
71 seqStartLineEdit = new QLineEdit();
72 seqStartLineEdit->setWhatsThis(tr("Start base pair in input sequence (0 based: 1st base pair is 0)"));
73 //seqStartLineEdit->setMinimumWidth(60);
74 //seqStartLineEdit->setMaximumWidth(80);
76 QLabel *seqStartLabel = new QLabel(tr("Sequence Start:"));
77 seqStartLabel->setWhatsThis(tr("Start base pair in input sequence (0 based: 1st base pair is 0)"));
78 seqStartLabel->setBuddy(seqStartLineEdit);
80 seqStopLineEdit = new QLineEdit();
81 seqStopLineEdit->setWhatsThis(tr("Stop base pair in input sequence (0 based: 1st base pair is 0) 0 means all of remaining sequence."));
82 //seqStopLineEdit->setMinimumWidth(40);
83 //seqStopLineEdit->setMaximumWidth(60);
85 QLabel *seqStopLabel = new QLabel(tr("Sequence Stop:"));
86 seqStopLabel->setWhatsThis(tr("Stop base pair in input sequence (0 based: 1st base pair is 0) 0 means all of remaining sequence."));
87 seqStopLabel->setBuddy(seqStopLineEdit);
90 QVBoxLayout *mainLayout = new QVBoxLayout;
91 QHBoxLayout *sequenceNameLayout = new QHBoxLayout;
92 QHBoxLayout *sequenceRowLayout = new QHBoxLayout;
93 QHBoxLayout *annotRowLayout = new QHBoxLayout;
94 QHBoxLayout *indexRowLayout = new QHBoxLayout;
96 sequenceNameLayout->addWidget(sequenceNameLabel);
97 sequenceNameLayout->addWidget(sequenceNameEdit);
99 sequenceRowLayout->addWidget(sequenceLabel);
100 sequenceRowLayout->addWidget(sequenceLineEdit);
101 sequenceRowLayout->addWidget(sequenceButton);
103 annotRowLayout->addWidget(annotLabel);
104 annotRowLayout->addWidget(annotLineEdit);
105 annotRowLayout->addWidget(annotButton);
107 indexRowLayout->addWidget(fastaIndexLabel);
108 indexRowLayout->addWidget(fastaIndexLineEdit);
109 indexRowLayout->addWidget(seqStartLabel);
110 indexRowLayout->addWidget(seqStartLineEdit);
111 indexRowLayout->addWidget(seqStopLabel);
112 indexRowLayout->addWidget(seqStopLineEdit);
114 mainLayout->addLayout(sequenceNameLayout);
115 mainLayout->addLayout(sequenceRowLayout);
116 mainLayout->addLayout(annotRowLayout);
117 mainLayout->addLayout(indexRowLayout);
118 setLayout(mainLayout);
121 //SequenceSetupWidget::SequenceSetupWidget(const SequenceSetupWidget& ssw) :
122 // sequenceLineEdit(ssw.sequenceLineEdit),
123 // annotLineEdit(ssw.annotLineEdit),
124 // fastaIndexLineEdit(ssw.fastaIndexLineEdit),
125 // seqStartLineEdit(ssw.seqStartLineEdit),
126 // seqStopLineEdit(ssw.seqStopLineEdit)
130 int SequenceSetupWidget::getFastaIndex() const
132 if (fastaIndexLineEdit->text().size() == 0)
135 return fastaIndexLineEdit->text().toInt();
138 void SequenceSetupWidget::promptForFastaFile()
140 QString default_dir = setupFrame->get_default_dir().absolutePath();
141 QString fastaFilePath = QFileDialog::getOpenFileName(this,
142 "Choose a fasta file",
144 "Fasta (*.fa *.fasta *.fsa *.txt)");
145 if (fastaFilePath.isEmpty())
148 sequenceLineEdit->setText(fastaFilePath);
149 setupFrame->set_default_dir(QDir(fastaFilePath));
153 void SequenceSetupWidget::promptForAnnotFile()
155 QString default_dir = setupFrame->get_default_dir().absolutePath();
156 QString annotFilePath = QFileDialog::getOpenFileName(this,
157 "Choose a annotation file",
159 "Annot (*.txt *.annot)");
160 if (annotFilePath.isEmpty())
163 annotLineEdit->setText(annotFilePath);
164 setupFrame->set_default_dir(QDir(annotFilePath));