3
// Copyright (c) 1998-2010 by The VoxBo Development Team
5
// This file is part of VoxBo
7
// VoxBo is free software: you can redistribute it and/or modify it
8
// under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
12
// VoxBo is distributed in the hope that it will be useful, but
13
// WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with VoxBo. If not, see <http://www.gnu.org/licenses/>.
20
// For general information on VoxBo, including the latest complete
21
// source code and binary distributions, manual, and associated files,
22
// see the VoxBo home page at: http://www.voxbo.org/
24
// original version written by Tom King and Daniel Y. Kimberg
30
#include <qcheckbox.h>
33
#include <qpushbutton.h>
34
#include <q3textedit.h>
37
#include <q3whatsthis.h>
38
#include <qmessagebox.h>
39
#include <qcombobox.h>
40
#include <qlineedit.h>
44
#include <Q3HBoxLayout>
45
#include <Q3VBoxLayout>
46
#include <Q3BoxLayout>
47
#include <QCloseEvent>
54
int msgboxsetpermnumber;
58
permGenerator::permGenerator( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
59
: QDialog( parent, name, modal, fl )
63
setName( "permGenerator" );
65
Q3BoxLayout *x = new Q3VBoxLayout(this);
67
txtPRM = new QLineEdit( this, "txtPRM" );
68
txtPRM->setGeometry( QRect( 250, 10, 170, 24 ) );
69
connect(txtPRM, SIGNAL(textChanged(const QString &)), this, SLOT(CalculateNumPerms()));
71
pbDir = new QPushButton( this, "pbDir" );
72
pbDir->setGeometry( QRect( 50, 10, 180, 20 ) );
73
connect(pbDir, SIGNAL(clicked()), this, SLOT(getPRMFile()));
75
Q3BoxLayout *y = new Q3HBoxLayout(x);
76
y->insertWidget(0, pbDir, 10, Qt::AlignRight);
78
y->insertWidget(2, txtPRM, 10, Qt::AlignTop);
82
txtPermDir = new QLineEdit( this, "txtPermDir" );
83
txtPermDir->setGeometry( QRect( 250, 40, 170, 24 ) );
85
lblPermDir = new QLabel( this, "lblPermNumber" );
86
lblPermDir->setGeometry( QRect( 90, 130, 140, 20 ) );
88
Q3BoxLayout *y1 = new Q3HBoxLayout(x);
89
y1->insertWidget(0, lblPermDir, 10, Qt::AlignRight);
91
y1->insertWidget(2, txtPermDir, 10, Qt::AlignTop);
95
txtContrasts = new QLineEdit( this, "txtContrasts" );
96
txtContrasts->setGeometry( QRect( 250, 70, 170, 24 ) );
98
lblContrasts = new QLabel( this, "lblContrasts" );
99
lblContrasts->setGeometry( QRect( 130, 70, 100, 20 ) );
101
Q3BoxLayout *y2 = new Q3HBoxLayout(x);
102
y2->insertWidget(0, lblContrasts, 10, Qt::AlignRight);
104
y2->insertWidget(2, txtContrasts, 10, Qt::AlignTop);
108
cbScale = new QComboBox( this, "txtScale" );
109
cbScale->setGeometry( QRect( 250, 100, 170, 24 ) );
111
lblScale = new QLabel( this, "lblScale" );
112
lblScale->setGeometry( QRect( 130, 100, 100, 20 ) );
114
Q3BoxLayout *y5 = new Q3HBoxLayout(x);
115
y5->insertWidget(0, lblScale, 10, Qt::AlignRight);
117
y5->insertWidget(2, cbScale, 10, Qt::AlignTop);
121
txtPermNumber = new QLineEdit( this, "txtPermNumber" );
122
txtPermNumber->setGeometry( QRect( 250, 130, 170, 24 ) );
123
connect(txtPermNumber, SIGNAL(textChanged(const QString &)), this, SLOT(warnCalculateNumPerms()));
125
lblPermNumber = new QLabel( this, "lblPermNumber" );
126
lblPermNumber->setGeometry( QRect( 90, 130, 140, 20 ) );
128
Q3BoxLayout *y3 = new Q3HBoxLayout(x);
129
y3->insertWidget(0, lblPermNumber, 10, Qt::AlignRight);
131
y3->insertWidget(2, txtPermNumber, 10, Qt::AlignTop);
135
lblPseudoT = new QLabel( this, "lblPseudoT" );
136
lblPseudoT->setGeometry( QRect(10, 150, 143, 40) );
138
QCheckBox *on=new QCheckBox("on/off",this);
140
on->setGeometry( QRect( 160, 160, 60, 21 ) );
141
QObject::connect(on,SIGNAL(toggled(bool)),this,SLOT(mod(bool)));
143
txtZ = new QLineEdit( this, "txtZ" );
144
txtZ->setGeometry( QRect( 390, 160, 30, 24 ) );
145
txtZ->setDisabled(true);
147
lblZ = new QLabel( this, "lblZ" );
148
lblZ->setGeometry( QRect( 370, 160, 16, 21 ) );
150
txtX = new QLineEdit( this, "txtX" );
151
txtX->setGeometry( QRect( 270, 160, 30, 24 ) );
152
txtX->setDisabled(true);
154
txtY = new QLineEdit( this, "txtY" );
155
txtY->setGeometry( QRect( 330, 160, 30, 24 ) );
156
txtY->setDisabled(true);
158
lblX = new QLabel( this, "lblX" );
159
lblX->setGeometry( QRect( 250, 160, 16, 20 ) );
161
lblY = new QLabel( this, "lblY" );
162
lblY->setGeometry( QRect( 310, 160, 16, 20 ) );
164
Q3BoxLayout *y4 = new Q3HBoxLayout(x);
166
y4->insertWidget(1, lblPseudoT, 10, Qt::AlignRight);
168
y4->insertWidget(3, on, 10, Qt::AlignRight);
170
y4->insertWidget(5, lblX, 10, Qt::AlignRight);
172
y4->insertWidget(7, txtX, 10, Qt::AlignTop);
174
y4->insertWidget(9, lblY, 10, Qt::AlignRight);
176
y4->insertWidget(11, txtY, 10, Qt::AlignTop);
178
y4->insertWidget(13, lblZ, 10, Qt::AlignRight);
180
y4->insertWidget(15, txtZ, 10, Qt::AlignTop);
184
lblPermType = new QLabel( this, "lblPermType" );
185
lblPermType->setGeometry( QRect( 0, 190, 230, 20 ) );
187
cbPermType = new QComboBox( this, "cbPermType" );
188
cbPermType->setGeometry( QRect( 250, 190, 170, 24 ) );
190
Q3BoxLayout *y6 = new Q3HBoxLayout(x);
191
y6->insertWidget(0, lblPermType, 10, Qt::AlignRight);
193
y6->insertWidget(2, cbPermType, 10, Qt::AlignTop);
197
line2 = new Q3Frame( this, "line2" );
198
line2->setGeometry( QRect( 21, 220, 400, 20 ) );
199
line2->setFrameShape( Q3Frame::HLine );
200
line2->setFrameShadow( Q3Frame::Sunken );
201
line2->setFrameShape( Q3Frame::HLine );
203
Q3BoxLayout *y7 = new Q3HBoxLayout(x);
205
y7->addWidget(line2, 10, Qt::AlignTop);
209
sbPriority = new QSpinBox( this, "sbPriority" );
210
sbPriority->setGeometry( QRect( 360, 240, 41, 20 ) );
211
sbPriority->setMaxValue( 4 );
212
sbPriority->setMinValue( 1 );
213
sbPriority->setValue( 3 );
215
txtSN = new QLineEdit( this, "txtSN" );
216
txtSN->setGeometry( QRect( 140, 240, 130, 23 ) );
218
lblPriority = new QLabel( this, "lblPriority" );
219
lblPriority->setGeometry( QRect( 300, 240, 50, 21 ) );
221
lblSN = new QLabel( this, "lblSequenceName" );
222
lblSN->setGeometry( QRect( 30, 240, 111, 21 ) );
224
Q3BoxLayout *y8 = new Q3HBoxLayout(x);
226
y8->insertWidget(1, lblSN, 10, Qt::AlignRight);
228
y8->insertWidget(3, txtSN, 10, Qt::AlignTop);
230
y8->insertWidget(5, lblPriority, 10, Qt::AlignRight);
232
y8->insertWidget(7, sbPriority, 10, Qt::AlignLeft);
236
//QBoxLayout *y9 = new QHBoxLayout(x);
237
//y9->addSpacing(30);
240
pbCancel = new QPushButton( this, "pbCancel" );
241
pbCancel->setGeometry( QRect( 310, 280, 110, 30 ) );
242
connect(pbCancel, SIGNAL(clicked()), this, SLOT(exitProgram()));
244
pbGO = new QPushButton( this, "pbGO" );
245
pbGO->setGeometry( QRect( 30, 280, 120, 30 ) );
246
connect(pbGO, SIGNAL(clicked()), this, SLOT(pressed()));
248
Q3BoxLayout *y10 = new Q3HBoxLayout(x);
250
y10->insertWidget(1, pbGO, 10, Qt::AlignTop);
251
y10->addSpacing(100);
252
y10->insertWidget(3, pbCancel, 10, Qt::AlignTop);
258
resize( QSize(436, 318).expandedTo(minimumSizeHint()) );
262
* Destroys the object and frees any allocated resources
264
permGenerator::~permGenerator()
266
// no need to delete child widgets, Qt does it all for us
270
* Sets the strings of the subwidgets using the current
273
void permGenerator::languageChange()
275
setCaption( tr( "Permutation Generator" ) );
276
lblZ->setText( tr( "z:" ) );
277
lblX->setText( tr( "x:" ) );
278
lblY->setText( tr( "y:" ) );
282
pbGO->setText( tr( "Submit Jobs" ) );
283
lblContrasts->setText( tr( "Contrast:" ) );
284
lblScale->setText( tr( "Scale:" ) );
285
txtPermNumber->insert("0");
286
lblPermNumber->setText( tr( "Number of Permutations:" ) );
287
lblPseudoT->setText( tr( "Smoothing for Pseudo-t \n"
288
"map (FWHM in Voxels):" ) );
289
lblPermType->setText( tr( " Perm Type:" ) );
290
pbDir->setText( tr( "Select PRM File" ) );
291
lblPriority->setText( tr( "Priority:" ) );
292
lblSN->setText( tr( "Sequence Name:" ) );
293
lblPermDir->setText( tr( "Perm Directory (to be created):" ) );
295
cbScale->addItem("t values");
296
cbScale->addItem("intercept % change");
297
cbScale->addItem("raw beta values");
298
cbScale->addItem("F values");
299
cbScale->addItem("p map for t values");
300
cbScale->addItem("p map for F values");
301
cbScale->addItem("Z map for t values");
302
cbScale->addItem("Z map for F values");
304
cbPermType->addItem("Sign");
305
cbPermType->addItem("Regular");
307
pbCancel->setText( tr( "Cancel" ) );
308
msgboxsetpermnumber = 0;
311
void permGenerator::mod(bool x) {
325
QString permGenerator::getPRMFile() {
326
QString s=Q3FileDialog::getOpenFileName(".","All (*.prm)",this,"open .prm file","Choose a .prm file to load");
327
if (s==QString::null)
331
createfullpath(s.ascii());
332
txtPRM->insert(s.ascii());
333
if (s==QString::null)
339
int commandlineExecute(int argc, char **argv) {
341
string matrixStemName, permDir, sscale, seqname;
342
int method, priority;
344
string contrasts, pseudoT, clist, plist;
346
a.setArgs("-h", "--help", 0);
347
a.setArgs("-m", "--matrixstemname", 1);
348
a.setArgs("-d", "--permdir", 1);
349
a.setArgs("-t", "--method", 1);
350
a.setArgs("-v", "--version", 0);
351
a.setArgs("-n", "--permindex", 1);
352
a.setArgs("-s", "--scale", 1);
353
a.setArgs("-c", "--contrast", 1);
354
a.setArgs("-p", "--pseudot", 3);
355
a.setArgs("-a", "--seqname", 1);
356
a.setArgs("-b", "--priority", 1);
357
a.parseArgs(argc, argv);
358
string errstring = a.badArg();
359
if (errstring.size())
361
matrixStemName = a.getFlaggedArgs("-m")[0];
362
if (matrixStemName.size() == 0) return 2;
363
glmi.setup(matrixStemName);
364
permDir = a.getFlaggedArgs("-d")[0];
365
if (permDir.size() == 0) return 3;
366
method = atoi(a.getFlaggedArgs("-t")[0].c_str());
367
if (a.getFlaggedArgs("-t")[0].size() == 0) return 4;
368
if (a.flagPresent("-v"))
369
printf("\nVoxBo v%s\n",vbversion.c_str());
370
int numPerms = atoi(a.getFlaggedArgs("-n")[0].c_str());
373
VBMatrix headerMatrix;
374
string headerName = xrootname(glmi.stemname) + ".G";
375
headerMatrix.ReadMAT1Header(headerName);
376
double orderG = (double)headerMatrix.m;
377
if (pow(2.0, (orderG-1)) < 1000)
378
maxPerms = (int)pow(2.0, (orderG-1));
381
if (numPerms > maxPerms) return 8;
382
if (a.getFlaggedArgs("-n")[0].size() == 0) return 5;
383
sscale = a.getFlaggedArgs("-s")[0];
384
if (sscale.size() == 0) return 6;
385
seqname = a.getFlaggedArgs("-a")[0];
386
if (seqname.size() == 0) seqname = glmi.stemname;
387
priority = atoi(a.getFlaggedArgs("-b")[0].c_str());
388
if (a.getFlaggedArgs("-b")[0].size() == 0) priority = 3;
389
clist =a.getFlaggedArgs("-c")[0];
390
if (a.getFlaggedArgs("-c")[0].size() == 0) return 7;
391
plist = a.getFlaggedArgs("-p")[0] + " " + a.getFlaggedArgs("-p")[1] + " " + a.getFlaggedArgs("-p")[2];
392
if (a.getFlaggedArgs("-p")[0].size() == 0)
396
char presentDir[STRINGLEN];
397
char temp[STRINGLEN];
398
char tempstring[STRINGLEN];
399
getcwd(presentDir,STRINGLEN-1);
400
strcat(presentDir, "/");
403
//check permutation directory if mat file already exists
404
file = glmi.stemname + "_" + permDir + "/" + "permutations.mat";
405
//clist = "'" + clist + "'";
407
if (glmi.parsecontrast(clist) != 0) {
408
errstring = "contrast: failed to derive a valid contrast from " + clist;
409
printErrorMsg(VB_ERROR, errstring.c_str());
414
for (int index = 0; index < glmi.contrast.contrast.size(); index++) {
415
sprintf(tempstring, "%1.0f", glmi.contrast.contrast[index]);
416
if (index != 0) contrasts += " ";
417
contrasts += tempstring;
422
errstring = "contrast: no contrast values were supplied.";
423
printErrorMsg(VB_ERROR, errstring.c_str());
427
for (int index = 0; index < glmi.contrast.contrast.size(); index++) {
428
sprintf(tempstring, "%1.0f", glmi.contrast.contrast[index]);
429
if (index != 0) clist += " ";
433
if (!sscale.size()) {
434
if (glmi.contrast.scale.size())
435
sscale = glmi.contrast.scale;
437
errstring = "vbpermgen: no scale was provided.";
438
printErrorMsg(VB_ERROR, errstring.c_str());
442
if (!(validscale(sscale)) && sscale.size()) {
443
errstring = "contrast: invalid scale passed: " + sscale;
444
printErrorMsg(VB_ERROR, errstring.c_str());
447
plist = "'" + plist + "'";
449
pc.AddMatrixStemName(glmi.stemname);
450
pc.AddPermDir(permDir);
452
pc.AddMethod(method);
453
pc.AddContrastlist(contrasts);
454
pc.AddPseudoTList(plist);
455
pc.AddPseudoTOnOff(onOff);
456
pc.SetFileName("perminfo.txt");
457
pc.AddPrmTimeStamp(glmi.stemname);
458
if (stat(file.c_str(), &my_stat) != 0)
461
memset((void*)&my_stat, 0, sizeof(my_stat));
466
for (int permIndex = 0; permIndex < numPerms; permIndex++) {
468
js.arguments.clear();
470
js.jobtype="permstep";
472
js.jobtype="permstep2";
474
// Modified by Dongbo to add the argument title ina dumb way (10/12/2005)
475
// js.arguments.Add(glmi.stemname);
476
// js.arguments.Add(permDir);
477
// sprintf(temp, "%d", method);
478
// js.arguments.Add(temp);
479
// sprintf(temp, "%s", scale.c_str());
480
// js.arguments.Add(temp);
481
// js.arguments.Add(clist);
482
// js.arguments.Add(plist);
483
// sprintf(temp, "%d", permIndex);
484
// js.arguments.Add(temp);
485
js.arguments["matrixstemname"]=glmi.stemname;
486
js.arguments["permdir"]=permDir;
487
js.arguments["permtype"]=strnum(method);
488
// FIXME steps is set to sscale???
489
js.arguments["steps"]=temp;
490
js.arguments["contrast"]=clist;
491
js.arguments["pseudot"]=plist;
492
js.arguments["permindex"]=strnum(permIndex);
495
js.name=permDir+temp;
496
js.dirname = presentDir;
503
js.arguments.clear();
504
js.jobtype="permfinish";
506
// Modified by Dongbo too (10/12/2005)
507
// js.arguments.Add(glmi.stemname + "_" + permDir + "/" + "iterations/permcube");
508
// js.arguments.Add(glmi.stemname + "_" + permDir + "/results.ref");
509
js.arguments["permstemname"]=glmi.stemname + "_" + permDir + "/" + "iterations/permcube";
510
js.arguments["resultsfile"]=glmi.stemname + "_" + permDir + "/results.ref";
514
js.dirname = presentDir;
516
for (int i=0; i<=count; i++)
517
js.waitfor.insert(i);
520
if (seq.name.size() == 0)
521
seq.name="perm"+matrixStemName;
522
seq.priority = priority;
523
seq.seqnum = (int)getpid();
525
if (seq.Submit(vbp) == 0) {
526
errstring = "vbpermgen successfully submitted the sequence.";
527
printErrorMsg(VB_INFO, errstring.c_str());
530
errstring = "vbpermgen failed to submit the sequence.";
531
printErrorMsg(VB_ERROR, errstring.c_str());
536
runseq(vbp,seq,vbp.cores);
541
void permGenerator::pressed() {
543
char presentDir[STRINGLEN];
544
char temp[STRINGLEN];
545
char tempstring[STRINGLEN];
546
getcwd(presentDir,STRINGLEN-1);
547
strcat(presentDir, "/");
548
string matrixStemName = txtPRM->text().latin1();
549
string permDir = txtPermDir->text().latin1();
550
string scale = cbScale->currentText().latin1();
551
int method = 2-(cbPermType->currentItem()); //methods start at 1, not 0
552
int numPerms = atoi(txtPermNumber->text());
553
string contrasts = txtContrasts->text().latin1();
554
string clist = contrasts;
556
glmi.setup(matrixStemName);
557
if (glmi.parsecontrast(clist) != 0) {
558
string errstring = "contrast: failed to derive a valid contrast from " + clist + "\n";
559
QMessageBox::warning( this, "Warning!", errstring.c_str());
564
for (int index = 0; index < glmi.contrast.contrast.size(); index++) {
565
sprintf(tempstring, "%1.0f", glmi.contrast.contrast[index]);
566
if (index != 0) contrasts += " ";
567
contrasts += tempstring;
572
string errstring = "contrast: no contrast values were supplied.\n";
573
QMessageBox::warning( this, "Warning!", errstring.c_str());
577
for (int index = 0; index < glmi.contrast.contrast.size(); index++) {
578
sprintf(tempstring, "%1.0f", glmi.contrast.contrast[index]);
579
if (index != 0) clist += " ";
584
if (glmi.contrast.scale.size())
585
scale = glmi.contrast.scale;
587
string errstring = "vbpermgen: no scale was provided.";
588
printErrorMsg(VB_ERROR, errstring.c_str());
592
if (scale == "t values") scale = "t";
593
else if (scale == "intercept % change") scale = "i";
594
else if (scale == "raw beta values") scale = "rb";
595
else if (scale == "F values") scale = "f";
596
else if (scale == "p map for t values") scale = "tp";
597
else if (scale == "p map for F values") scale = "fp";
598
else if (scale == "Z map for t values") scale = "tz";
599
else if (scale == "Z map for F values") scale = "fz";
600
if (!(validscale(scale)) && scale.size()) {
601
string errstring = "contrast: invalid scale passed: " + scale;
602
QMessageBox::warning( this, "Warning!", errstring.c_str());
605
string pseudoT = (string)txtX->text().latin1() + " " + txtY->text().latin1() + " " + txtZ->text().latin1();
606
if (!txtX->isEnabled())
608
string plist = "'" + pseudoT + "'";
610
pc.AddMatrixStemName(glmi.stemname);
611
pc.AddPermDir(permDir);
613
pc.AddMethod(method);
614
pc.AddContrastlist(contrasts);
615
pc.AddPseudoTList(pseudoT);
616
pc.AddPseudoTOnOff(txtX->isEnabled());
617
pc.AddPrmTimeStamp(glmi.stemname);
618
pc.SetFileName("perminfo.txt");
619
if (matrixStemName.size() == 0) {
620
QMessageBox::warning( this, "Warning!", "Must specify the matrix stem name (glm directory).\n");
623
if (permDir.size() == 0) {
624
QMessageBox::warning( this, "Warning!", "Must specify the permutation directory name.\n");
627
if ((method < 0) || (method > 2)) {
628
QMessageBox::warning( this, "Warning!", "Must specify the permutation method.\n");
631
if ((scale != "t") && (scale != "i") && (scale != "rb") && (scale != "f") && (scale != "tp") &&
632
(scale != "fp") && (scale != "tz") && (scale != "fz")) {
633
QMessageBox::warning( this, "Warning!", "Must specify the scale. For list of scales, type permgen -h.\n");
638
//check permutation directory if mat file already exists
639
file = glmi.stemname + "_" + permDir + "/" + "permutations.mat";
640
// FIXME if permstart returns an error, we're in trouble. but
641
// really this should be a job instead.
642
if (stat(file.c_str(), &my_stat) != 0)
645
memset((void*)&my_stat, 0, sizeof(my_stat));
650
for (int permIndex = 0; permIndex < numPerms; permIndex++) {
652
js.arguments.clear();
654
js.jobtype="permstep";
656
js.jobtype="permstep2";
658
// Modified by Dongbo to add the argument title ina dumb way (10/12/2005)
659
// js.arguments.Add(glmi.stemname);
660
// js.arguments.Add(permDir);
661
// sprintf(temp, "%d", method);
662
// js.arguments.Add(temp);
663
// sprintf(temp, "%s", scale.c_str());
664
// js.arguments.Add(temp);
665
// js.arguments.Add(clist);
666
// js.arguments.Add(plist);
667
// sprintf(temp, "%d", permIndex);
668
// js.arguments.Add(temp);
669
js.arguments["matrixstemname"]=glmi.stemname;
670
js.arguments["permdir"]=permDir;
671
js.arguments["permtype"]=strnum(method);
672
// FIXME steps = scale???
673
js.arguments["steps"]=scale;
674
js.arguments["contrast"]=clist;
675
js.arguments["pseudot"]=plist;
676
js.arguments["permindex"]=strnum(permIndex);
678
// FIXME following flag line is totally broken
679
// if (method == 2) js.arguments.Add("-e");
681
js.name=permDir+temp;
682
js.dirname = presentDir;
689
js.arguments.clear();
690
js.jobtype="permfinish";
692
// Modified by Dongbo too (10/12/2005)
693
// js.arguments.Add(glmi.stemname + "_" + permDir + "/" + "iterations/permcube");
694
// js.arguments.Add(glmi.stemname + "_" + permDir + "/results.ref");
695
js.arguments["permstemname"]=glmi.stemname + "_" + permDir + "/" + "iterations/permcube";
696
js.arguments["resultsfile"]=glmi.stemname + "_" + permDir + "/results.ref";
700
js.dirname = presentDir;
702
for (int i=0; i<=count; i++)
703
js.waitfor.insert(i);
705
seq.name=txtSN->text().ascii();
706
if (seq.name.size() == 0)
707
seq.name="perm"+matrixStemName;
708
seq.priority = sbPriority->value();
709
seq.seqnum = (int)getpid();
711
if (seq.Submit(vbp) == 0) {
712
QMessageBox::warning( this, "Information", "The requested sequence was submitted.\n");
716
QMessageBox::warning( this, "Information", "The requested sequence failed to submit.\n");
721
runseq(vbp,seq,vbp.cores);
723
msgboxsetpermnumber = 0;
727
int permGenerator::warnCalculateNumPerms() {
728
if (msgboxsetpermnumber) return 1;
729
VBMatrix headerMatrix;
733
string matrixStemName;
734
if (txtPRM->text().length())
735
matrixStemName = txtPRM->text().ascii();
737
matrixStemName = tempPRM;
738
string headerName = xrootname(matrixStemName) + ".G";
739
if (stat(headerName.c_str(),&my_stat)) {
742
headerMatrix.ReadMAT1Header(headerName);
743
double orderG = (double)headerMatrix.m;
744
if (pow(2.0, (orderG-1)) < 1000)
745
numPerms = (int)pow(2.0, (orderG-1));
751
sprintf(num, "%d", numPerms);
752
sprintf(obs, "%d", (int)orderG);
753
sprintf(old, "%d", atoi(txtPermNumber->text().ascii()));
757
string msg = "Maximum permutations is " + snum + " based on your data.\n Do you want to generate the " + snum + " possible?";
758
if (atoi(txtPermNumber->text().ascii()) > numPerms) {
759
QMessageBox mb( "vbpermgen",
761
QMessageBox::Information,
762
QMessageBox::Yes | QMessageBox::Default,
764
QMessageBox::Cancel | QMessageBox::Escape );
765
mb.setButtonText( QMessageBox::Yes, "Replace" );
766
mb.setButtonText( QMessageBox::No, "Abort" );
767
switch( mb.exec() ) {
768
case QMessageBox::Yes:
769
msgboxsetpermnumber = 1;
770
txtPermNumber->clear();
771
txtPermNumber->insert(num);
772
msgboxsetpermnumber = 0;
775
case QMessageBox::No:
776
msgboxsetpermnumber = 1;
777
txtPermNumber->clear();
778
txtPermNumber->insert("0");
779
msgboxsetpermnumber = 0;
782
case QMessageBox::Cancel:
783
msgboxsetpermnumber = 1;
784
txtPermNumber->clear();
785
txtPermNumber->insert("0");
786
msgboxsetpermnumber = 0;
794
void permGenerator::CalculateNumPerms() {
795
if (msgboxsetpermnumber) return;
796
VBMatrix headerMatrix;
800
string matrixStemName;
801
if (txtPRM->text().length())
802
matrixStemName = txtPRM->text().ascii();
804
matrixStemName = tempPRM;
805
string headerName = xrootname(matrixStemName) + ".G";
806
if (stat(headerName.c_str(),&my_stat)) {
809
headerMatrix.ReadMAT1Header(headerName);
810
double orderG = (double)headerMatrix.m;
811
if (pow(2.0, (orderG-1)) < 1000)
812
numPerms = (int)pow(2.0, (orderG-1));
816
sprintf(num, "%d", numPerms);
817
txtPermNumber->clear();
818
txtPermNumber->insert(num);
822
void permGenerator::closeEvent( QCloseEvent *ce ){
827
void permGenerator::exitProgram() {