2727
2828#include < sharg/all.hpp>
2929
30+ #include " shared_options.hpp"
31+
3032// --------------------------------------------------------------------------
3133// Class LambdaIndexerOptions
3234// --------------------------------------------------------------------------
@@ -54,17 +56,26 @@ struct LambdaIndexerOptions : public SharedOptions
5456// INDEXER
5557void parseCommandLine (LambdaIndexerOptions & options, int argc, char const ** argv)
5658{
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;
5861
5962 // 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." };
6171
6272 sharg::parser parser (programName, argc, argv, sharg::update_notifications::off);
6373
6474 parser.info .short_description = " the Local Aligner for Massive Biological DatA" ;
6575
6676 // 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" );
6879
6980 parser.info .description .push_back (" This is the indexer command for creating lambda-compatible databases." );
7081
@@ -162,51 +173,45 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
162173 std::string alphabetReductionTmp;
163174 int geneticCodeTmp = 1 ;
164175
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 )
184177 {
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 ;
210215 }
211216
212217 parser.add_section (" Remarks" );
@@ -222,7 +227,7 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
222227 options.indexFileOptions .indexType = DbIndexType::FM_INDEX;
223228
224229 // set options for protein alphabet, genetic code and alphabet reduction
225- if (! options.nucleotide_mode )
230+ if (options.domain == domain_t ::protein )
226231 {
227232 options.indexFileOptions .origAlph = _alphabetNameToEnum (inputAlphabetTmp);
228233 if (alphabetReductionTmp == " none" )
@@ -231,13 +236,6 @@ void parseCommandLine(LambdaIndexerOptions & options, int argc, char const ** ar
231236 options.indexFileOptions .redAlph = _alphabetNameToEnum (alphabetReductionTmp);
232237 options.indexFileOptions .geneticCode = static_cast <bio::alphabet::genetic_code>(geneticCodeTmp);
233238 }
234- else
235- {
236- if (alphabetReductionTmp == " none" )
237- options.indexFileOptions .redAlph = AlphabetEnum::DNA5;
238- else
239- options.indexFileOptions .redAlph = _alphabetNameToEnum (alphabetReductionTmp);
240- }
241239
242240 setEnv (" TMPDIR" , options.tmpdir );
243241
0 commit comments