2016-11-26 07:47:48 +00:00
|
|
|
# samtools
|
|
|
|
|
|
|
|
> Tools for handling high-throughput sequencing (genomics) data.
|
|
|
|
> Used for reading/writing/editing/indexing/viewing of data in SAM/BAM/CRAM format.
|
2021-08-12 23:33:57 +01:00
|
|
|
> More information: <https://www.htslib.org>.
|
2016-11-26 07:47:48 +00:00
|
|
|
|
|
|
|
- Convert a SAM input file to BAM stream and save to file:
|
|
|
|
|
|
|
|
`samtools view -S -b {{input.sam}} > {{output.bam}}`
|
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Take input from stdin (-) and print the SAM header and any reads overlapping a specific region to stdout:
|
2016-11-26 07:47:48 +00:00
|
|
|
|
|
|
|
`{{other_command}} | samtools view -h - chromosome:start-end`
|
|
|
|
|
|
|
|
- Sort file and save to BAM (the output format is automatically determined from the output file's extension):
|
|
|
|
|
|
|
|
`samtools sort {{input}} -o {{output.bam}}`
|
|
|
|
|
|
|
|
- Index a sorted BAM file (creates {{sorted_input.bam.bai}}):
|
|
|
|
|
|
|
|
`samtools index {{sorted_input.bam}}`
|
|
|
|
|
|
|
|
- Print alignment statistics about a file:
|
|
|
|
|
|
|
|
`samtools flagstat {{sorted_input}}`
|
|
|
|
|
|
|
|
- Count alignments to each index (chromosome / contig):
|
|
|
|
|
|
|
|
`samtools idxstats {{sorted_indexed_input}}`
|
|
|
|
|
|
|
|
- Merge multiple files:
|
|
|
|
|
2019-02-01 17:17:21 +00:00
|
|
|
`samtools merge {{output}} {{input1 input2 …}}`
|
2016-11-26 07:47:48 +00:00
|
|
|
|
|
|
|
- Split input file according to read groups:
|
|
|
|
|
|
|
|
`samtools split {{merged_input}}`
|