Remove Single Info Field From Vcf
3
2
Entering edit mode
11.5 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.7k views
ADD COMMENT
4
Entering edit mode
11.5 years ago
Sangwoo Kim ▴ 440

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.7 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.7 years ago

Use vt package

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

Login before adding your answer.

Traffic: 1646 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