Skip to content

Commit

Permalink
Merge pull request #295 from waveygang/let-me-overlap
Browse files Browse the repository at this point in the history
Let me overlap
  • Loading branch information
ekg authored Nov 14, 2024
2 parents f8d4446 + 12457f5 commit 3e3ef81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/interface/parse_args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void parse_args(int argc,
args::Flag no_split(mapping_opts, "no-split", "map each sequence in one piece", {'N',"no-split"});
args::ValueFlag<std::string> chain_gap(mapping_opts, "INT", "chain gap: max distance to chain mappings [2k]", {'c', "chain-gap"});
args::ValueFlag<std::string> max_mapping_length(mapping_opts, "INT", "target mapping length [50k]", {'P', "max-length"});
args::ValueFlag<double> overlap_threshold(mapping_opts, "FLOAT", "maximum mapping overlap fraction [0.5]", {'O', "overlap"});
args::ValueFlag<double> overlap_threshold(mapping_opts, "FLOAT", "max overlap with better mappings (1.0=keep all) [1.0]", {'O', "overlap"});
args::Flag no_filter(mapping_opts, "", "disable mapping filtering", {'f', "no-filter"});
args::Flag no_merge(mapping_opts, "", "disable merging of consecutive mappings", {'M', "no-merge"});
args::ValueFlag<double> kmer_complexity(mapping_opts, "FLOAT", "minimum k-mer complexity threshold", {'J', "kmer-cmplx"});
Expand Down Expand Up @@ -364,7 +364,7 @@ void parse_args(int argc,
if (overlap_threshold) {
map_parameters.overlap_threshold = args::get(overlap_threshold);
} else {
map_parameters.overlap_threshold = 0.5;
map_parameters.overlap_threshold = 1.0;
}

if (kmer_size) {
Expand Down
44 changes: 25 additions & 19 deletions src/map/include/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,19 @@ namespace skch
}
auto kit = it;

// Check for overlaps and mark bad if necessary
for ( ; it != L.end(); it++) {
if (it == L.begin()) continue;
int idx = *it;
for (auto it2 = L.begin(); it2 != kit; it2++) {
double overlap = get_overlap(idx, *it2);
if (overlap > overlapThreshold) {
vec[idx].overlapped = 1; // Mark as bad if it overlaps >50% with the best mapping
vec[idx].discard = 1;
break;
// Skip overlap checking if threshold is 1.0 (allow all overlaps)
if (overlapThreshold < 1.0) {
// Check for overlaps and mark bad if necessary
for ( ; it != L.end(); it++) {
if (it == L.begin()) continue;
int idx = *it;
for (auto it2 = L.begin(); it2 != kit; it2++) {
double overlap = get_overlap(idx, *it2);
if (overlap > overlapThreshold) {
vec[idx].overlapped = 1; // Mark as bad if overlaps more than threshold
vec[idx].discard = 1;
break;
}
}
}
}
Expand Down Expand Up @@ -393,15 +396,18 @@ namespace skch
}
auto kit = it;

// Check for overlaps and mark bad if necessary
for ( ; it != L.end(); it++) {
if (it == L.begin()) continue;
int idx = *it;
for (auto it2 = L.begin(); it2 != kit; it2++) {
if (get_overlap(idx, *it2) > overlapThreshold) {
vec[idx].overlapped = 1; // Mark as bad if it overlaps >50% with the best mapping
vec[idx].discard = 1;
break;
// Skip overlap checking if threshold is 1.0 (allow all overlaps)
if (overlapThreshold < 1.0) {
// Check for overlaps and mark bad if necessary
for ( ; it != L.end(); it++) {
if (it == L.begin()) continue;
int idx = *it;
for (auto it2 = L.begin(); it2 != kit; it2++) {
if (get_overlap(idx, *it2) > overlapThreshold) {
vec[idx].overlapped = 1; // Mark as bad if overlaps more than threshold
vec[idx].discard = 1;
break;
}
}
}
}
Expand Down

0 comments on commit 3e3ef81

Please sign in to comment.