#!/bin/bash

#
# Count the number of alternative alleles in a .vcf or .vcf.gz file
#

# gsub returns number of substitutions made
gzip -fcd $1 | \
awk 'BEGIN {i = 0} {if(!($1 ~ /^#/ || $1 == "'""'")) {i += gsub(",",",",$5)+1;}} END {print i}'
