Skip to content

Commit 06a94be

Browse files
Merge pull request #99 from FilomenoSanchez/master
Set PDB sequence register at conkit-plot peval and conkit-precision
2 parents fdc926e + 05946f1 commit 06a94be

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
python-version: [3.6, 3.7, 3.8, 3.9]
18+
python-version: [3.7, 3.8, 3.9]
1919

2020
steps:
2121
- uses: actions/checkout@v1

conkit/command_line/conkit_plot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,12 @@ def altloc_remove(cmap):
516516
con.sort("raw_score", reverse=True, inplace=True)
517517

518518
if args.pdbchain:
519-
pdb = conkit.io.read(args.pdbfile, "pdb")[args.pdbchain]
519+
pdb = conkit.io.read(args.pdbfile, args.pdbformat)[args.pdbchain]
520520
else:
521-
pdb = conkit.io.read(args.pdbfile, "pdb")[0]
521+
pdb = conkit.io.read(args.pdbfile, args.pdbformat)[0]
522522

523+
pdb.sequence = seq
524+
pdb.set_sequence_register()
523525
pdb = pdb.as_contactmap()
524526
con_matched = con.match(pdb, renumber=True, remove_unmatched=True)
525527

conkit/command_line/conkit_precision.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ def main():
7979
pdb = conkit.io.read(args.pdbfile, args.pdbformat)[args.pdbchain]
8080
else:
8181
pdb = conkit.io.read(args.pdbfile, args.pdbformat)[0]
82+
8283
seq = conkit.io.read(args.seqfile, args.seqformat)[0]
83-
con = conkit.io.read(args.confile, args.conformat)[0]
8484

85+
pdb.sequence = seq
86+
pdb.set_sequence_register()
87+
pdb = pdb.as_contactmap()
88+
89+
con = conkit.io.read(args.confile, args.conformat)[0]
8590
con.sequence = seq
8691
con.set_sequence_register()
8792

conkit/command_line/conkit_predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def main(argl=None):
177177
conkit.io.convert(a3m_fname, "a3m", jon_fname, "jones")
178178

179179
else:
180-
raise RuntimeError("Should never get to here")
180+
raise RuntimeError("Error reading cli arguments - please report this bug")
181181

182182
# CCMpred requires alignments to be in the *jones* format - i.e. the format created
183183
# and used by David Jones in PSICOV

conkit/core/contactmap.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,20 @@ def set_sequence_register(self, altloc=False):
530530
if self.sequence is None:
531531
raise ValueError("No sequence defined")
532532

533+
seq_len = len(self.sequence)
534+
533535
for c in self:
534536
if altloc:
535537
res1_index = c.res1_altseq
536538
res2_index = c.res2_altseq
537539
else:
538540
res1_index = c.res1_seq
539541
res2_index = c.res2_seq
540-
c.res1 = self.sequence.seq[res1_index - 1]
541-
c.res2 = self.sequence.seq[res2_index - 1]
542+
if res1_index <= seq_len and res2_index <= seq_len:
543+
c.res1 = self.sequence.seq[res1_index - 1]
544+
c.res2 = self.sequence.seq[res2_index - 1]
545+
else:
546+
raise ValueError('Contact {} is out of sequence bounds'.format(c.id))
542547

543548
@deprecate("0.11", msg="Use get_jaccard_index instead.")
544549
def calculate_jaccard_index(self, other):
@@ -826,7 +831,7 @@ def match(
826831
else:
827832
contact_map1[_id].status = ContactMatchState.false_positive
828833
else:
829-
raise RuntimeError("Error matching two contact maps - this should never happen")
834+
raise RuntimeError("Error matching two contact maps - please report this bug")
830835

831836
# ================================================================
832837
# 3. Add false negatives
@@ -1159,6 +1164,6 @@ def _renumber(contact_map, self_keymap, other_keymap):
11591164
contact.res2_seq = other_residue.res_seq
11601165
contact.res2_chain = other_residue.res_chain
11611166
else:
1162-
raise ValueError("Should never get here")
1167+
raise ValueError("Error renumbering contact map - please report this bug")
11631168

11641169
return contact_map

conkit/core/tests/test_contactmap.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,22 @@ def test_set_sequence_register_2(self):
432432
[("A", "E"), ("B", "F"), ("A", "D"), ("C", "F"), ("B", "E")], [(c.res1, c.res2) for c in contact_map1]
433433
)
434434

435+
def test_set_sequence_register_3(self):
436+
contact_map1 = ContactMap("1")
437+
for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]:
438+
contact_map1.add(Contact(*comb))
439+
contact_map1.sequence = Sequence("foo", "ABCDE")
440+
with self.assertRaises(ValueError):
441+
contact_map1.set_sequence_register()
442+
443+
def test_set_sequence_register_4(self):
444+
contact_map1 = ContactMap("1")
445+
for comb in [(1, 5, 1.0), (6, 3, 1.0), (1, 4, 1.0), (3, 2, 1.0), (2, 5, 1.0)]:
446+
contact_map1.add(Contact(*comb))
447+
contact_map1.sequence = Sequence("foo", "ABCDE")
448+
with self.assertRaises(ValueError):
449+
contact_map1.set_sequence_register()
450+
435451
def test_match_1(self):
436452
contact_map1 = ContactMap("foo")
437453
for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]:

0 commit comments

Comments
 (0)