From b4206615ce87929ed3b841294020e21854a72e2e Mon Sep 17 00:00:00 2001 From: Glenn Hickey Date: Mon, 24 May 2021 12:50:46 -0400 Subject: [PATCH 1/2] choose alt when possible, even if ref more frequent --- src/deconstructor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/deconstructor.cpp b/src/deconstructor.cpp index a2a41ded665..eb062e95376 100644 --- a/src/deconstructor.cpp +++ b/src/deconstructor.cpp @@ -194,7 +194,12 @@ pair, bool> Deconstructor::choose_traversals(const string& sample_na // count the number of times each allele comes up in a traversal vector allele_frequencies(*max_element(trav_to_allele.begin(), trav_to_allele.end()) + 1, 0); for (auto trav : travs) { - ++allele_frequencies[trav_to_allele.at(trav)]; + // we always want to choose alt over ref when possible in sorting logic below, so + // don't count refs here + int allele = trav_to_allele.at(trav); + if (allele > 0) { + ++allele_frequencies[allele]; + } } // sort on frquency function comp = [&] (int trav1, int trav2) { From ed776401fa2843400c7a85a8685bcd0618ba40cb Mon Sep 17 00:00:00 2001 From: Glenn Hickey Date: Mon, 24 May 2021 13:28:03 -0400 Subject: [PATCH 2/2] fix to pass unit tests --- src/deconstructor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deconstructor.cpp b/src/deconstructor.cpp index eb062e95376..7bcc389609f 100644 --- a/src/deconstructor.cpp +++ b/src/deconstructor.cpp @@ -195,9 +195,9 @@ pair, bool> Deconstructor::choose_traversals(const string& sample_na vector allele_frequencies(*max_element(trav_to_allele.begin(), trav_to_allele.end()) + 1, 0); for (auto trav : travs) { // we always want to choose alt over ref when possible in sorting logic below, so - // don't count refs here + // cap ref frequency at 1 int allele = trav_to_allele.at(trav); - if (allele > 0) { + if (allele > 0 || allele_frequencies[allele] == 0) { ++allele_frequencies[allele]; } }