added option for output directory
@@ -40,6 +40,7 @@ namespace
(ebi::vcf::INPUT_OPTION, po::value<std::string>()->default_value(ebi::vcf::STDIN), "Path to the input VCF file, or stdin")
(ebi::vcf::FASTA_OPTION, po::value<std::string>(), "Path to the input FASTA file; please note that the index file must have the same name as the FASTA file and saved with a .idx extension")
(ebi::vcf::REPORT_OPTION, po::value<std::string>()->default_value(ebi::vcf::SUMMARY), "Comma separated values for types of reports (summary, text, valid)")
+ (ebi::vcf::OUTDIR_OPTION, po::value<std::string>()->default_value(""), "Output directory")
;
return description;
@@ -72,6 +73,23 @@ namespace
return 0;
}
+ std::string get_output_path(const std::string &outdir, const std::string &file_path)
+ {
+ if (outdir == "") {
+ return file_path;
+ }
+
+ boost::filesystem::path file_boost_path{file_path};
+ boost::filesystem::path outdir_boost_path{outdir};
+ if (!boost::filesystem::is_directory(outdir_boost_path)) {
+ throw std::invalid_argument{"outdir should be a directory, not a file: " + outdir_boost_path.string()};
+ }
+
+ outdir_boost_path /= file_boost_path.filename();
+
+ return outdir_boost_path.string();
+ }
+
std::vector<std::unique_ptr<ebi::vcf::AssemblyReportWriter>> get_outputs(std::string const &output_str,
std::string const &input)
{
@@ -144,7 +162,8 @@ int main(int argc, char** argv)
auto vcf_path = vm[ebi::vcf::INPUT].as<std::string>();
auto fasta_path = vm[ebi::vcf::FASTA].as<std::string>();
auto fasta_index_path = fasta_path + ".fai";
- auto outputs = get_outputs(vm[ebi::vcf::REPORT].as<std::string>(), vcf_path);
+ auto outdir = get_output_path(vm[ebi::vcf::OUTDIR].as<std::string>(), vcf_path);
+ auto outputs = get_outputs(vm[ebi::vcf::REPORT].as<std::string>(), outdir);
BOOST_LOG_TRIVIAL(info) << "Reading from input FASTA file...";
std::ifstream fasta_input;
