Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved handling of insertion codes #184

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pdbfixer/pdbfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,17 @@ def findMissingResidues(self):
# Find the sequence of each chain, with gaps for missing residues.

for chain in chains:
minResidue = min(int(r.id) for r in chain.residues())
maxResidue = max(int(r.id) for r in chain.residues())
residues = [None]*(maxResidue-minResidue+1)
for r in chain.residues():
residues[int(r.id)-minResidue] = r.name
chainWithGaps[chain] = residues
residues = list(chain.residues())
ids = [int(r.id) for r in residues]
for i, res in enumerate(residues):
if res.insertionCode not in ('', ' '):
for j in range(i, len(residues)):
ids[j] += 1
minResidue = min(ids)
maxResidue = max(ids)
chainWithGaps[chain] = [None]*(maxResidue-minResidue+1)
for r, id in zip(residues, ids):
chainWithGaps[chain][id-minResidue] = r.name

# Try to find the chain that matches each sequence.

Expand Down