-
Notifications
You must be signed in to change notification settings - Fork 78
/
sam.h
122 lines (109 loc) · 2.19 KB
/
sam.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* sam.h
*
* Created on: Sep 23, 2009
* Author: Ben Langmead
*/
#ifndef SAM_H_
#define SAM_H_
#include "ds.h"
#include "hit.h"
#include "pat.h"
#include "random_source.h"
#include "btypes.h"
class PatternSourcePerThread;
enum {
SAM_FLAG_PAIRED = 1,
SAM_FLAG_MAPPED_PAIRED = 2,
SAM_FLAG_UNMAPPED = 4,
SAM_FLAG_MATE_UNMAPPED = 8,
SAM_FLAG_QUERY_STRAND = 16,
SAM_FLAG_MATE_STRAND = 32,
SAM_FLAG_FIRST_IN_PAIR = 64,
SAM_FLAG_SECOND_IN_PAIR = 128,
SAM_FLAG_NOT_PRIMARY = 256,
SAM_FLAG_FAILS_CHECKS = 512,
SAM_FLAG_DUPLICATE = 1024
};
/**
* Sink that prints lines in SAM format:
*/
class SAMHitSink : public HitSink {
public:
/**
* Construct a single-stream VerboseHitSink (default)
*/
SAMHitSink(
OutFileBuf& out,
bool fullRef,
bool noQnameTrunc,
const std::string& dumpAl,
const std::string& dumpUnal,
const std::string& dumpMax,
bool onePairFile,
bool sampleMax,
EList<std::string>* refnames,
size_t nthreads,
int perThreadBufSize,
bool reorder) :
HitSink(
out,
dumpAl,
dumpUnal,
dumpMax,
onePairFile,
sampleMax,
refnames,
nthreads,
perThreadBufSize,
reorder),
fullRef_(fullRef),
noQnameTrunc_(noQnameTrunc) { }
/**
* Append a verbose, readable hit to the output stream
* corresponding to the hit.
*/
virtual void append(BTString& o, const Hit& h, int mapq, int xms);
/**
* Write the SAM header lines.
*/
void appendHeaders(
OutFileBuf& os,
size_t numRefs,
const EList<string>& refnames,
bool nosq,
const TIndexOffU* plen,
bool fullRef,
bool noQnameTrunc,
const char *cmdline,
const char *rgline);
protected:
/**
* Both
*/
void reportUnOrMax(
PatternSourcePerThread& p,
EList<Hit>* hs, // could be NULL
size_t threadId,
bool un);
/**
* See sam.cpp
*/
virtual void reportMaxed(
EList<Hit>& hs,
size_t threadId,
PatternSourcePerThread& p);
/**
* See sam.cpp
*/
virtual void reportUnaligned(
size_t threadId,
PatternSourcePerThread& p)
{
reportUnOrMax(p, NULL, threadId, true);
}
private:
bool fullRef_; /// print full reference name, not just up to whitespace
bool noQnameTrunc_; /// true -> don't truncate QNAME at first whitespace
};
#endif /* SAM_H_ */