Remove Single Info Field From Vcf
3
2
Entering edit mode
10.9 years ago
Brett Thomas ▴ 300

What's the quickest way to remove a single INFO field from a VCF file? Don't care what framework - vcftools, pyvcf, whatever. Just want a one liner to do this.

In this case, I just want to remove the ensembl CSQ field so I can annotate again

vcf • 7.5k views
ADD COMMENT
4
Entering edit mode
10.9 years ago
Sangwoo Kim ▴ 420

The below python function takes a vcf line (non-header) and will return a line without CSQ field. Good luck~

def removeCSQ(line):
        values = line.split()
        INFO = values[7]
        NEWINFO = []
        for info in INFO.split(";"):
                if not "CSQ=" in info:
                        NEWINFO.append(info)
        values[7] = ";".join(NEWINFO)
        return "\t".join(values)
ADD COMMENT
2
Entering edit mode
7.1 years ago
Len Trigg ★ 1.6k

Using RTG Tools:

rtg vcfsubset -i in.vcf -o out.vcf --remove-info CSQ
ADD COMMENT
1
Entering edit mode
7.1 years ago

Use vt package

vt rminfo in.vcf -t CSQ -o out.vcf
ADD COMMENT

Login before adding your answer.

Traffic: 2560 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6