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 Kosh Banerjee
31
void usage(const unsigned short exitValue, char *progName);
33
gsl_rng *theRNG = NULL;
35
int main(int argc, char *argv[]) {
42
string matrixStemName;
46
/*********************************************************************
47
* Now processing the command line options. *
49
* -h ==> Display usage information. *
50
* -m ==> Specifies the matrix stem name. *
51
* -d ==> Permutation directory. *
52
* -t ==> Permutation type. *
53
* -v ==> Print out the gobal VoxBo version number. *
56
* printHelp - a flag, used to determine if the "-h" command line *
57
* option was used or not. *
58
* printVersion - a flag, used to determine if the "-v" command line *
59
* option was used or not. *
60
*********************************************************************/
63
a.setArgs("-h", "--help", 0);
64
a.setArgs("-m", "--matrixstemname", 1);
65
a.setArgs("-d", "--permdir", 1);
66
a.setArgs("-t", "--method", 1);
67
a.setArgs("-v", "--version", 0);
68
a.parseArgs(argc, argv);
69
string errstring = a.badArg();
70
if (errstring.size()) {
71
errstring = "[E] unknown flag: " + errstring;
72
printErrorMsg(VB_ERROR, errstring.c_str());
75
if (a.flagPresent("-h"))
77
matrixStemName = a.getFlaggedArgs("-m")[0];
78
permDir = a.getFlaggedArgs("-d")[0];
79
method = atoi(a.getFlaggedArgs("-t")[0].c_str());
80
if (a.flagPresent("-v"))
81
printf("\nVoxBo v%s\n",vbversion.c_str());
82
if (matrixStemName.size() == 0) {
83
ostringstream errorMsg;
84
errorMsg << "Must specify the matrix stem name, using the \"-m\" option.";
85
printErrorMsgAndExit(VB_ERROR, errorMsg, 1);
87
if (permDir.size() == 0) {
88
ostringstream errorMsg;
89
errorMsg << "Must specify the permutation directory name, using the \"-d\" option.";
90
printErrorMsgAndExit(VB_ERROR, errorMsg, 1);
92
if ((method < 0) || (method > 2)) {
93
ostringstream errorMsg;
94
errorMsg << "The \"-t\" argument must be 1 or 2, not [" << method << "].";
95
printErrorMsgAndExit(VB_ERROR, errorMsg, 1);
98
glmi.setup(matrixStemName);
99
pc.AddMatrixStemName(glmi.stemname);
100
pc.AddPermDir(permDir);
101
pc.AddMethod(method);
107
printErrorMsg(VB_ERROR, "permstart: no stem name specified.\n");
110
printErrorMsg(VB_ERROR, "permstart: no perm directory specified.\n");
113
printErrorMsg(VB_ERROR, "permstart: prm file not valid.\n");
116
printErrorMsg(VB_ERROR, "permstart: g matrix file not readable.\n");
119
printErrorMsg(VB_ERROR, "permstart: MAT1 header not valid.\n");
122
printErrorMsg(VB_ERROR, "permstart: failed to allocate permutation.\n");
125
printErrorMsg(VB_ERROR, "permstart: bad permuation type.\n");
128
printErrorMsg(VB_ERROR, "permstart: failed to make subdirectory.\n");
131
printErrorMsg(VB_ERROR, "permstart: failed to make permutation matrix.\n");
134
printErrorMsg(VB_ERROR, "permstart: permutation matrix is not valid.\n");
137
printErrorMsg(VB_ERROR, "permstart: failed to write permutation matrix file.\n");
140
printErrorMsg(VB_ERROR, "permstart: unknown error.\n");
146
void usage(const unsigned short exitValue, char *progName) {
147
printf("\nVoxBo permstart (v%s)\n",vbversion.c_str());
149
printf(" Permutation start.\n");
151
printf(" permstart -h -m[matrix stem name] -d[permutation directory] -t[permutation type] -v\n");
153
printf(" -h Print usage information. Optional.\n");
154
printf(" -m <matrix stem name> Specify the matrix stem name. Required.\n");
155
printf(" -d Permutation directory name. Required.\n");
156
printf(" -t Permutation type. 1 means regular permutation.\n");
157
printf(" 2 means sign permutation. Required.\n");
158
printf(" -v Global VoxBo version number. Optional.\n\n");