Many thanks, the genotype format of my vcf file is like this 0|0, 1|1, 2|2, ./. so I replaced
if gt == '0|0' or gt == '0/0':
letter = ref*2
elif gt == '0|1'or gt == '0/1':
letter = ref+alt
elif gt == '1|1'or gt == '1/1':
letter = alt*2
by
if gt == '0|0' or gt == '0/0':
letter = ref*2
elif gt == '1|1'or gt == '1/1':
letter = ref+alt
elif gt == '2|2'or gt == '2/2':
letter = alt*2
It needs parenthesis in print statement so I added parenthesis
(print 'only accept BIALLELIC SNP\nremove this site\n')
But I am getting this error:
Traceback (most recent call last):
File "letter.py", line 76, in <module>
Letter(vcf).write_out()
File "letter.py", line 70, in write_out
f.write(''.join(self.vcfhead))
File "/home/waqas/miniconda3/lib/python3.6/gzip.py", line 260, in write
data = memoryview(data)
TypeError: memoryview: a bytes-like object is required, not 'str'