From 951f690e1dc467ee54b0e1d4218bebf536468ff1 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Sat, 26 Nov 2016 08:47:48 +0100 Subject: [PATCH] samtools: add page (#1159) --- pages/common/samtools.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pages/common/samtools.md diff --git a/pages/common/samtools.md b/pages/common/samtools.md new file mode 100644 index 000000000..3a1773a01 --- /dev/null +++ b/pages/common/samtools.md @@ -0,0 +1,36 @@ +# samtools + +> Tools for handling high-throughput sequencing (genomics) data. +> Used for reading/writing/editing/indexing/viewing of data in SAM/BAM/CRAM format. + +- Convert a SAM input file to BAM stream and save to file: + +`samtools view -S -b {{input.sam}} > {{output.bam}}` + +- Take input from stdin (-) and print the SAM header and any reads overlapping a specific region to stdout: + +`{{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: + +`samtools merge {{output}} {{input_1}} [{{input_2}}...]` + +- Split input file according to read groups: + +`samtools split {{merged_input}}`