File: sambamba-view.1.ronn

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 (124 lines) | stat: -rw-r--r-- 4,563 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
sambamba-view(1) -- tool for extracting information from SAM/BAM files
======================================================================

## SYNOPSIS

`sambamba view` [OPTIONS] <input.bam | input.sam> [region1 [...]]

## DESCRIPTION

`sambamba view` 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.

By default, the tool expects BAM file as an input.  In order to work SAM,
specify `-S`|`--sam-input` 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.

## FILTERING

Filtering is presented in two ways. First, you can specify a condition
with `-F` option, using a special language for filtering, described at

https://github.com/lomereiter/sambamba/wiki/%5Bsambamba-view%5D-Filter-expression-syntax

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: <chr>:<beg>-<end> where <beg> and <end>
are 1-based start and end of a closed-end interval on the reference <chr>.

## JSON

Alignment record JSON representation is a hash with keys 'qname', 'flag', 'rname', 'pos', 'mapq',
'cigar', 'rnext', 'qual', 'tags', e.g.

{"qname":"EAS56_57:6:190:289:82","flag":69,"rname":"chr1","pos":100,  
 "mapq":0,"cigar":"*","rnext":"=","pnext":100,"tlen":0,  
 "seq":"CTCAAGGTTGTTGCAAGGGGGTCTATGTGAACAAA",  
 "qual":[27,27,27,22,27,27,27,26,27,27,27,27,27,27,27,27,23,26,26,27,  
 22,26,19,27,26,27,26,26,26,26,26,24,19,27,26],"tags":{"MF":192}}

JSON representation mimics SAM format except quality is given as an array of integers.

Postprocessing JSON output is best accomplished with https://stedolan.github.io/jq/

The output is one line per read, for building a proper JSON array pipe the output into `jq --slurp`.

## OPTIONS

  * `-F`, `--filter`=<FILTER>:
    Set custom filter for alignments.

  * `-f`, `--format`=<FORMAT>:
    Specify output format. <FORMAT> must be one of sam, bam, or json (in lowercase).
    Default is SAM.

  * `-h`, `--with-header`:
    Print SAM header before reads. This is always done for BAM output.

  * `-H`, `--header`:
    Print only SAM header to STDOUT. If <FORMAT> is sam or bam, its text version is
    printed, otherwise JSON object is written.

  * `-I`, `--reference-info`:
    Output to STDOUT reference sequence names and lengths in JSON (see [EXAMPLES][]).

  * `-L`, `--regions`=<BEDFILE>:
    Intersect a file with regions specified in the BED file.

  * `-c`, `--count`:
    Output to STDOUT only the number of matching records, -hHI options are ignored.

  * `-v`, `--valid`:
    Output only valid reads.

  * `-S`, `--sam-input`:
    Specify that the input is SAM file (default is BAM for all operations).

  * `-p`, `--show-progress`:
    Show progressbar in STDERR. Works only for BAM files, and with no regions
    specified, i.e. only when reading full file.

  * `-l`, `--compression-level`=<COMPRESSION_LEVEL>:
    Set compression level for BAM output, a number from 0 to 9.

  * `-o`, `--output-filename`=<FILENAME>:
    Specify output filename (by default everything is written to STDOUT).

  * `-t`, `--nthreads`=<NTHREADS>:
    Number of threads to use.

## EXAMPLES

  Print basic reference sequence information:

     $ sambamba view --reference-info ex1_header.bam
     [{"name":"chr1","length":1575},{"name":"chr2","length":1584}]

  Count reads with mapping quality not less than 50:

     $ sambamba view -c -F "mapping_quality >= 50" ex1_header.bam
     3124

  Count properly paired reads overlapping 100..200 on chr1:
     
     $ sambamba view -c -F "proper_pair" ex1_header.bam chr1:100-200
     39

  Output header in JSON format:

     $ 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":[]}

## SEE ALSO

For more information on the original samtools VIEW behaviour, check
out the [samtools documentation](http://samtools.sourceforge.net/samtools.shtml).