File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,12 @@ using std::istream;
3333using std::ostream;
3434using std::begin;
3535using std::end;
36+ using std::ostringstream;
3637
3738// ADS: this is for debugging purposes
3839string
3940format_sam_flags (const uint16_t the_flags) {
40- std:: ostringstream oss;
41+ ostringstream oss;
4142 using samflags::check;
4243 oss << " read_paired: " << check (the_flags, samflags::read_paired) << ' \n '
4344 << " read_pair_mapped: "
@@ -72,6 +73,25 @@ format_sam_flags(const uint16_t the_flags) {
7273// return regex_match(qual, regex("[!-~]+"));
7374// }
7475
76+ string
77+ sam_rec::tostring () const {
78+ ostringstream oss;
79+ oss << qname << ' \t '
80+ << flags << ' \t '
81+ << rname << ' \t '
82+ << pos << ' \t '
83+ << static_cast <unsigned >(mapq) << ' \t '
84+ << cigar << ' \t '
85+ << rnext << ' \t '
86+ << pnext << ' \t '
87+ << tlen << ' \t '
88+ << seq << ' \t '
89+ << qual;
90+
91+ for (auto it (begin (tags)); it != end (tags); ++it)
92+ oss << ' \t ' << *it;
93+ return oss.str () + " \n " ;
94+ }
7595
7696ostream &
7797operator <<(std::ostream &the_stream, const sam_rec &r) {
@@ -88,7 +108,7 @@ operator<<(std::ostream &the_stream, const sam_rec &r) {
88108 << r.qual ;
89109
90110 for (auto it (begin (r.tags )); it != end (r.tags ); ++it)
91- the_stream << ' \t ' << *it;
111+ the_stream << ' \t ' << *it;
92112 return the_stream;
93113}
94114
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ class sam_rec {
117117 seq (_seq),
118118 qual (_qual) {}
119119 void add_tag (const std::string &the_tag) {tags.push_back (the_tag);}
120+ std::string tostring () const ;
120121};
121122
122123inline bool
You can’t perform that action at this time.
0 commit comments