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

Ignores CONECT lines in pdb_tidy #74

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 0 additions & 15 deletions pdbtools/pdb_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ def make_TER(prev_line):

# TER 606 LEU A 75
fmt_TER = "TER {:>5d} {:3s} {:1s}{:>4s}{:1s}" + " " * 53 + "\n"
# CONECT 1179 746 1184 1195 1203
fmt_CONECT = "CONECT{:>5s}{:>5s}{:>5s}{:>5s}{:>5s}" + " " * 49 + "\n"
char_ranges = (slice(6, 11), slice(11, 16),
slice(16, 21), slice(21, 26), slice(26, 31))

records = ('ATOM', 'HETATM')
ignored = ('TER', 'END ', 'END\n')
Expand All @@ -124,7 +120,6 @@ def make_TER(prev_line):
break

# Now go through all the remaining lines
serial_equiv = {} # store for conect statements
atom_section = False
serial_offset = 0 # To offset after adding TER records
for line in fhandle:
Expand Down Expand Up @@ -165,16 +160,6 @@ def make_TER(prev_line):
line = line[:6] + str(serial).rjust(5) + line[11:]

elif line.startswith('CONECT'):
joaomcteixeira marked this conversation as resolved.
Show resolved Hide resolved
if atom_section:
atom_section = False
yield make_TER(prev_line)

# 6:11, 11:16, 16:21, 21:26, 26:31
serials = [line[cr] for cr in char_ranges]
# If not found, return default
new_serials = [str(serial_equiv.get(s, s)) for s in serials]
conect_line = fmt_CONECT.format(*new_serials)
yield conect_line
continue

else:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_pdb_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ def test_default(self):

# Validate results
self.assertEqual(self.retcode, 0) # ensure the program exited OK.
self.assertEqual(len(self.stdout), 207)
# CONECTs are ignored by issue #72, expected only 205 lines
self.assertEqual(len(self.stdout), 205)
JoaoRodrigues marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(len(self.stderr), 0) # no errors

# Check if we added TER statements correctly
n_ter = len([r for r in self.stdout if r.startswith('TER')])
self.assertEqual(n_ter, 5)

# Check no CONECT in output
c_conect = sum(1 for i in self.stdout if i.startswith('CONECT'))
self.assertEqual(c_conect, 0)

# Check if we added END statements correctly
self.assertTrue(self.stdout[-1].startswith('END'))

Expand Down