From 144874ddad15e5bc4cdba5561c060e426c4bcaf5 Mon Sep 17 00:00:00 2001 From: jonathonl Date: Thu, 9 Nov 2023 15:23:08 -0500 Subject: [PATCH] Adds --min-ratio-behavior option to allow for skipping chunks with low number of target sites. --- src/main.cpp | 9 ++++++++- src/prog_args.hpp | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6069268..e6e7c12 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,7 +80,14 @@ class imputation float tar_ref_ratio = float(typed_only_reference_data.variant_size()) / float(full_reference_data.variant_size()); std::cerr << "Typed sites to imputed sites ratio: " << tar_ref_ratio << " (" << typed_only_reference_data.variant_size() << "/" << full_reference_data.variant_size() << ")\n"; if (tar_ref_ratio < args.min_ratio()) - return std::cerr << "Error: not enough target variants are available to impute this chunk. The --min-ratio, --chunk, or --region options may need to be altered.\n", false; + { + std::cerr << (args.fail_min_ratio() ? "Error" : "Warning") << ": not enough target variants are available to impute this chunk. The --min-ratio, --chunk, or --region options may need to be altered." << std::endl; + if (!args.fail_min_ratio()) + std::cerr << "Warning: skipping chunk " << impute_region.chromosome() << ":" << impute_region.from() << "-" << impute_region.to() << std::endl; + if (args.fail_min_ratio()) + return false; + return true; // skip + } if (target_only_sites.size()) { diff --git a/src/prog_args.hpp b/src/prog_args.hpp index c433902..882c074 100644 --- a/src/prog_args.hpp +++ b/src/prog_args.hpp @@ -46,6 +46,7 @@ class prog_args : public getopt_wrapper bool compress_reference_ = false; bool pass_only_ = false; bool meta_ = false; // deprecated + bool fail_min_ratio_ = true; bool help_ = false; bool version_ = false; @@ -81,6 +82,7 @@ class prog_args : public getopt_wrapper bool update_m3vcf() const { return update_m3vcf_; } bool compress_reference() const { return compress_reference_; } bool pass_only() const { return pass_only_; } + bool fail_min_ratio() const { return fail_min_ratio_; } prog_args() : getopt_wrapper( @@ -106,6 +108,7 @@ class prog_args : public getopt_wrapper {"decay", required_argument, 0, '\x02', "Decay rate for dosages in flanking regions (default: disabled with 0)"}, {"min-r2", required_argument, 0, '\x02', "Minimum estimated r-square for output variants"}, {"min-ratio", required_argument, 0, '\x02', "Minimum ratio of number of target sites to reference sites (default: 0.00001)"}, + {"min-ratio-behavior", required_argument, 0, '\x02', "Behavior for when --min-ratio is not met (\"skip\" or \"fail\"; default: fail)"}, // maybe add "warn" {"match-error", required_argument, 0, '\x02', "Error parameter for HMM match probabilities (default: 0.01)"}, {"min-recom", required_argument, 0, '\x02', "Minimum recombination probability (default: 0.00001)"}, {"prob-threshold", required_argument, 0, '\x02', "Probability threshold used for template selection"}, @@ -299,6 +302,11 @@ class prog_args : public getopt_wrapper min_ratio_ = std::min(1., std::max(0., std::atof(optarg ? optarg : ""))); break; } + else if (long_opt_str == "min-ratio-behavior") + { + fail_min_ratio_ = std::string(optarg ? optarg : "") == "fail"; + break; + } else if (long_opt_str == "match-error") { error_param_ = std::min(0.5, std::max(0., std::atof(optarg ? optarg : "")));