This is a test version of Biostars. For the public version, visit https://www.biostars.org.
divide vcf file by consequence

I have a VEP annotated VCF file I want to divide it based on consequence, my approach is:

awk '{ gsub(",","-",$4); print $0 >> $4".txt"}' input.txt

I substitute "," by "-" so file naming be convenient, but as a result because I depend on column 4 for naming; also the resulted file will contains "-"

for example if column number 4 is
start_lost,splice_region_variant
The output file will be
start_lost-splice_region_variant.txt
Which what I want. However, the resulted data in the file will be
start_lost-splice_region_variant instead of start_lost,splice_region_variant which is incorrect.

Any suggestion?

vcf awk

Could you provide first few lines of the vcf? May be head file.vcf?

1 answer

do a copy of $0?

awk '{ P=$0; gsub(",","-",$4); print P >> $4".txt"}' input.txt

Log in to answer this question.