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

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

vcf variants sed • 2.2k views
1
Entering edit mode
5.5 years ago
Ram 34k

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.

Traffic: 1635 users visited in the last hour
FAQ
API
Stats

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