I have a file (.pdb) that looks like this:
ATOM 1 BB MET A 1 4.171 16.195 -18.221 1.00 0.00 B
ATOM 2 SC1 MET A 1 0.852 15.586 -20.418 1.00 0.00 S
ATOM 3 BB GLU A 3 9.285 12.756 -18.753 1.00 22.00 B
I would like to replace the values in column 11 by another one from another txt file that looks like this:
4.61
4.80
15.81
The output should be:
ATOM 1 BB MET A 1 4.171 16.195 -18.221 1.00 4.61 B
ATOM 2 SC1 MET A 1 0.852 15.586 -20.418 1.00 4.80 S
ATOM 3 BB GLU A 3 9.285 12.756 -18.753 1.00 15.81 B
I tried with awk the following
awk ' NR==FNR{a[NR]=$0; next}{$11=a[FNR]}1' file2.txt fil1.pdb > output.pdb
but the format is not preserved. I got something like this:
ATOM 1 BB MET A 1 4.171 16.195 -18.221 1.00 4.61 B
ATOM 2 SC1 MET A 1 0.852 15.586 -20.418 1.00 4.80 S
ATOM 3 SC1 GLU A 3 9.285 12.756 -18.753 1.00 15.81 B
Any suggestions to retain the format while substitution?