File: SecStructOptions.cpp

package info (click to toggle)
clustalx 2.1%2Blgpl-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,332 kB
  • ctags: 3,424
  • sloc: cpp: 40,050; sh: 163; xml: 102; makefile: 11
file content (272 lines) | stat: -rw-r--r-- 8,730 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#include <QPushButton>
#include <QGroupBox>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QSizePolicy>
#include <QComboBox>
#include <QtGui>
#include <QLabel>
#include <QLineEdit>
#include "SecStructOptions.h"
#include "clustalW/general/userparams.h"

SecStructOptions::SecStructOptions()
{
    setWindowTitle("Secondary Structure Options");
    QVBoxLayout* mainLayout = new QVBoxLayout;
    
    outputGridBox = new QGroupBox("Output");
    ssGridBox = new QGroupBox;
    ssParamsGridBox = new QGroupBox;
    verticalBox = new QGroupBox;

    okButton = new QPushButton(tr("OK"));
    okButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));   
    
    setUpCombo();
    setUpOutput();
    setUpOtherParams();
    
    mainLayout->addWidget(okButton);
    mainLayout->addWidget(ssGridBox);
    mainLayout->addWidget(outputGridBox);
    mainLayout->addWidget(ssParamsGridBox);
    setLayout(mainLayout);     
}

void SecStructOptions::setUpCombo()
{
    QGridLayout *grid = new QGridLayout;
    useProfile1SS = new QComboBox;
    useProfile1SS->addItem("Yes");
    useProfile1SS->addItem("No");
    if(clustalw::userParameters->getUseSS1())
    {
        useProfile1SS->setCurrentIndex(0);
    }
    else
    {
        useProfile1SS->setCurrentIndex(1);
    }
    
    useProfile2SS = new QComboBox;
    useProfile2SS->addItem("Yes");
    useProfile2SS->addItem("No");  
    if(clustalw::userParameters->getUseSS2())
    {
        useProfile2SS->setCurrentIndex(0);
    }
    else
    {
        useProfile2SS->setCurrentIndex(1);
    }
        
    useProfile1SSLabel = new QLabel("Use profile 1 secondary structure / penalty mask");
    useProfile2SSLabel = new QLabel("Use profile 2 secondary structure / penalty mask");
    
    grid->addWidget(useProfile1SSLabel, 0, 0);
    grid->addWidget(useProfile1SS, 0, 1);
    grid->addWidget(useProfile2SSLabel, 1, 0);
    grid->addWidget(useProfile2SS, 1, 1);    
    
    ssGridBox->setLayout(grid);
      
}

void SecStructOptions::setUpOutput()
{
    QGridLayout *grid = new QGridLayout;
    secStruct = new QCheckBox("Secondary Structure");
    gapMask = new QCheckBox("Gap Penalty Mask"); 
    if(clustalw::userParameters->getOutputStructPenalties() == clustalw::OUTSECST)
    {
        secStruct->setChecked(true);
        gapMask->setChecked(false);        
    }
    else if(clustalw::userParameters->getOutputStructPenalties() == clustalw::OUTGAP)
    {
        gapMask->setChecked(true);
        secStruct->setChecked(false);        
    }
    else if(clustalw::userParameters->getOutputStructPenalties() == clustalw::OUTBOTH)
    {
        secStruct->setChecked(true);
        gapMask->setChecked(true);            
    }
    else
    {
        secStruct->setChecked(false);
        gapMask->setChecked(false);    
    }
    grid->addWidget(secStruct, 0, 0);
    grid->addWidget(gapMask, 0, 1);
    outputGridBox->setLayout(grid);
}

void SecStructOptions::setUpOtherParams()
{
    QString myNum;
    
    helixGapPen = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getHelixPenalty());
    helixGapPen->setText(myNum);
    
    strandGapPen = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getStrandPenalty());
    strandGapPen->setText(myNum);
    
    loopGapPen = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getLoopPenalty());
    loopGapPen->setText(myNum);
        
    ssTerminalPen = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getHelixEndPenalty());
    ssTerminalPen->setText(myNum);
        
    helixTerminalPosWithin = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getHelixEndMinus());
    helixTerminalPosWithin->setText(myNum);
        
    helixTerminalPosOutside = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getHelixEndPlus());
    helixTerminalPosOutside->setText(myNum);
        
    strandTerminalPosWithin = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getStrandEndMinus());
    strandTerminalPosWithin->setText(myNum);
    
    strandTerminalPosOutside = new QLineEdit;
    myNum.setNum(clustalw::userParameters->getStrandEndPlus());
    strandTerminalPosOutside->setText(myNum);
    
    helixGapPenLabel = new QLabel("Helix Gap Penalty [1-9]:");
    strandGapPenLabel = new QLabel("Strand Gap Penalty [1-9]:");
    loopGapPenLabel = new QLabel("Loop Gap Penalty [1-9]:");
    ssTerminalPenLabel = new QLabel("Secondary Structure Terminal Penalty [1-9]:");
    helixTerminalPosWithinLabel = new QLabel("Helix Terminal Positions [1-9]    within:");
    helixTerminalPosOutsideLabel = new QLabel("outside:");
    strandTerminalPosWithinLabel = new QLabel("Strand Terminal Positions [1-9]    within:");
    strandTerminalPosOutsideLabel = new QLabel("outside:");
    
    QGridLayout *grid = new QGridLayout;
    grid->addWidget(helixGapPenLabel, 0, 0);
    grid->addWidget(helixGapPen, 0, 1);
    grid->addWidget(strandGapPenLabel, 1, 0);
    grid->addWidget(strandGapPen, 1, 1);
    grid->addWidget(loopGapPenLabel, 2, 0);
    grid->addWidget(loopGapPen, 2, 1);
    grid->addWidget(ssTerminalPenLabel, 3, 0);
    grid->addWidget(ssTerminalPen, 3, 1);
    grid->addWidget(helixTerminalPosWithinLabel, 4, 0);
    grid->addWidget(helixTerminalPosWithin, 4, 1);
    grid->addWidget(helixTerminalPosOutsideLabel, 5, 0);
    grid->addWidget(helixTerminalPosOutside, 5, 1);
    grid->addWidget(strandTerminalPosWithinLabel, 6, 0);
    grid->addWidget(strandTerminalPosWithin, 6, 1);
    grid->addWidget(strandTerminalPosOutsideLabel, 7, 0);
    grid->addWidget(strandTerminalPosOutside, 7, 1);    
    
    ssParamsGridBox->setLayout(grid);                        
}

void SecStructOptions::accept()
{
    bool ok;
    // Using secondary structure information??
    if(useProfile1SS->currentIndex() == 0)
    {
        clustalw::userParameters->setUseSS1(true);
    }
    else
    {
        clustalw::userParameters->setUseSS1(false);
    }    

    if(useProfile2SS->currentIndex() == 0)
    {
        clustalw::userParameters->setUseSS2(true);
    }
    else
    {
        clustalw::userParameters->setUseSS2(false);
    }

    // Output secondary structure information???
    if(secStruct->isChecked() && !gapMask->isChecked())
    {
        clustalw::userParameters->setOutputStructPenalties(clustalw::OUTSECST);
    }
    else if(gapMask->isChecked() && !secStruct->isChecked())
    {
        clustalw::userParameters->setOutputStructPenalties(clustalw::OUTGAP);     
    }
    else if(secStruct->isChecked() && gapMask->isChecked())
    {
        clustalw::userParameters->setOutputStructPenalties(clustalw::OUTBOTH);           
    }
    else
    {
        clustalw::userParameters->setOutputStructPenalties(clustalw::OUTNONE);    
    }
    // Now check all the numbers in the boxes are 1-9
    QString helixGapPenString = helixGapPen->text();
    int pen = helixGapPenString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setHelixPenalty(pen);
    }
    
    QString strandGapPenString = strandGapPen->text();
    pen = strandGapPenString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setStrandPenalty(pen);
    }
        
    QString loopGapPenString = loopGapPen->text();
    pen = loopGapPenString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setLoopPenalty(pen);
    }    
    
    QString ssTerminalPenString = ssTerminalPen->text();
    pen = ssTerminalPenString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setHelixEndPenalty(pen);
    }    
    
    QString helixTerminalPosWithinString = helixTerminalPosWithin->text();
    pen = helixTerminalPosWithinString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setHelixEndMinus(pen);
    }
        
    QString helixTerminalPosOutsideString = helixTerminalPosOutside->text();
    pen = helixTerminalPosOutsideString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setHelixEndPlus(pen);
    }
        
    QString strandTerminalPosWithinString = strandTerminalPosWithin->text();
    pen = strandTerminalPosWithinString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setStrandEndMinus(pen);
    }
           
    QString strandTerminalPosOutsideString = strandTerminalPosOutside->text();
    pen = strandTerminalPosOutsideString.toInt(&ok);
    if(ok && pen >= 1 && pen <= 9)
    {
        clustalw::userParameters->setStrandEndPlus(pen);
    }
                    
    setResult(QDialog::Accepted);
    hide();
}