]> git.donarmstrong.com Git - samtools.git/blob - samtools.1
* samtools-0.1.2-17
[samtools.git] / samtools.1
1 .TH samtools 1 "28 January 2009" "samtools-0.1.2" "Bioinformatics tools"
2 .SH NAME
3 .PP
4 samtools - Utilities for the Sequence Alignment/Map (SAM) format
5 .SH SYNOPSIS
6 .PP
7 samtools import ref_list.txt aln.sam.gz aln.bam
8 .PP
9 samtools sort aln.bam aln.sorted
10 .PP
11 samtools index aln.sorted.bam
12 .PP
13 samtools view aln.sorted.bam chr2:20,100,000-20,200,000
14 .PP
15 samtools merge out.bam in1.bam in2.bam in3.bam
16 .PP
17 samtools faidx ref.fasta
18 .PP
19 samtools pileup -f ref.fasta aln.sorted.bam
20 .PP
21 samtools tview aln.sorted.bam ref.fasta
22
23 .SH DESCRIPTION
24 .PP
25 Samtools is a set of utilities that manipulate alignments in the BAM
26 format. It imports from and exports to the SAM (Sequence
27 Alignment/Map) format, does sorting, merging and indexing, and
28 allows to retrieve reads in any regions swiftly.
29
30 .SH COMMANDS AND OPTIONS
31 .TP 10
32 .B import
33 samtools import <in.ref_list> <in.sam> <out.bam>
34
35 Convert alignments in SAM format to BAM format. File
36 .I <in.ref_list>
37 is TAB-delimited. Each line must contain the reference name and the
38 length of the reference, one line for each distinct reference;
39 additional fields are ignored. This file also defines the order of the
40 reference sequences in sorting. File
41 .I <in.sam>
42 can be optionally compressed by zlib or gzip. A single hyphen is
43 recognized as stdin or stdout, depending on the context. If you run
44 `samtools faidx <ref.fa>', the resultant index file
45 .I <ref.fa>.fai
46 can be used as this
47 .I <in.ref_list>
48 file.
49
50 .TP
51 .B sort
52 samtools sort [-n] [-m maxMem] <in.bam> <out.prefix>
53
54 Sort alignments by leftmost coordinates. File
55 .I <out.prefix>.bam
56 will be created. This command may also create temporary files
57 .I <out.prefix>.%d.bam
58 when the whole alignment cannot be fitted into memory (controlled by
59 option -m).
60
61 .B OPTIONS:
62 .RS
63 .TP 8
64 .B -n
65 Sort by read names rather than by chromosomal coordinates
66 .TP
67 .B -m INT
68 Approximately the maximum required memory. [500000000]
69 .RE
70
71 .TP
72 .B merge
73 samtools merge [-n] <out.bam> <in1.bam> <in2.bam> [...]
74
75 Merge multiple sorted alignments. The header of
76 .I <in1.bam>
77 will be copied to
78 .I <out.bam>
79 and the headers of other files will be ignored.
80
81 .B OPTIONS:
82 .RS
83 .TP 8
84 .B -n
85 The input alignments are sorted by read names rather than by chromosomal
86 coordinates
87 .RE
88
89 .TP
90 .B index
91 samtools index <aln.bam>
92
93 Index sorted alignment for fast random access. Index file
94 .I <aln.bam>.bai
95 will be created.
96
97 .TP
98 .B view
99 samtools view [-bhH] <in.bam> [region1 [...]]
100
101 Extract/print all or sub alignments in SAM or BAM format. If no region
102 is specified, all the alignments will be printed; otherwise only
103 alignments overlapping with the specified regions will be output. An
104 alignment may be given multiple times if it is overlapping several
105 regions. A region can be presented, for example, in the following
106 format: `chr2', `chr2:1000000' or `chr2:1,000,000-2,000,000'.
107
108 .B OPTIONS:
109 .RS
110 .TP 8
111 .B -b
112 Output in the BAM format.
113 .TP
114 .B -h
115 Include the header in the output.
116 .TP
117 .B -H
118 Output the header only.
119 .RE
120
121 .TP
122 .B faidx
123 samtools faidx <ref.fasta> [region1 [...]]
124
125 Index reference sequence in the FASTA format or extract subsequence from
126 indexed reference sequence. If no region is specified,
127 .B faidx
128 will index the file and create
129 .I <ref.fasta>.fai
130 on the disk. If regions are speficified, the subsequences will be
131 retrieved and printed to stdout in the FASTA format. The input file can
132 be compressed in the
133 .B RAZF
134 format.
135
136 .TP
137 .B pileup
138 samtools pileup [-f in.ref.fasta] [-t in.ref_list] [-l in.site_list]
139 [-iscg] [-T theta] [-N nHap] [-r pairDiffRate] <in.alignment>
140
141 Print the alignment in the pileup format. In the pileup format, each
142 line represents a genomic position, consisting of chromosome name,
143 coordinate, reference base, read bases, read qualities and alignment
144 mapping qualities. Information on match, mismatch, indel, strand,
145 mapping quality and start and end of a read are all encoded at the read
146 base column. At this column, a dot stands for a match to the reference
147 base on the forward strand, a comma for a match on the reverse strand,
148 `ACGTN' for a mismatch on the forward strand and `acgtn' for a mismatch
149 on the reverse strand. A pattern `\\+[0-9]+[ACGTNacgtn]+' indicates
150 there is an insertion between this reference position and the next
151 reference position. The length of the insertion is given by the integer
152 in the pattern, followed by the inserted sequence. Similarly, a pattern
153 `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference. Also at
154 the read base column, a symbol `^' marks the start of a read segment
155 which is a contiguous subsequence on the read separated by `N/S/H' CIGAR
156 operations. The ASCII of the character following `^' minus 33 gives the
157 mapping quality. A symbol `$' marks the end of a read segment.
158
159 If option
160 .B -c
161 is applied, the consensus base, consensus quality, SNP quality and
162 maximum mapping quality of the reads covering the site will be inserted
163 between the `reference base' and the `read bases' columns. An indel
164 occupies an additional line. Each indel line consists of chromosome
165 name, coordinate, a star, top two high-scoring ins/del sequences, the
166 number of reads strongly supporting the first indel, the number of reads
167 strongly supporting the second indel, the number of reads that confer
168 little information on distinguishing indels and the number of reads that
169 contain indels different from the top two ones.
170
171 .B OPTIONS:
172 .RS
173
174 .TP 10
175 .B -s
176 Print the mapping quality as the last column. This option makes the
177 output easier to parse, although this format is not space efficient.
178
179 .TP
180 .B -i
181 Only output pileup lines containing indels.
182
183 .TP
184 .B -f FILE
185 The reference sequence in the FASTA format. Index file
186 .I FILE.fai
187 will be created if
188 absent.
189
190 .TP
191 .B -t FILE
192 List of reference names ane sequence lengths, in the format described
193 for the
194 .B import
195 command. If this option is present, samtools assumes the input
196 .I <in.alignment>
197 is in SAM format; otherwise it assumes in BAM format.
198
199 .TP
200 .B -l FILE
201 List of sites at which pileup is output. This file is space
202 delimited. The first two columns are required to be chromosome and
203 1-based coordinate. Additional columns are ignored. It is
204 recommended to use option
205 .B -s
206 together with
207 .B -l
208 as in the default format we may not know the mapping quality.
209
210 .TP
211 .B -c
212 Call the consensus sequence using MAQ consensus model. Options
213 .B -T,
214 .B -N
215 and
216 .B -r
217 are only effective when
218 .B -c
219 is in use.
220
221 .TP
222 .B -g
223 Generate genotype likelihood in the binary GLFv2 format. This option
224 suppresses -c, -i and -s.
225
226 .TP
227 .B -T FLOAT
228 The theta parameter (error dependency coefficient) in the maq consensus
229 calling model [0.85]
230
231 .TP
232 .B -N INT
233 Number of haplotypes in the sample (>=2) [2]
234
235 .TP
236 .B -r FLOAT
237 Expected fraction of differences between a pair of haplotypes [0.001]
238
239 .RE
240
241 .TP
242 .B tview
243 samtools tview <in.sorted.bam> [ref.fasta]
244
245 Text alignment viewer (based on the ncurses library). In the viewer,
246 press `?' for help and press `g' to check the alignment start from a
247 region in the format like `chr10:10,000,000'. Note that if the region
248 showed on the screen contains no mapped reads, a blank screen will be
249 seen. This is a known issue and will be improved later.
250
251 .RE
252
253 .TP
254 .B fixmate
255 samtools fixmate <in.nameSrt.bam> <out.bam>
256
257 Fill in mate coordinates, ISIZE and mate related flags from a
258 name-sorted alignment.
259
260 .TP
261 .B rmdup
262 samtools rmdup <input.srt.bam> <out.bam>
263
264 Remove potential PCR duplicates: if multiple read pairs have identical
265 external coordinates, only retain the pair with highest mapping quality.
266 This command
267 .B ONLY
268 works with FR orientation and requires ISIZE is correctly set.
269
270 .RE
271
272
273 .SH SAM FORFAM
274
275 SAM is TAB-delimited. Apart from the header lines, which are started
276 with the `@' symbol, each alignment line consists of:
277
278 .TS
279 center box;
280 cb | cb | cb
281 n | l | l .
282 Col     Field   Description
283 _
284 1       QNAME   Query (pair) NAME
285 2       FLAG    bitwise FLAG
286 3       RNAME   Reference sequence NAME
287 4       POS     1-based leftmost POSition/coordinate of clipped sequence
288 5       MAPQ    MAPping Quality (Phred-scaled)
289 6       CIAGR   extended CIGAR string
290 7       MRNM    Mate Reference sequence NaMe (`=' if same as RNAME)
291 8       MPOS    1-based Mate POSistion
292 9       ISIZE   Inferred insert SIZE
293 10      SEQ     query SEQuence on the same strand as the reference
294 11      QUAL    query QUALity (ASCII-33 gives the Phred base quality)
295 12      OPT     variable OPTional fields in the format TAG:VTYPE:VALUE
296 .TE
297
298 .PP
299 Each bit in the FLAG field is defined as:
300
301 .TS
302 center box;
303 cb | cb
304 l | l .
305 Flag    Description
306 _
307 0x0001  the read is paired in sequencing
308 0x0002  the read is mapped in a proper pair
309 0x0004  the query sequence itself is unmapped
310 0x0008  the mate is unmapped
311 0x0010  strand of the query (1 for reverse)
312 0x0020  strand of the mate
313 0x0040  the read is the first read in a pair
314 0x0080  the read is the second read in a pair
315 0x0100  the alignment is not primary
316 0x0200  the read fails platform/vendor quality checks
317 0x0400  the read is either a PCR or an optical duplicate
318 .TE
319
320 .SH LIMITATIONS
321 .PP
322 .IP o 2
323 In general, more testing is needed to ensure there is no severe bug.
324 .IP o 2
325 Reference sequence names and lengths are not acquired from the BAM/SAM header.
326 .IP o 2
327 CIGAR operations N and P may not be properly handled.
328 .IP o 2
329 There is a small memory leak in the viewer.
330
331 .SH AUTHOR
332 .PP
333 Heng Li from the Sanger Institute is the author of the C version of
334 samtools. Bob Handsaker from the Broad Institute implemented the BGZF
335 library and Jue Ruan from Beijing Genomics Institute wrote the RAZF
336 library. Various people in the 1000Genomes Project contributed to the
337 SAM format specification.
338
339 .SH SEE ALSO
340 .PP
341 Samtools website: http://samtools.sourceforge.net