7 #ifndef PRINT_SEQUENCE_HPP_ 8 #define PRINT_SEQUENCE_HPP_ 12 #include "boost/assert.hpp" 13 #include "boost/foreach.hpp" 14 #include "boost/lexical_cast.hpp" 15 #include "boost/utility/string_ref.hpp" 26 template<
class Ch,
class Tr>
inline std::basic_ostream<Ch,Tr>&
28 std::basic_ostream<Ch,Tr>& os,
29 const boost::string_ref str,
34 for( ; str.size() > n0 + length; n0 += length) {
35 os << str.substr(n0, length) << delim;
47 template<
class Ch,
class Tr>
inline std::basic_ostream<Ch,Tr>&
print_fasta(
48 std::basic_ostream<Ch,Tr>& os,
49 std::string
const& name,
51 const unsigned length = 80
53 os << '>
' << name << '\n'; 54 print_split(os, sequence, '\n', length); 65 template<class Ch,class Tr> inline std::basic_ostream<Ch,Tr>& print_fasta( 66 std::basic_ostream<Ch,Tr>& os, 67 const std::string& name, 68 const boost::string_ref sequence, 69 const unsigned length = 80 71 os << '>
' << name << '\n'; 72 print_split(os, sequence, '\n', length); 83 template<class Ch,class Tr> inline std::basic_ostream<Ch,Tr>& print_qual( 84 std::basic_ostream<Ch,Tr>& os, 85 std::string const& name, 86 Qual_record::quality const& qual, 87 const unsigned length = 80 90 unsigned pos = length; 91 typedef Qual_record::quality::value_type qual_type; 92 BOOST_FOREACH(const qual_type q, qual) { 93 const std::string qs = boost::lexical_cast<std::string>((int)q); 94 if( (pos + qs.size() + 1) > length ) { 115 template<class Ch,class Tr> inline std::basic_ostream<Ch,Tr>& print_fastq( 116 std::basic_ostream<Ch,Tr>& os, 117 std::string const& name, 118 Seq_record::sequence const& sequence, 119 Qual_record::quality const& qual, 120 const int offset = 33 122 BOOST_ASSERT(sequence.size() == qual.size()); 124 << '@
' << name << '\n' 127 BOOST_FOREACH(const int q, qual) { 128 os << (char)(q + offset); 134 }//namespace vdj_pipe 135 #endif /* PRINT_SEQUENCE_HPP_ */
std::basic_ostream< Ch, Tr > & print_split(std::basic_ostream< Ch, Tr > &os, const boost::string_ref str, const Ch delim, const unsigned length)
print string splitting it into parts of equal length
Definition: print_sequence.hpp:27
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
const std::size_t n
Definition: vector_set_test.cpp:26
std::string sequence
Definition: sequence_record.hpp:29
std::basic_ostream< Ch, Tr > & print_fasta(std::basic_ostream< Ch, Tr > &os, std::string const &name, Seq_record::sequence const &sequence, const unsigned length=80)
print FASTA record
Definition: print_sequence.hpp:47