Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ksw2 to align soft-clipped ends from ungapped alignment #382

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add operator<< for ksw_extz_t
  • Loading branch information
marcelm committed Feb 22, 2024
commit a90d6979a3070c0886df5ed4326eeaa6d2dacd76
21 changes: 21 additions & 0 deletions src/aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <algorithm>
#include <cassert>
#include <cstring> // memset
#include <iostream>
#include "ksw2/ksw2.h"
#include "aligner.hpp"

Expand Down Expand Up @@ -241,6 +242,26 @@ void ksw_gen_simple_mat(int m, int8_t *mat, int8_t a, int8_t b)
mat[(m - 1) * m + j] = 0;
}

std::ostream& operator<<(std::ostream& os, const ksw_extz_t& ez) {
os << "ksw_extz_t("
//
<< "\n max: " << ez.max // max overall score
<< "\n coord max_q: " << ez.max_q // max extension coordinate
<< "\n coord max_t: " << ez.max_t // max extension coordinate

<< "\n score mqe: " << ez.mqe // max score when reaching the end of query
<< "\n mqe_t: " << ez.mqe_t // coordinate in target corresponding to mqe

<< "\n score mte: " << ez.mte // max score when reaching the end of target
<< "\n mte_q: " << ez.mte_q // coordinate in query corresponding to mte

<< "\n score both ends: " << ez.score // max score reaching both ends
<< "\n cigar: " << Cigar(ez.cigar, ez.n_cigar)
<< "\n zdropped: " << ez.zdropped
<< "\n reach_end: " << ez.reach_end
<< "\n)";
return os;
}

AlignmentInfo Aligner::ksw_extend(const std::string& query, const std::string& ref, bool right_align) const {
int w = -1; // band width; -1 is inf
Expand Down
5 changes: 5 additions & 0 deletions src/cigar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Cigar::Cigar(const std::string& cig) {
}
}

std::ostream& operator<<(std::ostream& os, const Cigar& cigar) {
os << cigar.to_string();
return os;
}

std::string compress_cigar(const std::string& ops) {
char prev = 0;
int count = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/cigar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Cigar {
std::vector<uint32_t> m_ops;
};

std::ostream& operator<<(std::ostream& os, const Cigar& cigar);

std::string compress_cigar(const std::string& ops);

#endif