编辑后保持PDB文件格式. [英] keeping PDB file format after editing.
问题描述
我的xxx.pdb文件为:
I have xxx.pdb files as:
ATOM 1910 CB SER 128 45.806 50.621 39.840 1.00 9.36
ATOM 1913 OG SER 128 44.538 51.195 39.571 1.00 9.36
ATOM 1915 C SER 128 45.325 48.172 40.360 1.00 9.36
ATOM 1916 O SER 128 45.368 47.955 39.155 1.00 9.36
ATOM 1917 N SER 129 44.953 47.236 41.238 1.00 11.24
ATOM 1919 CA SER 129 44.395 45.938 40.826 1.00 11.24
ATOM 1921 CB SER 129 44.091 45.053 42.031 1.00 11.24
ATOM 1924 OG SER 129 43.483 45.786 43.085 1.00 11.24
当我尝试这段代码时:awk'{if($ 10< 11){$ 9 ="1.50"}; print $ 0}'xxx.pdb
When I tried this code: awk '{if($10<11){$9="1.50"};print $0}' xxx.pdb
这件事发生了:
ATOM 1910 CB SER 128 45.806 50.621 39.840 1.50 9.36
ATOM 1913 OG SER 128 44.538 51.195 39.571 1.50 9.36
ATOM 1915 C SER 128 45.325 48.172 40.360 1.50 9.36
ATOM 1916 O SER 128 45.368 47.955 39.155 1.50 9.36
ATOM 1917 N SER 129 44.953 47.236 41.238 1.00 11.24
ATOM 1919 CA SER 129 44.395 45.938 40.826 1.00 11.24
ATOM 1921 CB SER 129 44.091 45.053 42.031 1.00 11.24
ATOM 1924 OG SER 129 43.483 45.786 43.085 1.00 11.24
关于如何保留列格式的任何想法?
Any idea on how to preserve the column formatting?
谢谢.
推荐答案
我不确定您要完成什么,但是通常来说,是要读取xxx.pdb文件,然后输出new.pdb格式正确的文件,这就是我的工作:
I'm not sure what you're trying to accomplish, but in general, to read in a xxx.pdb file, and then output a new.pdb file with proper format, this is what I do:
awk '{printf "%4s%7.0f%3s%6s%2s%4.0f%12.3f%8.3f%8.3f%6.2f%7.2f\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11}' < xxx.pdb >> new.pdb
(此代码除了进行复制外实际上不会做任何事情)
(This code won't actually do anything except make a copy)
如果我想使用变量来更改一个字段(如第二个字段),它看起来像:
If I wanted to use a variable to change one of the fields (like the second field), it would look like:
VARIABLE=3
awk -v x=$VARIABLE '{printf "%4s%7.0f%3s%6s%2s%4.0f%12.3f%8.3f%8.3f%6.2f%7.2f\n", $1, ($2 + x), $3, $4, $5, $6, $7, $8, $9, $10, $11}' < xxx.pdb >> new.pdb
这会将pdb文件的第二列全部加3.
This would add 3 to all the entire second column of the pdb file.
这篇关于编辑后保持PDB文件格式.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!