File: sambamba-view.1

package info (click to toggle)
sambamba 1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,528 kB
  • sloc: sh: 220; python: 166; ruby: 147; makefile: 103
file content (170 lines) | stat: -rw-r--r-- 5,042 bytes parent folder | download | duplicates (3)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "SAMBAMBA\-VIEW" "1" "June 2016" "" ""
.
.SH "NAME"
\fBsambamba\-view\fR \- tool for extracting information from SAM/BAM files
.
.SH "SYNOPSIS"
\fBsambamba view\fR \fIOPTIONS\fR <input\.bam | input\.sam> [region1 [\.\.\.]]
.
.SH "DESCRIPTION"
\fBsambamba view\fR allows to efficiently filter SAM/BAM files for alignments satisfying various conditions, as well as access its SAM header and information about reference sequences\. In order to make these data readily available for consumption by scripts in Perl/Python/Ruby, JSON output is provided\.
.
.P
By default, the tool expects BAM file as an input\. In order to work with SAM, specify \fB\-S\fR|\fB\-\-sam\-input\fR as a command\-line option, the tool does NOT try to guess file format from the extension\. Beware that when reading SAM, the tool will skip tags which don\'t conform to the SAM/BAM specification, and set invalid fields to their default values\.
.
.SH "FILTERING"
Filtering is presented in two ways\. First, you can specify a condition with \fB\-F\fR option, using a special language for filtering, described at
.
.P
https://github\.com/lomereiter/sambamba/wiki/%5Bsambamba\-view%5D\-Filter\-expression\-syntax
.
.P
Second, if you have an indexed BAM file, several regions can be specified as well\. The syntax for regions is the same as in samtools: \fIchr\fR:\fIbeg\fR\-\fIend\fR where \fIbeg\fR and \fIend\fR are 1\-based start and end of a closed\-end interval on the reference \fIchr\fR\.
.
.SH "JSON"
Alignment record JSON representation is a hash with keys \'qname\', \'flag\', \'rname\', \'pos\', \'mapq\', \'cigar\', \'rnext\', \'qual\', \'tags\', e\.g\.
.
.P
{"qname":"EAS56_57:6:190:289:82","flag":69,"rname":"chr1","pos":100,
.
.br
"mapq":0,"cigar":"*","rnext":"=","pnext":100,"tlen":0,
.
.br
"seq":"CTCAAGGTTGTTGCAAGGGGGTCTATGTGAACAAA",
.
.br
"qual":[27,27,27,22,27,27,27,26,27,27,27,27,27,27,27,27,23,26,26,27,
.
.br
22,26,19,27,26,27,26,26,26,26,26,24,19,27,26],"tags":{"MF":192}}
.
.P
JSON representation mimics SAM format except quality is given as an array of integers\.
.
.P
Postprocessing JSON output is best accomplished with https://stedolan\.github\.io/jq/
.
.P
The output is one line per read, for building a proper JSON array pipe the output into \fBjq \-\-slurp\fR\.
.
.SH "OPTIONS"
.
.TP
\fB\-F\fR, \fB\-\-filter\fR=\fIFILTER\fR
Set custom filter for alignments\.
.
.TP
\fB\-f\fR, \fB\-\-format\fR=\fIFORMAT\fR
Specify output format\. \fIFORMAT\fR must be one of sam, bam, or json (in lowercase)\. Default is SAM\.
.
.TP
\fB\-h\fR, \fB\-\-with\-header\fR
Print SAM header before reads\. This is always done for BAM output\.
.
.TP
\fB\-H\fR, \fB\-\-header\fR
Print only SAM header to STDOUT\. If \fIFORMAT\fR is sam or bam, its text version is printed, otherwise JSON object is written\.
.
.TP
\fB\-I\fR, \fB\-\-reference\-info\fR
Output to STDOUT reference sequence names and lengths in JSON (see \fIEXAMPLES\fR)\.
.
.TP
\fB\-L\fR, \fB\-\-regions\fR=\fIBEDFILE\fR
Intersect a file with regions specified in the BED file\.
.
.TP
\fB\-c\fR, \fB\-\-count\fR
Output to STDOUT only the number of matching records, \-hHI options are ignored\.
.
.TP
\fB\-v\fR, \fB\-\-valid\fR
Output only valid reads\.
.
.TP
\fB\-S\fR, \fB\-\-sam\-input\fR
Specify that the input is SAM file (default is BAM for all operations)\.
.
.TP
\fB\-p\fR, \fB\-\-show\-progress\fR
Show progressbar in STDERR\. Works only for BAM files, and with no regions specified, i\.e\. only when reading full file\.
.
.TP
\fB\-l\fR, \fB\-\-compression\-level\fR=\fICOMPRESSION_LEVEL\fR
Set compression level for BAM output, a number from 0 to 9\.
.
.TP
\fB\-o\fR, \fB\-\-output\-filename\fR=\fIFILENAME\fR
Specify output filename (by default everything is written to STDOUT)\.
.
.TP
\fB\-t\fR, \fB\-\-nthreads\fR=\fINTHREADS\fR
Number of threads to use\.
.
.SH "EXAMPLES"
Print basic reference sequence information:
.
.IP "" 4
.
.nf

 $ sambamba view \-\-reference\-info ex1_header\.bam
 [{"name":"chr1","length":1575},{"name":"chr2","length":1584}]
.
.fi
.
.IP "" 0
.
.P
Count reads with mapping quality not less than 50:
.
.IP "" 4
.
.nf

 $ sambamba view \-c \-F "mapping_quality >= 50" ex1_header\.bam
 3124
.
.fi
.
.IP "" 0
.
.P
Count properly paired reads overlapping 100\.\.200 on chr1:
.
.IP "" 4
.
.nf

 $ sambamba view \-c \-F "proper_pair" ex1_header\.bam chr1:100\-200
 39
.
.fi
.
.IP "" 0
.
.P
Output header in JSON format:
.
.IP "" 4
.
.nf

 $ sambamba view \-\-header \-\-format=json ex1_header\.bam
 {"format_version":"1\.3","rg_lines":[],
  "sq_lines":[{"sequence_length":1575,"species":"","uri":"",
  "sequence_name":"chr1","assembly":"","md5":""},
  {"sequence_length":1584,"species":"","uri":"",
  "sequence_name":"chr2","assembly":"","md5":""}],
  "sorting_order":"coordinate","pg_lines":[]}
.
.fi
.
.IP "" 0
.
.SH "SEE ALSO"
For more information on the original samtools VIEW behaviour, check out the samtools documentation \fIhttp://samtools\.sourceforge\.net/samtools\.shtml\fR\.