I would like to find the count of homozygous major(0|0),homozygous minor(1|1) and heterozygous(1|0,0|1) alleles for each position of a chromosome.I would like to form a table like this:

**POS   00    1 0/0 1  11**

Pos1    n1      n2       n3

Pos2    n4      n5      n6

where n1...n6 are the counts .

See the example file here [1000Genomes][1]


  [1]: ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/ALL.chr22.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz

Any suggestions  to try to get this information would be much appreciated

Thanks in Advance


An `awk` solution:

    $ zcat input.vcf.gz|awk -v OFS="\t" '$0 !~ "^#" {hom_ref = 0; hom_alt = 0; het = 0; for(i=10;i<=NF;i++) { if($i ~ /0\|0/) hom_ref++; else if($i ~ /1\|1/) hom_alt++;  else het++; } print $1, $2, hom_ref, hom_alt, het}'

fin swimmer