Question: Manipulating header (and contents) of a vcf file
0
gravatar for kirannbishwa01
3.7 years ago by
kirannbishwa011.1k
United States
kirannbishwa011.1k wrote:

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 !

variants sed vcf • 1.7k views
ADD COMMENTlink modified 3.7 years ago by RamRS25k • written 3.7 years ago by kirannbishwa011.1k
1
gravatar for RamRS
3.7 years ago by
RamRS25k
Houston, TX
RamRS25k wrote:

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 COMMENTlink written 3.7 years ago by RamRS25k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 767 users visited in the last hour