0

我想计算 pdb 文件中每个残基的原子数。PDB 文件如下所示。第三列表示原子,第四列表示残基。

ATOM      1  N   ASN A 380      -0.011  22.902 -13.714  1.00 65.81           N
ATOM      2  CA  ASN A 380       0.401  23.938 -12.714  1.00 65.53           C 
ATOM      3  C   ASN A 380       1.926  24.019 -12.595  1.00 64.48           C
ATOM      9  N   THR A 381       2.553  24.693 -13.562  1.00 61.65           N
ATOM     10  CA  THR A 381       4.006  24.848 -13.609  1.00 58.60           C 
ATOM     16  N   ILE A 382       5.156  22.716 -13.481  1.00 53.48           N  
ATOM     17  CA  ILE A 382       5.808  21.571 -12.830  1.00 49.47           C
ATOM     18  C   ILE A 382       6.645  21.933 -11.584  1.00 45.24           C
ATOM     28  CB  GLN A 383       8.735  24.763 -10.759  1.00 30.19           C 
ATOM     29  CG  GLN A 383      10.140  24.257 -11.037  1.00 29.17           C
ATOM     30  CD  ASN A 384      10.397  23.975 -12.514  1.00 29.51           C
ATOM     31  OE1 ASN A 384      10.892  24.838 -13.237  1.00 30.67           O 

我想得到如下输出

Total no:of ASN atoms - 5
Total no:of THR atoms - 2
Total no:of ILE atoms - 3
Total no:of GLN atoms - 2
4

1 回答 1

0

这应该做的工作:

awk '{print $4}' <file> | sort | uniq -c | \
    awk '{print "Total no:of", $2, "atoms -", $1}'

或纯awk

awk '{atom[$4]++;}
    END{for (i in atom) {print "Total no:of", i, "atoms -", atom[i]} }' <file>

两种方法的输出:

Total no:of GLN atoms - 2
Total no:of THR atoms - 2
Total no:of ASN atoms - 5
Total no:of ILE atoms - 3
于 2013-03-18T04:32:15.663 回答