replace first column based on third column in modeled PDB file
1
0
Entering edit mode
9.5 years ago
venu 7.1k

I've modeled a protein. Here I want to replace ATOM with HETATM when fourth column contains UNK. Here is a sample of pdb file.

ATOM   7525  HB2 PHE A 462      24.643 -50.200  29.725  1.00  0.00           H
ATOM   7526  HD1 PHE A 462      22.585 -51.535  30.162  1.00  0.00           H
ATOM   7527  HD2 PHE A 462      25.166 -52.418  26.825  1.00  0.00           H
ATOM   7528  HE1 PHE A 462      20.867 -53.074  29.206  1.00  0.00           H
ATOM   7529  HE2 PHE A 462      23.429 -53.905  25.870  1.00  0.00           H
ATOM   7530  HZ  PHE A 462      21.293 -54.268  27.091  1.00  0.00           H
TER    7531  HZ  PHE A 462
ATOM   7532  O1  UNK     1       8.575 -36.095  63.165  1.00  0.00           O
ATOM   7533  O2  UNK     1      10.566 -35.374  62.229  1.00  0.00           O
ATOM   7534  N3  UNK     1       6.742 -36.630  57.870  1.00  0.00           N
ATOM   7535  N4  UNK     1       9.871 -33.867  59.866  1.00  0.00           N
ATOM   7536  C5  UNK     1       8.179 -34.893  58.559  1.00  0.00           C
ATOM   7537  C6  UNK     1       6.720 -35.389  58.665  1.00  0.00           C

I've tried sed, but unable to give a condition on specific column and replace first column.

awk sed • 2.9k views
ADD COMMENT
3
Entering edit mode
9.5 years ago
Martombo ★ 3.1k

You can use awk for this:

awk '{if($4 == "UNK") $1 = "HETATM"; print}' file.pdb >mod_file.pdb
ADD COMMENT
0
Entering edit mode

I thought it awk extracts the lines containing UNK. Thank you

ADD REPLY
0
Entering edit mode

You can move the comment to an answer :).

ADD REPLY

Login before adding your answer.

Traffic: 1474 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6