Manipulating header (and contents) of a vcf file
1
0
Entering edit mode
8.1 years ago
kirannbishwa01 ★ 1.6k

I want to manipulate (acutally add information to) the vcf file and its header information. I tried using sed in linux but just couldn't understand it.

It original vcf file looks like:

CHROM POS REF ALT

1 69 A G

1 75 C T

1 85 G A

I want to add the "ID" field after the 2nd column and replace the value for this field with "." Additionally I want to add other fields "QUAL", "FILTER" and "INFO" after the last column. All the columns should be tab separated and finally should look like.

CHROM POS ID REF ALT QUAL FILTER INFO

1 69 . A C . . .

1 75 . G A . . .

1 87 . C A . . .

1 88 . T C . . .

Thanks much in advance !

vcf variants sed • 2.8k views
ADD COMMENT
1
Entering edit mode
8.1 years ago
Ram 43k

You're looking to modify a stream of text. Substitution using sed works like this:

sed 's/old_text_or_regex/new_text_or_regex/modifiers/' input_file >output_file

But this scenario is better addressed using awk, where you can process individual columns and just add column at the appropriate position.

Once again, I'm providing no code because that would cripple learning.

ADD COMMENT

Login before adding your answer.

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