From 8311650247b4e3958ce25402e5c220891e90cb2b Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Mon, 13 Mar 2023 14:37:35 +0100 Subject: [PATCH] Add operator<< for ksw_extz_t --- src/aligner.cpp | 22 ++++++++++++++++++++++ src/cigar.cpp | 5 +++++ src/cigar.hpp | 2 ++ 3 files changed, 29 insertions(+) diff --git a/src/aligner.cpp b/src/aligner.cpp index a041d710..b0adc7a2 100644 --- a/src/aligner.cpp +++ b/src/aligner.cpp @@ -11,6 +11,7 @@ #include #include #include // memset +#include #include "ksw2/ksw2.h" #include "aligner.hpp" @@ -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 diff --git a/src/cigar.cpp b/src/cigar.cpp index 18354112..85eb9508 100644 --- a/src/cigar.cpp +++ b/src/cigar.cpp @@ -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; diff --git a/src/cigar.hpp b/src/cigar.hpp index adfc49aa..00364502 100644 --- a/src/cigar.hpp +++ b/src/cigar.hpp @@ -87,6 +87,8 @@ class Cigar { std::vector m_ops; }; +std::ostream& operator<<(std::ostream& os, const Cigar& cigar); + std::string compress_cigar(const std::string& ops); #endif