27
27
28
28
#include < sharg/all.hpp>
29
29
30
+ #include " shared_options.hpp"
31
+
30
32
// --------------------------------------------------------------------------
31
33
// Class LambdaIndexerOptions
32
34
// --------------------------------------------------------------------------
@@ -54,17 +56,26 @@ struct LambdaIndexerOptions : public SharedOptions
54
56
// INDEXER
55
57
void parseCommandLine (LambdaIndexerOptions & options, int argc, char const ** argv)
56
58
{
57
- std::string programName = " lambda3-" + std::string (argv[0 ]);
59
+ std::string const subcommand = std::string (argv[0 ]);
60
+ std::string const programName = " lambda3-" + subcommand;
58
61
59
62
// this is important for option handling:
60
- options.nucleotide_mode = (std::string (argv[0 ]) == " mkindexn" );
63
+ if (subcommand == " mkindexp" )
64
+ options.domain = domain_t ::protein;
65
+ else if (subcommand == " mkindexn" )
66
+ options.domain = domain_t ::nucleotide;
67
+ else if (subcommand == " mkindexbs" )
68
+ options.domain = domain_t ::bisulfite;
69
+ else
70
+ throw std::runtime_error{" Unknown subcommand." };
61
71
62
72
sharg::parser parser (programName, argc, argv, sharg::update_notifications::off);
63
73
64
74
parser.info .short_description = " the Local Aligner for Massive Biological DatA" ;
65
75
66
76
// Define usage line and long description.
67
- parser.info .synopsis .push_back (" [\\ fIOPTIONS\\ fP] \\ -d DATABASE.fasta [-i INDEX.lba]\\ fP" );
77
+ parser.info .synopsis .push_back (" lambda3 " s + subcommand +
78
+ " [\\ fIOPTIONS\\ fP] \\ -d DATABASE.fasta [-i INDEX.lba]\\ fP" );
68
79
69
80
parser.info .description .push_back (" This is the indexer command for creating lambda-compatible databases." );
70
81
@@ -162,51 +173,45 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
162
173
std::string alphabetReductionTmp;
163
174
int geneticCodeTmp = 1 ;
164
175
165
- if (options.nucleotide_mode )
166
- {
167
- alphabetReductionTmp = " dna4" ;
168
- options.indexFileOptions .origAlph = AlphabetEnum::DNA5;
169
- options.indexFileOptions .transAlph = AlphabetEnum::DNA5;
170
- options.indexFileOptions .redAlph = AlphabetEnum::DNA4;
171
-
172
- parser.add_section (" Alphabet reduction" );
173
-
174
- parser.add_option (alphabetReductionTmp,
175
- sharg::config{
176
- .short_id = ' r' ,
177
- .long_id = " alphabet-reduction" ,
178
- .description = " Alphabet Reduction for seeding phase." ,
179
- .advanced = true ,
180
- .validator = sharg::value_list_validator{" none" , " dna4" , " dna3bs" }
181
- });
182
- }
183
- else
176
+ switch (options.domain )
184
177
{
185
- alphabetReductionTmp = " li10" ;
186
- options.indexFileOptions .origAlph = AlphabetEnum::UNDEFINED;
187
- options.indexFileOptions .transAlph = AlphabetEnum::AMINO_ACID;
188
- options.indexFileOptions .redAlph = AlphabetEnum::LI10;
189
-
190
- parser.add_section (" Alphabet and Translation" );
191
-
192
- parser.add_option (inputAlphabetTmp,
193
- sharg::config{
194
- .short_id = ' a' ,
195
- .long_id = " input-alphabet" ,
196
- .description = " Alphabet of the database sequences (specify to override auto-detection); "
197
- " if input is Dna, it will be translated." ,
198
- .advanced = true ,
199
- .validator = sharg::value_list_validator{" auto" , " dna5" , " aminoacid" }
200
- });
201
-
202
- parser.add_option (alphabetReductionTmp,
203
- sharg::config{
204
- .short_id = ' r' ,
205
- .long_id = " alphabet-reduction" ,
206
- .description = " Alphabet Reduction for seeding phase." ,
207
- .advanced = true ,
208
- .validator = sharg::value_list_validator{" none" , " murphy10" , " li10" }
209
- });
178
+ case domain_t ::protein:
179
+ alphabetReductionTmp = " li10" ;
180
+ options.indexFileOptions .origAlph = AlphabetEnum::UNDEFINED;
181
+ options.indexFileOptions .transAlph = AlphabetEnum::AMINO_ACID;
182
+ options.indexFileOptions .redAlph = AlphabetEnum::LI10;
183
+
184
+ parser.add_section (" Alphabet and Translation" );
185
+
186
+ parser.add_option (inputAlphabetTmp,
187
+ sharg::config{
188
+ .short_id = ' a' ,
189
+ .long_id = " input-alphabet" ,
190
+ .description = " Alphabet of the database sequences (specify to override "
191
+ " auto-detection); if input is Dna, it will be translated." ,
192
+ .advanced = true ,
193
+ .validator = sharg::value_list_validator{" auto" , " dna5" , " aminoacid" }
194
+ });
195
+
196
+ parser.add_option (alphabetReductionTmp,
197
+ sharg::config{
198
+ .short_id = ' r' ,
199
+ .long_id = " alphabet-reduction" ,
200
+ .description = " Alphabet Reduction for seeding phase." ,
201
+ .advanced = true ,
202
+ .validator = sharg::value_list_validator{" none" , " murphy10" , " li10" }
203
+ });
204
+ break ;
205
+ case domain_t ::nucleotide:
206
+ options.indexFileOptions .origAlph = AlphabetEnum::DNA5;
207
+ options.indexFileOptions .transAlph = AlphabetEnum::DNA5;
208
+ options.indexFileOptions .redAlph = AlphabetEnum::DNA4;
209
+ break ;
210
+ case domain_t ::bisulfite:
211
+ options.indexFileOptions .origAlph = AlphabetEnum::DNA5;
212
+ options.indexFileOptions .transAlph = AlphabetEnum::DNA5;
213
+ options.indexFileOptions .redAlph = AlphabetEnum::DNA3BS;
214
+ break ;
210
215
}
211
216
212
217
parser.add_section (" Remarks" );
@@ -222,7 +227,7 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
222
227
options.indexFileOptions .indexType = DbIndexType::FM_INDEX;
223
228
224
229
// set options for protein alphabet, genetic code and alphabet reduction
225
- if (! options.nucleotide_mode )
230
+ if (options.domain == domain_t ::protein )
226
231
{
227
232
options.indexFileOptions .origAlph = _alphabetNameToEnum (inputAlphabetTmp);
228
233
if (alphabetReductionTmp == " none" )
@@ -231,13 +236,6 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
231
236
options.indexFileOptions .redAlph = _alphabetNameToEnum (alphabetReductionTmp);
232
237
options.indexFileOptions .geneticCode = static_cast <bio::alphabet::genetic_code>(geneticCodeTmp);
233
238
}
234
- else
235
- {
236
- if (alphabetReductionTmp == " none" )
237
- options.indexFileOptions .redAlph = AlphabetEnum::DNA5;
238
- else
239
- options.indexFileOptions .redAlph = _alphabetNameToEnum (alphabetReductionTmp);
240
- }
241
239
242
240
setEnv (" TMPDIR" , options.tmpdir );
243
241
0 commit comments