Skip to content

Commit

Permalink
Add operator<< for ksw_extz_t
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelm committed Mar 17, 2023
1 parent 88ffb17 commit 8311650
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
22 changes: 22 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 @@ -235,6 +236,27 @@ 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;
}

aln_info Aligner::ksw_extend(const std::string& query, const std::string& ref, bool right_align) const {
int w = -1; // band width; -1 is inf
int zdrop = -1; // -1 to disable
Expand Down
5 changes: 5 additions & 0 deletions src/cigar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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 @@ -87,6 +87,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

0 comments on commit 8311650

Please sign in to comment.