Skip to content

Instantly share code, notes, and snippets.

@arteymix
Created November 5, 2019 21:29
Show Gist options
  • Save arteymix/16d2fb48394ee9e14a5004cef1ad6e75 to your computer and use it in GitHub Desktop.
Save arteymix/16d2fb48394ee9e14a5004cef1ad6e75 to your computer and use it in GitHub Desktop.
Convert CADD annotations to VCF
#!/usr/bin/env python
#
# Converts the CADD format to VCF
#
import sys
import csv
print('''##fileformat=VCFv4.2
##INFO<ID=CADD_SCORE,Number=A,Type=Float,Description="CADD Score">
#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO''')
reader = csv.reader(sys.stdin, delimiter='\t')
writer = csv.writer(sys.stdout, delimiter='\t')
for row in reader:
if row[0].startswith('#'):
continue
chrom, pos, ref, alt, cadd_score, cadd_phred = row
writer.writerow([chrom, pos, '.', ref, alt, cadd_phred, '.', 'CADD_SCORE={}'.format(cadd_score)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment