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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
|
/**
* Changes:
* Mark: 18-01-2007. Changed from using QFileDialog to FileDialog.
*
* 15-03-07,Nigel Brown(EMBL): setSlowInitialTextParams() was calling
* getGapOpen() and getGapExtend() instead of getPWGapOpen() and
* getPWGapExtend(), so these user settings were being dropped.
*/
#include "PairwiseParams.h"
#include <QTabWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QGridLayout>
#include <QLineEdit>
#include <QButtonGroup>
#include <QRadioButton>
#include <QMessageBox>
#include <QHBoxLayout>
#include <QtGui>
#include "clustalW/general/userparams.h"
#include "clustalW/substitutionMatrix/globalmatrix.h"
#include "FileDialog.h"
PairwiseParams::PairwiseParams()
{
setWindowTitle("Pairwise Parameters");
proteinMatLoaded = false;
dnaMatLoaded = false;
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAParams();
}
else
{
clustalw::userParameters->setProtParams();
}
slowOrQuick = new QComboBox;
slowOrQuick->addItem("Slow-Accurate");
slowOrQuick->addItem("Fast-Approximate");
if(clustalw::userParameters->getQuickPairAlign())
{
slowOrQuick->setCurrentIndex(1);
}
else
{
slowOrQuick->setCurrentIndex(0);
}
mainLayout = new QVBoxLayout;
slowPairwiseTab = new QGroupBox;
fastPairwiseTab = new QGroupBox;
tabWidget = new QTabWidget;
setUpSlowTab();
tabWidget->addTab(slowPairwiseTab, "Slow/Accurate Pairwise Parameters");
setUpFastTab();
tabWidget->addTab(fastPairwiseTab, "Fast/Approx Pairwise Parameters");
okButton = new QPushButton(tr("OK"));
okButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
mainLayout->addWidget(okButton);
mainLayout->addWidget(slowOrQuick);
mainLayout->addWidget(tabWidget);
setLayout(mainLayout);
}
void PairwiseParams::showEvent(QShowEvent* event)
{
if(clustalw::userParameters->getQuickPairAlign())
{
slowOrQuick->setCurrentIndex(1);
}
else
{
slowOrQuick->setCurrentIndex(0);
}
// Each time the dialog is shown reload the values from the userParameters object!!!
setInitialProteinMat();
setInitialDNAMat();
setSlowInitialTextParams();
setFastInitialTextParams();
}
void PairwiseParams::userProteinClicked()
{
if(!proteinMatLoaded)
{
slowBrowseProtein();
}
}
void PairwiseParams::userDNAClicked()
{
if(!dnaMatLoaded)
{
slowBrowseDNA();
}
}
void PairwiseParams::setUpSlowTab()
{
setUpSlowTextAreas();
setUpSlowProteinWeightMat();
setUpSlowDNAWeightMat();
loadProteinGroup = new QGroupBox;
horizLayoutAA = new QHBoxLayout;
userProteinMatrix = new QLabel("");
slowLoadProtMat = new QPushButton(tr("Load protein matrix:"));
slowLoadProtMat->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
horizLayoutAA->addWidget(slowLoadProtMat);
horizLayoutAA->addWidget(userProteinMatrix);
loadProteinGroup->setLayout(horizLayoutAA);
connect(slowLoadProtMat, SIGNAL(clicked()), this, SLOT(slowBrowseProtein()));
loadDNAGroup = new QGroupBox;
horizLayoutDNA = new QHBoxLayout;
userDNAMatrix = new QLabel("");
slowLoadDNAMat = new QPushButton(tr("Load DNA matrix:"));
slowLoadDNAMat->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
horizLayoutDNA->addWidget(slowLoadDNAMat);
horizLayoutDNA->addWidget(userDNAMatrix);
loadDNAGroup->setLayout(horizLayoutDNA);
connect(slowLoadDNAMat, SIGNAL(clicked()), this, SLOT(slowBrowseDNA()));
slowTabLayout = new QVBoxLayout;
slowTabLayout->addWidget(slowGapParams);
slowTabLayout->addWidget(slowProtMatGroup);
slowTabLayout->addWidget(loadProteinGroup);
slowTabLayout->addWidget(slowDNAMatGroup);
slowTabLayout->addWidget(loadDNAGroup);
slowPairwiseTab->setLayout(slowTabLayout);
}
void PairwiseParams::setUpSlowTextAreas()
{
slowGapParams = new QGroupBox;
slowGapOpenLabel = new QLabel(tr("Gap Opening [0-100]: "));
slowGapExtendLabel = new QLabel(tr("Gap Extend [0-100]: "));
slowGapOpen = new QLineEdit;
slowGapExtend = new QLineEdit;
slowGapLayout = new QGridLayout;
slowGapLayout->addWidget(slowGapOpenLabel, 0, 0);
slowGapLayout->addWidget(slowGapOpen, 0, 1);
slowGapLayout->addWidget(slowGapExtendLabel, 1, 0);
slowGapLayout->addWidget(slowGapExtend, 1, 1);
slowGapParams->setLayout(slowGapLayout);
}
void PairwiseParams::setSlowInitialTextParams()
{
QString num;
num = num.setNum(clustalw::userParameters->getPWGapOpen());
slowGapOpen->setText(num);
num = num.setNum(clustalw::userParameters->getPWGapExtend());
slowGapExtend->setText(num);
}
void PairwiseParams::setUpSlowProteinWeightMat()
{
slowProtMatGroup = new QGroupBox(tr("Protein Weight Matrix"));
slowProteinWeightMat = new QButtonGroup;
slowProteinWeightMat->setExclusive(true);
slowProtBlosum30 = new QRadioButton("BLOSUM 30");
slowProtPAM350 = new QRadioButton("PAM 350");
slowProtGonnet250 = new QRadioButton("Gonnet 250");
slowProtIdentity = new QRadioButton("Identity matrix");
slowProtAAUserMat = new QRadioButton("User defined");
connect(slowProtAAUserMat, SIGNAL(clicked()), this, SLOT(userProteinClicked()));
slowProteinWeightMat->addButton(slowProtBlosum30);
slowProteinWeightMat->addButton(slowProtPAM350);
slowProteinWeightMat->addButton(slowProtGonnet250);
slowProteinWeightMat->addButton(slowProtIdentity);
slowProteinWeightMat->addButton(slowProtAAUserMat);
protMatLayout = new QGridLayout;
protMatLayout->addWidget(slowProtBlosum30, 0, 0);
protMatLayout->addWidget(slowProtPAM350, 0, 1);
protMatLayout->addWidget(slowProtGonnet250, 0, 2);
protMatLayout->addWidget(slowProtIdentity, 1, 0);
protMatLayout->addWidget(slowProtAAUserMat, 1, 1);
slowProtMatGroup->setLayout(protMatLayout);
}
void PairwiseParams::setInitialProteinMat()
{
if((clustalw::subMatrix->getPWMatrixNum() - 1) == clustalw::PWAABLOSUM)
{
slowProtBlosum30->setChecked(true);
}
else if((clustalw::subMatrix->getPWMatrixNum() - 1) == clustalw::PWAAPAM)
{
slowProtPAM350->setChecked(true);
}
else if((clustalw::subMatrix->getPWMatrixNum() - 1) == clustalw::PWAAGONNET)
{
slowProtGonnet250->setChecked(true);
}
else if((clustalw::subMatrix->getPWMatrixNum() - 1) == clustalw::PWAAIDENTITY)
{
slowProtIdentity->setChecked(true);
}
else if((clustalw::subMatrix->getPWMatrixNum() - 1) == clustalw::PWAAUSER)
{
slowProtAAUserMat->setChecked(true);
}
}
void PairwiseParams::setUpSlowDNAWeightMat()
{
slowDNAMatGroup = new QGroupBox(tr("DNA Weight Matrix"));
slowDNAWeightMat = new QButtonGroup;
slowDNAWeightMat->setExclusive(true);
slowDNAIUB = new QRadioButton("IUB");
slowDNAClustalw = new QRadioButton("CLUSTALW(1.6)");
slowDNAUser = new QRadioButton("User defined");
connect(slowDNAUser, SIGNAL(clicked()), this, SLOT(userDNAClicked()));
slowDNAWeightMat->addButton(slowDNAIUB);
slowDNAWeightMat->addButton(slowDNAClustalw);
slowDNAWeightMat->addButton(slowDNAUser);
dnaMatLayout = new QGridLayout;
dnaMatLayout->addWidget(slowDNAIUB, 0, 0);
dnaMatLayout->addWidget(slowDNAClustalw, 0, 1);
dnaMatLayout->addWidget(slowDNAUser, 0, 2);
slowDNAMatGroup->setLayout(dnaMatLayout);
}
void PairwiseParams::setInitialDNAMat()
{
if((clustalw::subMatrix->getPWDNAMatrixNum() - 1) == clustalw::DNAIUB)
{
slowDNAIUB->setChecked(true);
}
else if((clustalw::subMatrix->getPWDNAMatrixNum() - 1) == clustalw::DNACLUSTALW)
{
slowDNAClustalw->setChecked(true);
}
else if((clustalw::subMatrix->getPWDNAMatrixNum() - 1) == clustalw::DNAUSERDEFINED)
{
slowDNAUser->setChecked(true);
}
}
void PairwiseParams::setUpFastTab()
{
fastGapPenaltyLabel = new QLabel(tr("Gap Penalty [1-500]: "));
fastGapPenalty = new QLineEdit;
fastKTupSizeLabel = new QLabel(tr("K-Tuple Size [1-2]: "));
fastKTupSize = new QLineEdit;
fastTopDiagonalsLabel = new QLabel(tr("Top Diagonals [1-50]: "));
fastTopDiagonals = new QLineEdit;
fastWindowSizeLabel = new QLabel(tr("Window Size [1-50]: "));
fastWindowSize = new QLineEdit;
fastTabLayout = new QGridLayout;
fastTabLayout->addWidget(fastGapPenaltyLabel, 0, 0);
fastTabLayout->addWidget(fastGapPenalty, 0, 1);
fastTabLayout->addWidget(fastKTupSizeLabel, 1, 0);
fastTabLayout->addWidget(fastKTupSize, 1, 1);
fastTabLayout->addWidget(fastTopDiagonalsLabel, 2, 0);
fastTabLayout->addWidget(fastTopDiagonals, 2, 1);
fastTabLayout->addWidget(fastWindowSizeLabel, 3, 0);
fastTabLayout->addWidget(fastWindowSize, 3, 1);
fastPairwiseTab->setLayout(fastTabLayout);
}
void PairwiseParams::setFastInitialTextParams()
{
QString num;
num = num.setNum(clustalw::userParameters->getWindowGap());
fastGapPenalty->setText(num);
num = num.setNum(clustalw::userParameters->getKtup());
fastKTupSize->setText(num);
num = num.setNum(clustalw::userParameters->getSignif());
fastTopDiagonals->setText(num);
num = num.setNum(clustalw::userParameters->getWindow());
fastWindowSize->setText(num);
}
void PairwiseParams::radioSetUsingUserProtein()
{
slowProtAAUserMat->setChecked(true);
}
void PairwiseParams::slowBrowseProtein()
{
// Mark Jan 18th 2007: changes to remember working Dir
FileDialog fd;
slowAAMatrixPath = fd.getOpenFileName(this, tr("Find Protein Matrix"));
string path = slowAAMatrixPath.toStdString();
if(path != "")
{
int lenOfString = path.length();
char* userFile = new char[lenOfString + 1];
strcpy(userFile, path.c_str());
if (clustalw::subMatrix->getUserMatFromFile(userFile, clustalw::Protein,
clustalw::Pairwise))
{
aaMatrixFile = string(userFile);
proteinMatLoaded = true;
userProteinMatrix->setText(aaMatrixFile.c_str());
radioSetUsingUserProtein();
}
else
{
aaMatrixFile = "";
proteinMatLoaded = false;
userProteinMatrix->setText(aaMatrixFile.c_str());
setInitialProteinMat();
}
delete []userFile;
}
else // pressed cancel
{
if(!proteinMatLoaded)
{
setInitialProteinMat();
}
}
}
void PairwiseParams::slowBrowseDNA()
{
// Mark Jan 18th 2007: changes to remember working Dir
FileDialog fd;
slowDNAMatrixPath = fd.getOpenFileName(this, tr("Find DNA Matrix"));
string path = slowDNAMatrixPath.toStdString();
if(path != "")
{
int lenOfString = path.length();
char* userFile = new char[lenOfString + 1];
strcpy(userFile, path.c_str());
if (clustalw::subMatrix->getUserMatFromFile(userFile, clustalw::DNA,
clustalw::Pairwise))
{
dnaMatrixFile = string(userFile);
dnaMatLoaded = true;
userDNAMatrix->setText(dnaMatrixFile.c_str());
slowDNAUser->setChecked(true);
}
else
{
dnaMatrixFile = "";
dnaMatLoaded = false;
setInitialDNAMat();
userDNAMatrix->setText(dnaMatrixFile.c_str());
}
delete []userFile;
}
else // pressed cancel
{
if(!dnaMatLoaded)
{
setInitialDNAMat();
}
}
}
void PairwiseParams::accept()
{
if(slowOrQuick->currentIndex() == 1)
{
clustalw::userParameters->setQuickPairAlign(true);
}
else
{
clustalw::userParameters->setQuickPairAlign(false);
}
// Protein matrices
if(slowProtBlosum30->isChecked())
{
//slowProtBlosum30->setChecked(true);
clustalw::subMatrix->setCurrentNameAndNum("blosum", 1, clustalw::Protein,
clustalw::Pairwise);
}
else if(slowProtPAM350->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum("pam", 2, clustalw::Protein,
clustalw::Pairwise);
}
else if(slowProtGonnet250->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum("gonnet", 3, clustalw::Protein,
clustalw::Pairwise);
}
else if(slowProtIdentity->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum("id", 4, clustalw::Protein,
clustalw::Pairwise);
}
else if(slowProtAAUserMat->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum(aaMatrixFile, 5, clustalw::Protein,
clustalw::Pairwise);
}
// DNA Matrix
if(slowDNAIUB->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum("iub", 1, clustalw::DNA,
clustalw::Pairwise);
}
else if(slowDNAClustalw->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum("clustalw", 2, clustalw::DNA,
clustalw::Pairwise);
}
else if(slowDNAUser->isChecked())
{
clustalw::subMatrix->setCurrentNameAndNum(dnaMatrixFile, 3, clustalw::DNA,
clustalw::Pairwise);
}
// Check slowGapOpen 0-100
bool ok;
QString sGapOpen = slowGapOpen->text();
float sgapOpen;
sgapOpen = sGapOpen.toFloat(&ok);
if(ok && sgapOpen >= 0.0 && sgapOpen <= 100.0)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAPWGapOpenPenalty(sgapOpen);
}
else
{
clustalw::userParameters->setAAPWGapOpen(sgapOpen);
}
}
// Check slowGapExtend 0-100
QString sGapExtend = slowGapExtend->text();
float sgapExtend;
sgapExtend = sGapExtend.toFloat(&ok);
if(ok && sgapExtend >= 0.0 && sgapExtend <= 100.0)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAPWGapExtendPenalty(sgapExtend);
}
else
{
clustalw::userParameters->setAAPWGapExtend(sgapExtend);
}
}
// Check fastGapPenalty 1-500
QString fastGapPenString = fastGapPenalty->text();
int fastGPen;
fastGPen = fastGapPenString.toInt(&ok);
if(ok && fastGPen >= 1 && fastGPen <= 500)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAWindowGap(fastGPen);
}
else
{
clustalw::userParameters->setAAWindowGap(fastGPen);
}
}
// Check fastKTupSize 1-2
QString fastKTupString = fastKTupSize->text();
int fastKTup;
fastKTup = fastKTupString.toInt(&ok);
if(ok && fastKTup >= 1 && fastKTup <= 2)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAKtup(fastKTup);
}
else
{
clustalw::userParameters->setAAKtup(fastKTup);
}
}
// Check fastTopDiagonals 1-50
QString fastTopDiagonalsString = fastTopDiagonals->text();
int fastTopDiag;
fastTopDiag = fastTopDiagonalsString.toInt(&ok);
if(ok && fastTopDiag >= 1 && fastTopDiag <= 50)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNASignif(fastTopDiag);
}
else
{
clustalw::userParameters->setAASignif(fastTopDiag);
}
}
// Check fastWindowSize 1-50
QString fastWindowSizeString = fastWindowSize->text();
int fastWinSize;
fastWinSize = fastWindowSizeString.toInt(&ok);
if(ok && fastWinSize >= 1 && fastWinSize <= 50)
{
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAWindow(fastWinSize);
}
else
{
clustalw::userParameters->setAAWindow(fastWinSize);
}
}
// NOTE it is important to set the parameters here.
if(clustalw::userParameters->getDNAFlag())
{
clustalw::userParameters->setDNAParams();
}
else
{
clustalw::userParameters->setProtParams();
}
setResult(QDialog::Accepted);
hide();
}
|