Need to add letters to a column and add in a new column subtracting from another column

So I have this input

1    10327    rs112750067    T    C    .    PASS    DP=65;AF=0.208;CB=BC,NCBI
1    10469    rs117577454    C    G    .    PASS    DP=2055;AF=0.020;CB=UM,BC,NCBI
1    10492    rs55998931    C    T    .    PASS    DP=231;AF=0.167;CB=BC,NCBI
1    10583    rs58108140    G    A    .    PASS    DP=1557;AF=0.162;CB=UM,BI,BC,NCBI
1    11508    .    A    G    .    PASS    DP=23;AF=0.720;CB=BI,BC
1    11565    .    G    T    .    PASS    DP=45;AF=0.000;CB=BI,BC
1    12783    .    G    A    .    PASS    DP=4010;AF=0.56

And I want this output - basically add "chr" to the first column, then have a new 2nd column where the data is -1 from column 3. i.e.

chr1   10326    10327    rs112750067    T    C    .    PASS    DP=65;AF=0.208;CB=BC,NCBI
chr1   10468    10469    rs117577454    C    G    .    PASS    DP=2055;AF=0.020;CB=UM,BC,NCBI
chr1   10491    10492    rs55998931    C    T    .    PASS    DP=231;AF=0.167;CB=BC,NCBI
chr1   10582    10583    rs58108140    G    A    .    PASS    DP=1557;AF=0.162;CB=UM,BI,BC,NCBI
chr1   11507    11508    .    A    G    .    PASS    DP=23;AF=0.720;CB=BI,BC
chr1   11564    11565    .    G    T    .    PASS    DP=45;AF=0.000;CB=BI,BC
chr1   12782    12783    .    G    A    .    PASS    DP=4010;AF=0.56Please help!

Thank you

P.S. This file is pretty massive (25,000,000 lines)

cat $1 |awk '{
   c1="chr" $1
   c2=$2-1
   c3=$2
   cut_lng=(length($1 $2)+3)
   ln_l=length($0)
   c4=(substr($0,cut_lng,ln_l-cut_lng))
   printf("%s %s %s %s\n",c1,c2,c3,c4)
}'

kellywilliams - Sorry My first code did not retain the input format I.E. spacing between the characters / fields in the output.
The new code below should resolve the output problem and retain the input spacing format.

cat $1 |awk '{
   c1="chr" $1
   c2="    " $2-1
   c3="    " $2
   z=(sprintf("%s    %s\n",$1,$2))
   cut_lng=(length(z))
   ln_l=length($0)
   c4=(substr($0,cut_lng,ln_l-cut_lng))
   printf("%s %s %s %s\n",c1,c2,c3,c4)
}'
1 Like
awk '{$1="chr"$1; $2=($2-1)FS$2; print}' infile
1 Like
awk '{$1="chr" $1 FS $2-1}1' infile
1 Like