1 .TH samtools 1 "28 January 2009" "samtools-0.1.2" "Bioinformatics tools"
4 samtools - Utilities for the Sequence Alignment/Map (SAM) format
7 samtools import ref_list.txt aln.sam.gz aln.bam
9 samtools sort aln.bam aln.sorted
11 samtools index aln.sorted.bam
13 samtools view aln.sorted.bam chr2:20,100,000-20,200,000
15 samtools merge out.bam in1.bam in2.bam in3.bam
17 samtools faidx ref.fasta
19 samtools pileup -f ref.fasta aln.sorted.bam
21 samtools tview aln.sorted.bam ref.fasta
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.
30 .SH COMMANDS AND OPTIONS
33 samtools import <in.ref_list> <in.sam> <out.bam>
35 Convert alignments in SAM format to BAM format. File
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
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
52 samtools sort [-n] [-m maxMem] <in.bam> <out.prefix>
54 Sort alignments by leftmost coordinates. File
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
65 Sort by read names rather than by chromosomal coordinates
68 Approximately the maximum required memory. [500000000]
73 samtools merge [-n] <out.bam> <in1.bam> <in2.bam> [...]
75 Merge multiple sorted alignments. The header of
79 and the headers of other files will be ignored.
85 The input alignments are sorted by read names rather than by chromosomal
91 samtools index <aln.bam>
93 Index sorted alignment for fast random access. Index file
99 samtools view [-b] <in.bam> [region1 [...]]
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'.
112 Output in the BAM format.
117 samtools faidx <ref.fasta> [region1 [...]]
119 Index reference sequence in the FASTA format or extract subsequence from
120 indexed reference sequence. If no region is specified,
122 will index the file and create
124 on the disk. If regions are speficified, the subsequences will be
125 retrieved and printed to stdout in the FASTA format. The input file can
132 samtools pileup [-f in.ref.fasta] [-t in.ref_list] [-l in.site_list]
133 [-iscg] [-T theta] [-N nHap] [-r pairDiffRate] <in.alignment>
135 Print the alignment in the pileup format. In the pileup format, each
136 line represents a genomic position, consisting of chromosome name,
137 coordinate, reference base, read bases, read qualities and alignment
138 mapping qualities. Information on match, mismatch, indel, strand,
139 mapping quality and start and end of a read are all encoded at the read
140 base column. At this column, a dot stands for a match to the reference
141 base on the forward strand, a comma for a match on the reverse strand,
142 `ACGTN' for a mismatch on the forward strand and `acgtn' for a mismatch
143 on the reverse strand. A pattern `\\+[0-9]+[ACGTNacgtn]+' indicates
144 there is an insertion between this reference position and the next
145 reference position. The length of the insertion is given by the integer
146 in the pattern, followed by the inserted sequence. Similarly, a pattern
147 `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference. Also at
148 the read base column, a symbol `^' marks the start of a read segment
149 which is a contiguous subsequence on the read separated by `N/S/H' CIGAR
150 operations. The ASCII of the character following `^' minus 33 gives the
151 mapping quality. A symbol `$' marks the end of a read segment.
155 is applied, the consensus base, consensus quality, SNP quality and
156 maximum mapping quality of the reads covering the site will be inserted
157 between the `reference base' and the `read bases' columns. An indel
158 occupies an additional line. Each indel line consists of chromosome
159 name, coordinate, a star, top two high-scoring ins/del sequences, the
160 number of reads strongly supporting the first indel, the number of reads
161 strongly supporting the second indel, the number of reads that confer
162 little information on distinguishing indels and the number of reads that
163 contain indels different from the top two ones.
170 Print the mapping quality as the last column. This option makes the
171 output easier to parse, although this format is not space efficient.
175 Only output pileup lines containing indels.
179 The reference sequence in the FASTA format. Index file
186 List of reference names ane sequence lengths, in the format described
189 command. If this option is present, samtools assumes the input
191 is in SAM format; otherwise it assumes in BAM format.
195 List of sites at which pileup is output. This file is space
196 delimited. The first two columns are required to be chromosome and
197 1-based coordinate. Additional columns are ignored. It is
198 recommended to use option
202 as in the default format we may not know the mapping quality.
206 Call the consensus sequnce using MAQ consensus model. Options
211 are only effective when
217 Generate genotype likelihood in the binary GLFv2 format. This option
218 suppresses -c, -i and -s.
222 The theta parameter (error dependency coefficient) in the maq consensus
227 Number of haplotypes in the sample (>=2) [2]
231 Expected fraction of differences between a pair of haplotypes [0.001]
237 samtools tview <in.sorted.bam> [ref.fasta]
239 Text alignment viewer (based on the ncurses library). In the viewer,
240 press `?' for help and press `g' to check the alignment start from a
241 region in the format like `chr10:10,000,000'. Note that if the region
242 showed on the screen contains no mapped reads, a blank screen will be
243 seen. This is a known issue and will be improved later.
249 samtools fixmate <in.nameSrt.bam> <out.bam>
251 Fill in mate coordinates, ISIZE and mate related flags from a
252 name-sorted alignment.
256 samtools rmdup <input.srt.bam> <out.bam>
258 Remove potential PCR duplicates: if multiple read pairs have identical
259 external coordinates, only retain the pair with highest mapping quality.
262 works with FR orientation and requires ISIZE is correctly set.
269 SAM is TAB-delimited. Apart from the header lines, which are started
270 with the `@' symbol, each alignment line consists of:
276 Col Field Description
278 1 QNAME Query (pair) NAME
280 3 RNAME Reference sequence NAME
281 4 POS 1-based leftmost POSition/coordinate of clipped sequence
282 5 MAPQ MAPping Quality (Phred-scaled)
283 6 CIAGR extended CIGAR string
284 7 MRNM Mate Reference sequence NaMe (`=' if same as RNAME)
285 8 MPOS 1-based Mate POSistion
286 9 ISIZE Inferred insert SIZE
287 10 SEQ query SEQuence on the same strand as the reference
288 11 QUAL query QUALity (ASCII-33 gives the Phred base quality)
289 12 OPT variable OPTional fields in the format TAG:VTYPE:VALUE
293 Each bit in the FLAG field is defined as:
301 0x0001 the read is paired in sequencing
302 0x0002 the read is mapped in a proper pair
303 0x0004 the query sequence itself is unmapped
304 0x0008 the mate is unmapped
305 0x0010 strand of the query (1 for reverse)
306 0x0020 strand of the mate
307 0x0040 the read is the first read in a pair
308 0x0080 the read is the second read in a pair
309 0x0100 the alignment is not primary
310 0x0200 the read fails platform/vendor quality checks
311 0x0400 the read is either a PCR or an optical duplicate
317 In general, more testing is needed to ensure there is no severe bug.
319 Reference sequence names and lengths are not acquired from the BAM/SAM header.
321 CIGAR operations N and P may not be properly handled.
323 There is a small memory leak in the viewer.
327 Heng Li from the Sanger Institute is the author of the C version of
328 samtools. Bob Handsaker from the Broad Institute implemented the BGZF
329 library and Jue Ruan from Beijing Genomics Institute wrote the RAZF
330 library. Various people in the 1000Genomes Project contributed to the
331 SAM format specification.
335 Samtools website: http://samtools.sourceforge.net