Skip to content

Commit

Permalink
now it prints the inverted patch in the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
ekg committed Jun 26, 2024
1 parent b663abe commit 4273104
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/common/wflign/src/wflign_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,9 @@ void write_merged_alignment(
// how long was our last gap?
// if it's long enough, patch it
int32_t size_region_to_repatch = 0;
// unused!

do {
{
got_alignment = false;

if ((size_region_to_repatch > 0 ||
Expand Down Expand Up @@ -984,6 +985,7 @@ void write_merged_alignment(
wf_aligner, convex_penalties, patch_aln, rev_patch_aln,
chain_gap, max_patching_score);
if (rev_patch_aln.ok) {
// we got a good reverse alignment
rev_patch_alns.push_back(rev_patch_aln);
}
if (patch_aln.ok) {
Expand All @@ -995,14 +997,13 @@ void write_merged_alignment(
const int end_idx =
patch_aln.edit_cigar.end_offset;
for (int i = start_idx; i < end_idx; i++) {
// std::cerr <<
// patch_aln.edit_cigar.cigar_ops[i];
patched.push_back(patch_aln.edit_cigar.cigar_ops[i]);
}
// std::cerr << "\n";

// Check if there are too many indels in the
// patch
/*
uint32_t size_indel = 0;
for (int i = end_idx - 1; i >= start_idx;
--i) {
Expand All @@ -1026,19 +1027,22 @@ void write_merged_alignment(
size_indel = 0;
}
}
*/
// std::cerr << std::endl;

// Not too big, to avoid repatching
// structural variants boundaries
//std::cerr << "size_region_to_repatch " << size_region_to_repatch << std::endl;
//std::cerr << "end_idx - start_idx " << end_idx - start_idx << std::endl;
/*
if (size_indel > 7 && size_indel <= 4096 &&
size_region_to_repatch <
(end_idx - start_idx)) {
//std::cerr << "REPATCH " << std::endl;
} else {
size_region_to_repatch = 0;
}
*/
}
#ifdef WFA_PNG_TSV_TIMING
if (emit_patching_tsv) {
Expand Down Expand Up @@ -1070,7 +1074,7 @@ void write_merged_alignment(

query_delta = 0;
target_delta = 0;
} while (size_region_to_repatch > 0);
}
}

// Tail patching
Expand Down Expand Up @@ -1889,8 +1893,8 @@ query_start : query_end)
target_length,
min_identity,
mashmap_estimated_identity,
false // Don't add an endline after each alignment
);
false, // Don't add an endline after each alignment
true); // This is a reverse complement alignment
// write tag indicating that this is a reverse complement alignment
out << "\t" << "rc:Z:true" << "\n";
}
Expand All @@ -1911,7 +1915,8 @@ void write_alignment(
const uint64_t& target_length, // unused
const float& min_identity,
const float& mashmap_estimated_identity,
const bool& with_endline) {
const bool& with_endline,
const bool& is_rev_patch) {

if (aln.ok) {
uint64_t matches = 0;
Expand Down Expand Up @@ -1939,9 +1944,9 @@ void write_alignment(

if (gap_compressed_identity >= min_identity) {
uint64_t q_start;
if (query_is_rev) {
if (query_is_rev && !is_rev_patch) {
q_start =
query_offset + (query_length - (aln.j + qAlignedLength));
query_offset + (query_length - (aln.j + qAlignedLength));
} else {
q_start = query_offset + aln.j;
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/wflign/src/wflign_patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ namespace wflign {
const uint64_t& target_length, // unused
const float& min_identity,
const float& mashmap_estimated_identity,
const bool& with_endline = true);
const bool& with_endline = true,
const bool& is_rev_patch = false);
double float2phred(const double& prob);
void sort_indels(std::vector<char>& v);

Expand Down

0 comments on commit 4273104

Please sign in to comment.