Adding columns with values dependent on existing columns

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

Try this code:

awk 'NR==1 {
        print;
  } NR>1 {
        if((length($3)==1)&&(length($4)>1)) {
                print;
                print $1,$2,$3,$4,$2,$2+2;
        }
        else if((length($3)>1)) {
                print;
                print $1,$2,$3,$4,$2-1,$2+length($3)+1;
        }
        else
                print;
}' OFS='\t' filename

How about below perl code?

while(<DATA>){
    chomp;
	s/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
	  (length($3)>1)?$_." ".($2-1)." ".($2+length($3)+1):$_." ".$2." ".($2+2)
	/ex;
	print $_,"\n";
}
__DATA__
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

or below python code:

with open("a.txt","r") as f:
 for line in f:
  line=line.replace("\n","")
  words=line.split(" ")
  if len(words[2])==1:
   words.append(words[1])
   words.append(str(int(words[1])+2))
  else:
   words.append(str(int(words[1])-1))
   words.append(str(int(words[1])+len(words[2])+1))
  print(" ".join(words))