Skip to content

Commit

Permalink
Optionally remove empty variants during file conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
dcdehaas committed Jul 23, 2024
1 parent c3f39f7 commit 55ec166
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static void mutationIteratorToIGD(const std::string& inFilename,
const double fnPerVariant = 0,
const size_t trimToSamples = 0,
std::string keepIndividualFile = "",
bool removeEmpty = false,
bool verbose = true) {
constexpr size_t EMIT_EVERY = 10000;

Expand Down Expand Up @@ -188,6 +189,9 @@ static void mutationIteratorToIGD(const std::string& inFilename,
}
trim(mutAndSamples.samples, trimToSamples);
mutAndSamples.samples = trimIndividuals(std::move(mutAndSamples.samples), ploidy, keepIndividuals);
if (removeEmpty && mutAndSamples.samples.empty()) {
continue;
}
if (fpPerVariant + fnPerVariant > 0) {
const double fp = fpPerVariant + fpLeftovers;
const size_t fpThisVariant = (size_t)fp;
Expand Down Expand Up @@ -238,6 +242,7 @@ int main(int argc, char* argv[]) {
"keepIndivs",
"Only retain the individuals with the IDs given in this file (one ID per line).",
{'i', "keep-indivs"});
args::Flag removeEmpty(parser, "removeEmpty", "Remove empty alternate alleles.", {'e', "remove-empty"});
try {
parser.ParseCLI(argc, argv);
} catch (args::Help&) {
Expand Down Expand Up @@ -291,6 +296,8 @@ int main(int argc, char* argv[]) {
falseNegPerVariant ? *falseNegPerVariant : 0,
falsePosPerVariant ? *falsePosPerVariant : 0,
trimTo ? *trimTo : 0,
keepIndivs ? *keepIndivs : "");
keepIndivs ? *keepIndivs : "",
removeEmpty,
/*verbose=*/true);
return 0;
}

0 comments on commit 55ec166

Please sign in to comment.