Repository navigation
Expand file tree
/
Copy pathPseCUI.cpp
More file actions
120 lines (110 loc) · 5.82 KB
/
Copy pathPseCUI.cpp
File metadata and controls
120 lines (110 loc) · 5.82 KB
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
/****************************************************************************
* PseCUI.cpp - Copyright 2017 Pu-Feng Du, Ph.D. *
* *
* This file is a part of the software: UltraPse *
* UltraPse is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* UltraPse is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with UltraPse. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#include "PseCUI.h"
#include "PseTask.h"
const char *argp_program_version = "UltraPse v1.0";
const char *argp_program_bug_address = "Dr. Pu-Feng Du: <PufengDu@gmail.com>";
const char *_cmd_lambda_name = "_cmd_lambda";
const char *_cmd_omega_name = "_cmd_omega";
const char *_cmd_subtype = "_cmd_subtype";
const char *_cmd_ktuple = "_cmd_ktuple";
namespace UltraPse
{
char doc[] = "UltraPse -- An ultra-fast extensible software platform for biological sequence representations.";
char args_doc[] = "";
/* The options we understand. */
struct argp_option options[] =
{
{"in", 'i', "FILE", 0, "A FASTA format file for input. The comment line of a sequence in this file should be unique. If you do not specify an in-file, the program will try to read it from keyboard."},
{"out", 'o', "FILE", 0, "A file for storing the results. If you do not specify an out-file, the results will be written on screen." },
{"note",'n',"{stdprot|didna|dirna|tridna} ", 0,"Sequence definition types. There are four internal types. If the user want to use their own sequence type, a task definition file id required."},
{"format", 'f', "{svm|tsv|csv}", 0,"Output format."},
{"mode",'m',"{comp|pse|dpc|cov|lua|pseb3|user,LIB_OBJECT,MOD_NAME}", 0, "Representation module choices. This option can appear for multiple times."},
{"user-task", 'u', "TASK-FILE", 0, "Task description file."},
{"query", 'q', "{prop|mode|note|all}",0,"Query status of everything."},
{"property", 'p', "PROP-ID", 0, "Activate the property PROP-ID for current task. This option can appear for multiple times."},
{"omega", 'w', "W", 0, "A mode specific option. Omega parameter in the pse module. This option can have user defined purpose."},
{"lambda", 'l', "L", 0, "A mode specific option. Lambda parameter in the pse module. This option can have user defined purpose."},
{"type",'t',"T",0, "A mode specific option. Type parameter in the pse / cov module. This option can have user defined purpose."},
{"k-tuple",'k',"K",0,"A mode specific option. Currently not used in internal modules. This option can have user defined purpose."},
{"arguments",'a',"LUA-EXPR",0,"Lua expression to provide extra module-specific parameters. This option can appear for multiple times."},
{"validate",'v',0,0,"Validate sequences automatically. Sequence with invalid notations will be dropped automatically."},
{ 0 }
};
error_t parse_opt (int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
PseTask *CurrentTask = (PseTask*)(state->input);
switch (key)
{
case 'i':
CurrentTask->SetInputFile(arg);
break;
case 'o':
CurrentTask->SetOutputFile(arg);
break;
case 'f':
CurrentTask->SetOutputFormat(arg);
break;
case 'n':
CurrentTask->SetNotationName(arg);
break;
case 'm':
CurrentTask->AddModule(arg);
break;
case 'u':
CurrentTask->SetTaskFile(arg);
break;
case 'q':
CurrentTask->ActivateQueryMode(arg);
break;
case 'p':
CurrentTask->AddProperty(arg);
break;
case 'w':
CurrentTask->AddExtraPara(_cmd_omega_name, arg);
break;
case 'l':
CurrentTask->AddExtraPara(_cmd_lambda_name, arg);
break;
case 't':
CurrentTask->AddExtraPara(_cmd_subtype, arg);
break;
case 'k':
CurrentTask->AddExtraPara(_cmd_ktuple, arg);
break;
case 'a':
CurrentTask->SetLuaExpr(arg);
break;
case 'v':
CurrentTask->SetValidate(true);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
struct argp argp = { options, parse_opt, args_doc, doc };
PseTask *ParseCUI(int argc, char *argv[])
{
PseTask *r = new PseTask();
argp_parse(&argp, argc, argv, 0, 0, r);
return r;
}
};