Hello
I have a file as below
chr1 start ref alt code1 code2
chr1 18884 C CAAAA 2 0
chr1 135419 TATACA T 2 0
chr1 332045 T TTG 0 2
chr1 453838 T TAC 2 0
chr1 567652 T TG 1 0
chr1 602541 TTTA T 2 0
on which I want to add new columns such that:
if ref is a string >1 (i.e line 2) then I generate 2 new columns where:
first new column = start-1
second new column = start+(length of string in ref)+1
therefore, for line 2 output would look like:
chr1 135419 TATACA T 2 0 135418 135426
or:
if length of string in ref = 1 and alt=string of length>1 (i.e. line 1) then
first new column = start
second new column = start+2
so, output for line 1 would be:
chr1 18884 C CAAAA 2 0 18884 18886
Anybody able to help with an approach to doing this?
Would awk be the best way to do this? My perl is non-existent otherwise I imagine that would be a good way to do it