diff --git a/src/map/include/computeMap.hpp b/src/map/include/computeMap.hpp index 4f1e67e0..c11fb78c 100644 --- a/src/map/include/computeMap.hpp +++ b/src/map/include/computeMap.hpp @@ -204,7 +204,10 @@ namespace skch //Filter over reference axis and report the mappings if (param.filterMode == filter::ONETOONE) { - skch::Filter::ref::filterMappings(allReadMappings, this->refSketch); + skch::Filter::ref::filterMappings(allReadMappings, this->refSketch, + param.secondaryToKeep + // (input->len < param.segLength ? param.shortSecondaryToKeep : param.secondaryToKeep) + ); //Re-sort mappings by input order of query sequences //This order may be needed for any post analysis of output diff --git a/src/map/include/filter.hpp b/src/map/include/filter.hpp index c6bc2f42..b2d5b46e 100644 --- a/src/map/include/filter.hpp +++ b/src/map/include/filter.hpp @@ -284,14 +284,17 @@ namespace skch * @param[in/out] L container with mappings */ template - inline void markGood(Type &L) + inline void markGood(Type &L, int secondaryToKeep) { //first segment in the set order auto beg = L.begin(); + // count how many secondary alignments we keep + int kept = 0; + for(auto it = L.begin(); it != L.end(); it++) { - if(this->greater_score(*beg, *it) || vec[*it].discard == 0) + if((this->greater_score(*beg, *it) || vec[*it].discard == 0) && ++kept > secondaryToKeep) break; vec[*it].discard = 0; @@ -325,7 +328,7 @@ namespace skch * @param[in] refsketch reference index class object, used to determine ref sequence lengths */ template - void filterMappings(VecIn &readMappings, const skch::Sketch &refsketch) + void filterMappings(VecIn &readMappings, const skch::Sketch &refsketch, int secondaryToKeep) { if(readMappings.size() <= 1) return; @@ -376,7 +379,7 @@ namespace skch }); //mark mappings as good - obj.markGood(bst); + obj.markGood(bst, secondaryToKeep); it = it2; }