Extracting Data From Vcf File
3
0
Entering edit mode
12.4 years ago
bioinfo ▴ 840

Hi from my vcf file, I have extracted the homozygous SNPs and got a new vcf file but it has no INFO section at the header. How can I keep the INFO section untouched? My commands: more file.vcf | grep "1/1" > homo.vcf What else do I need to add in the above arguments to protect the 13 lines INFO section at the header of vcf file?

vcftools gatk vcf samtools • 5.8k views
ADD COMMENT
3
Entering edit mode
12.4 years ago

try to use a regular expression, with egrep and '^#' ( hash starting a line)

egrep '(^#|1/1)' file.vcf > homo.vcf
ADD COMMENT
0
Entering edit mode

And then after you can do your previous command but make sure to append so as not to over write.

more file.vcf | grep "1/1" >> homo.vcf

Also if you know exactly how many lines are in your header that you want to keep (like say 13) you can do:

head -13 > homo.vcf to put the header in a file.

ADD REPLY

Login before adding your answer.

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