我有一个pdb文件,表示文件的轨迹
$('#container').on('click', '.answer', function () {
alert("Hi");
})
我想打印信息
REMARK GENERATED BY TRJCONV
TITLE Protein in water t= 400.00000
REMARK THIS IS A SIMULATION BOX
CRYST1 99.547 99.547 99.547 90.00 90.00 90.00 P 1 1
MODEL 1
ATOM 1 N PRO A 1 46.850 67.380 57.030 1.00 0.00
ATOM 2 H1 PRO A 1 46.230 66.770 56.500 1.00 0.00
ATOM 3 H2 PRO A 1 46.420 68.290 56.940 1.00 0.00
ATOM 4 CD PRO A 1 47.060 66.780 58.360 1.00 0.00
TER
ENDMDL
REMARK GENERATED BY TRJCONV
TITLE Protein in water t= 800.00000
REMARK THIS IS A SIMULATION BOX
MODEL 10
ATOM 1 N PRO A 1 46.850 67.380 57.030 1.00 0.00
ATOM 2 H1 PRO A 1 46.230 66.770 56.500 1.00 0.00
ATOM 3 H2 PRO A 1 46.420 68.290 56.940 1.00 0.00
ATOM 4 CD PRO A 1 47.060 66.780 58.360 1.00 0.00
TER
ENDMDL
REMARK GENERATED BY TRJCONV
TITLE Protein in water t= 1200.00000
REMARK THIS IS A SIMULATION BOX
MODEL 100
ATOM 1 N PRO A 1 46.850 67.380 57.030 1.00 0.00
ATOM 2 H1 PRO A 1 46.230 66.770 56.500 1.00 0.00
ATOM 3 H2 PRO A 1 46.420 68.290 56.940 1.00 0.00
ATOM 4 CD PRO A 1 47.060 66.780 58.360 1.00 0.00
TER
ENDMDL
适用于所有型号。保留文件的格式。我试过这个
MODEL 1
[all info]
TER
ENDMDL
但是我的文件非常庞大,无法手动完成。我想将每个模型保存为model1,model2等,并将其坐标信息保存到ENDMDL
答案 0 :(得分:2)
$ awk '/MODEL/{f="model" $2 ".pdb"} f{print > f} /ENDMDL/ {close(f);f=""}' file
$ cat model1.pdb
MODEL 1
ATOM 1 N PRO A 1 46.850 67.380 57.030 1.00 0.00
ATOM 2 H1 PRO A 1 46.230 66.770 56.500 1.00 0.00
ATOM 3 H2 PRO A 1 46.420 68.290 56.940 1.00 0.00
ATOM 4 CD PRO A 1 47.060 66.780 58.360 1.00 0.00
TER
ENDMDL
说明:
/MODEL/ { # @ MODEL
f="model" $2 ".pdb" # use f as flag and target filename
}
f { # when there is an f
print > f # output to file in f
}
/ENDMDL/ { # at the ENDMDL
close(f) # close the file
f="" # unset f
}