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

pdb_reres was ignoring MODEL lines #69

Merged
merged 2 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions pdbtools/pdb_reres.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def renumber_residues(fhandle, starting_resid):
line = _pad_line(line)
if line.startswith('MODEL'):
resid = starting_resid - 1 # account for first residue
prev_resid = None # tracks chain and resid
yield line

elif line.startswith(records):
line_resuid = line[17:27]
if line_resuid != prev_resid:
Expand Down
13 changes: 13 additions & 0 deletions tests/data/ensemble_more_OK.pdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
HEADER THIS A DUMMY PDB FOR PDB-TOOLS TESTING
TITLE A RANDOM PDB
MODEL 1
ATOM 1 N ASN A 1 22.066 40.557 0.420 1.00 0.00 N
ATOM 2 H ASN A 1 21.629 41.305 -0.098 1.00 0.00 H
ATOM 3 N ASN A 2 22.066 40.557 0.420 1.00 0.00 N
ATOM 4 H ASN A 2 21.629 41.305 -0.098 1.00 0.00 H
ENDMDL
MODEL 2
ATOM 1 N ASN A 1 22.066 40.557 0.420 1.00 0.00 N
ATOM 2 H ASN A 1 21.629 41.305 -0.098 1.00 0.00 H
ENDMDL
END
44 changes: 44 additions & 0 deletions tests/test_pdb_reres.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,50 @@ def test_two_options_neg(self):

self.assertEqual(resid_list, expected)

def test_three_with_single_res_models(self):
"""$ pdb_reres -4 data/ensemble.OK.pdb"""
sys.argv = ['', '-4', os.path.join(data_dir, 'ensemble_OK.pdb')]

self.exec_module()

self.assertEqual(self.retcode, 0)
self.assertEqual(len(self.stdout), 11)
self.assertEqual(len(self.stderr), 0)

records = ('ATOM', 'HETATM')
resid_list = [int(l[22:26]) for l in self.stdout
if l.startswith(records)]

expected = [4, 4, 4, 4]
self.assertEqual(resid_list, expected)

models = ('MODEL',)
models_int = [int(l[5:]) for l in self.stdout if l.startswith(models)]
models_expected = [1, 2]
self.assertEqual(models_int, models_expected)

def test_three_with_models(self):
"""$ pdb_reres -4 data/ensemble.OK.pdb"""
sys.argv = ['', '-4', os.path.join(data_dir, 'ensemble_more_OK.pdb')]

self.exec_module()

self.assertEqual(self.retcode, 0)
self.assertEqual(len(self.stdout), 13)
self.assertEqual(len(self.stderr), 0)

records = ('ATOM', 'HETATM')
resid_list = [int(l[22:26]) for l in self.stdout
if l.startswith(records)]

expected = [4, 4, 5, 5, 4, 4]
self.assertEqual(resid_list, expected)

models = ('MODEL',)
models_int = [int(l[5:]) for l in self.stdout if l.startswith(models)]
models_expected = [1, 2]
self.assertEqual(models_int, models_expected)

def test_too_many_residues(self):
"""$ pdb_reres -9998 data/dummy.pdb"""

Expand Down