Skip to content

Commit

Permalink
bugfix in pdb parser
Browse files Browse the repository at this point in the history
pdb that failed to parse: 2J88
it had a missing CA and so was excluded from res/pdb_idx, but then failed during full atom pass.
  • Loading branch information
sokrypton committed Mar 31, 2023
1 parent c042c0e commit 6e6e479
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions inference/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,13 @@ def parse_pdb(filename, **kwargs):

def parse_pdb_lines(lines, parse_hetatom=False, ignore_het_h=True):
# indices of residues observed in the structure
res = [
(l[22:26], l[17:20])
for l in lines
if l[:4] == "ATOM" and l[12:16].strip() == "CA"
]
res, pdb_idx = [],[]
for l in lines:
if l[:4] == "ATOM" and l[12:16].strip() == "CA":
res.append((l[22:26], l[17:20]))
# chain letter, res num
pdb_idx.append((l[21:22].strip(), int(l[22:26].strip())))
seq = [util.aa2num[r[1]] if r[1] in util.aa2num.keys() else 20 for r in res]
pdb_idx = [
(l[21:22].strip(), int(l[22:26].strip()))
for l in lines
if l[:4] == "ATOM" and l[12:16].strip() == "CA"
] # chain letter, res num

# 4 BB + up to 10 SC atoms
xyz = np.full((len(res), 14, 3), np.nan, dtype=np.float32)
Expand All @@ -562,16 +558,17 @@ def parse_pdb_lines(lines, parse_hetatom=False, ignore_het_h=True):
" " + l[12:16].strip().ljust(3),
l[17:20],
)
idx = pdb_idx.index((chain, resNo))
# for i_atm, tgtatm in enumerate(util.aa2long[util.aa2num[aa]]):
for i_atm, tgtatm in enumerate(
util.aa2long[util.aa2num[aa]][:14]
): # Nate's proposed change
if (
tgtatm is not None and tgtatm.strip() == atom.strip()
): # ignore whitespace
xyz[idx, i_atm, :] = [float(l[30:38]), float(l[38:46]), float(l[46:54])]
break
if (chain,resNo) in pdb_idx:
idx = pdb_idx.index((chain, resNo))
# for i_atm, tgtatm in enumerate(util.aa2long[util.aa2num[aa]]):
for i_atm, tgtatm in enumerate(
util.aa2long[util.aa2num[aa]][:14]
): # Nate's proposed change
if (
tgtatm is not None and tgtatm.strip() == atom.strip()
): # ignore whitespace
xyz[idx, i_atm, :] = [float(l[30:38]), float(l[38:46]), float(l[46:54])]
break

# save atom mask
mask = np.logical_not(np.isnan(xyz[..., 0]))
Expand Down

0 comments on commit 6e6e479

Please sign in to comment.