Skip to content

sum up snv

masikol edited this page Mar 27, 2024 · 3 revisions

sum-up-snv

Description

Script for summarizing variation ant single specified position in SAM/BAM file.

It's output is simple and self-descriptive:

Position 3436:
Coverage: 53
A:    0 |   0,0%
T:    1 |   1,9%
G:    1 |   1,9%
C:   51 |  96,2%
*:    0 |   0,0%

, where '*' is a gap.

In the verbose mode, the script also prints a tab-separated table of three columns: read_name, base, base_quality, for example:

cbef4273-758c-41de-87f3-b923a94039c4  A  27
0bc23ebf-2669-4eaf-9dfe-86db4779ea4c  G  23
28f6d93b-deeb-41ee-8175-a635f3d4c94c  A  17
0975f99f-d20e-489b-8ce9-42ec5d43b439  G  6
1a3ad162-3429-47c1-92a1-682ee3aefac4  G  25
Position 3436:
Coverage: 5
A:    2 |  40,0%
T:    0 |   0,0%
G:    0 |   0,0%
C:    3 |  60,0%
*:    0 |   0,0%

Dependencies

  • samtools;
  • the script is written in AWK, so you need AWK to use it;

The script is tested on GNU Awk 5.0.1.

Limitations

The script does not understand following CIGAR operations: =XPN.

Usage

Basic usage:

samtools view <BAM/SAM> | awk -f sum_up_snv.awk pos=<POS>

Example:

samtools view my_mapping.bam | awk -f sum_up_snv.awk pos=1067

Verbose mode

samtools view my_mapping.bam | awk -f sum_up_snv.awk pos=1067 verbose=1

Faster -- specify reference sequence name:

samtools view <BAM/SAM> <RNAME> | awk -f sum_up_snv.awk pos=<POS> Example: samtools view my_mapping.bam chr1 | awk -f sum_up_snv.awk pos=1067

Even faster -- specify single-base region:

samtools view <BAM/SAM> <RNAME>:<POS>-<POS> | awk -f sum_up_snv.awk pos=<POS> Example: samtools view my_mapping.bam chr1:1067-1067 | awk -f sum_up_snv.awk pos=1067