26 #ifndef SHORE_IO_SAM_HPP__
27 #define SHORE_IO_SAM_HPP__
44 SAM_PE_PAIRED_END=0x001,
45 SAM_PE_PROPER_PAIR=0x002,
46 SAM_UNMAPPED_SELF=0x004,
47 SAM_PE_UNMAPPED_MATE=0x008,
48 SAM_REVERSE_SELF=0x010,
49 SAM_REVERSE_MATE=0x020,
52 SAM_NO_PRIMARY_ALIGNMENT=0x100,
53 SAM_QUALITY_FILTERED=0x200,
54 SAM_DUPLICATE_READ=0x400
83 std::string refseq_fn;
95 bool discard_softclipped;
101 config(
const std::string &reffn=std::string());
113 leftover_pipe m_leftovers;
123 std::pair<int,shore::alignment::InsertState>
m_peconv[0x801];
151 std::vector<sh_sq> sq;
153 std::map<std::string,size_t> m5_map;
156 std::map<std::string,size_t> sn_map;
160 void append(
const std::string& s);
169 typedef std::map<std::string,size_t>::const_iterator ichr_t;
180 bool &isrev,cigarstats &cigsta,
size_t &xaofs,
181 const std::string &xa);
187 leftover_pipe &leftovers();
189 void set_max_ed(
const int ed);
190 void set_max_gaps(
const int g);
191 void set_max_gapsize(
const int g);
192 void set_max_hits(
const int h);
194 void discard_softclipped(
const bool d);
198 static void cigar2aln(std::string &aln,cigarstats &cs,
199 const std::string &
read,
const std::string &cigar,
201 const size_t start,
const int max_gapsize=1);
215 static const int MAXCOLS=
MAXTAGS+11;
232 typedef boost::function<void (const std::string*const)> tagfun_t;
244 std::string m_linebuf;
246 std::string m_splitbuf[MAXCOLS];
253 const std::string* m_xastring;
260 void convert_alignment_string();
262 bool m_emit_as_leftover;
263 int m_currentsamflag;
264 bool m_current_is_revcomp;
266 std::string m_rangeindexfile;
270 void tagfun_invalid(
const std::string*
const ptag);
271 void tagfun_MD(
const std::string*
const ptag);
272 void tagfun_X0(
const std::string*
const ptag);
273 void tagfun_XA(
const std::string*
const ptag);
274 void tagfun_NH(
const std::string*
const ptag);
275 void tagfun_RG(
const std::string*
const ptag);
276 void tagfun_XR(
const std::string*
const ptag);
277 void tagfun_XG(
const std::string*
const ptag);
278 void tagfun_XM(
const std::string*
const ptag);
293 const std::string ¤t_line()
const;
296 const long maxrl=0l);
312 typedef boost::function<void (const char**)> tagfun_t;
316 static const char CIGARCONV[17];
317 static const char BASECONV[17];
332 bool m_emit_as_leftover;
333 int m_currentsamflag;
334 bool m_current_is_revcomp;
338 size_t m_readbufsize;
341 size_t m_nextblocklen;
343 std::string m_cigarbuf;
344 std::string m_seqbuf;
349 void ensure_buf(
size_t size);
353 void tagfun_invalid(
const char **ptag);
354 void tagfun_default(
const char **ptag);
355 void tagfun_MD(
const char **ptag);
356 void tagfun_X0(
const char **ptag);
357 void tagfun_XA(
const char **ptag);
358 void tagfun_NH(
const char **ptag);
359 void tagfun_RG(
const char **ptag);
374 const long maxrl=0l);
390 std::string m_qualbuf;
398 std::set<std::string> m_allowed_readgroups;
400 bool m_correct_leftover_flags;
401 bool m_orphan_partners_only;
404 std::map<std::string,std::pair<shore::refseq_coor,shore::Strand> > m_orphan_coors;
418 sam_writer(
const std::string& fn,
const std::vector<std::string> &allowed_readgroups);
419 sam_writer(std::ostream*
const os,
const std::vector<std::string> &allowed_readgroups);
423 void write_header(
const std::string& fasta_fn=std::string(),
424 const SamSorting sort=SAM_SO_UNKNOWN);
440 S_MAKE_ENUM_TRAITS(sam_writer::SamSorting)
450 #endif // SHORE_IO_SAM_HPP__