From 61e24ecb667a1636388c80977cae4853fcb6212e Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Fri, 21 Jan 2022 12:40:33 +0000 Subject: [PATCH 1/6] set sequence register for pdb in conkit-plot peval --- conkit/command_line/conkit_plot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conkit/command_line/conkit_plot.py b/conkit/command_line/conkit_plot.py index 40bdc951..a2d3d1e2 100644 --- a/conkit/command_line/conkit_plot.py +++ b/conkit/command_line/conkit_plot.py @@ -516,10 +516,12 @@ def altloc_remove(cmap): con.sort("raw_score", reverse=True, inplace=True) if args.pdbchain: - pdb = conkit.io.read(args.pdbfile, "pdb")[args.pdbchain] + pdb = conkit.io.read(args.pdbfile, args.pdbformat)[args.pdbchain] else: - pdb = conkit.io.read(args.pdbfile, "pdb")[0] + pdb = conkit.io.read(args.pdbfile, args.pdbformat)[0] + pdb.sequence = seq + pdb.set_sequence_register() pdb = pdb.as_contactmap() con_matched = con.match(pdb, renumber=True, remove_unmatched=True) From 66f0fa1000034d67a15d9c17629ce7de8d1889a4 Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Fri, 21 Jan 2022 12:40:58 +0000 Subject: [PATCH 2/6] set pdb sequence register conkit-precision --- conkit/command_line/conkit_precision.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/conkit/command_line/conkit_precision.py b/conkit/command_line/conkit_precision.py index c27b5484..cfa580d0 100644 --- a/conkit/command_line/conkit_precision.py +++ b/conkit/command_line/conkit_precision.py @@ -79,9 +79,14 @@ def main(): pdb = conkit.io.read(args.pdbfile, args.pdbformat)[args.pdbchain] else: pdb = conkit.io.read(args.pdbfile, args.pdbformat)[0] + seq = conkit.io.read(args.seqfile, args.seqformat)[0] - con = conkit.io.read(args.confile, args.conformat)[0] + pdb.sequence = seq + pdb.set_sequence_register() + pdb = pdb.as_contactmap() + + con = conkit.io.read(args.confile, args.conformat)[0] con.sequence = seq con.set_sequence_register() From c16357ca049326f01c7c18b5a486c77e61dc9a91 Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Fri, 21 Jan 2022 12:53:45 +0000 Subject: [PATCH 3/6] descriptive message for contactmap.set_sequence_register() --- conkit/core/contactmap.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conkit/core/contactmap.py b/conkit/core/contactmap.py index a83f62cb..95c92637 100644 --- a/conkit/core/contactmap.py +++ b/conkit/core/contactmap.py @@ -530,6 +530,8 @@ def set_sequence_register(self, altloc=False): if self.sequence is None: raise ValueError("No sequence defined") + seq_len = len(self.sequence) + for c in self: if altloc: res1_index = c.res1_altseq @@ -537,8 +539,11 @@ def set_sequence_register(self, altloc=False): else: res1_index = c.res1_seq res2_index = c.res2_seq - c.res1 = self.sequence.seq[res1_index - 1] - c.res2 = self.sequence.seq[res2_index - 1] + if res1_index <= seq_len or res2_index <= seq_len: + c.res1 = self.sequence.seq[res1_index - 1] + c.res2 = self.sequence.seq[res2_index - 1] + else: + raise ValueError('Contact {} is out of sequence bounds'.format(c.id)) @deprecate("0.11", msg="Use get_jaccard_index instead.") def calculate_jaccard_index(self, other): From 6d935cb5632c0ff447dafe69812d356f8de7f17e Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Fri, 21 Jan 2022 12:57:45 +0000 Subject: [PATCH 4/6] remove tests for py3.6 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 467eb039..2410cc51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v1 From 5fb31d03c3303faeb598c7b8d88a0c045af141df Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Sun, 23 Jan 2022 11:00:19 +0000 Subject: [PATCH 5/6] removed should never happen error messages --- conkit/command_line/conkit_predict.py | 2 +- conkit/core/contactmap.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conkit/command_line/conkit_predict.py b/conkit/command_line/conkit_predict.py index 39055eb6..1a8bd100 100644 --- a/conkit/command_line/conkit_predict.py +++ b/conkit/command_line/conkit_predict.py @@ -177,7 +177,7 @@ def main(argl=None): conkit.io.convert(a3m_fname, "a3m", jon_fname, "jones") else: - raise RuntimeError("Should never get to here") + raise RuntimeError("Error reading cli arguments - please report this bug") # CCMpred requires alignments to be in the *jones* format - i.e. the format created # and used by David Jones in PSICOV diff --git a/conkit/core/contactmap.py b/conkit/core/contactmap.py index 95c92637..48d41a9d 100644 --- a/conkit/core/contactmap.py +++ b/conkit/core/contactmap.py @@ -831,7 +831,7 @@ def match( else: contact_map1[_id].status = ContactMatchState.false_positive else: - raise RuntimeError("Error matching two contact maps - this should never happen") + raise RuntimeError("Error matching two contact maps - please report this bug") # ================================================================ # 3. Add false negatives @@ -1164,6 +1164,6 @@ def _renumber(contact_map, self_keymap, other_keymap): contact.res2_seq = other_residue.res_seq contact.res2_chain = other_residue.res_chain else: - raise ValueError("Should never get here") + raise ValueError("Error renumbering contact map - please report this bug") return contact_map From 05946f1b3873f41b5645162cde69c5b155c452c0 Mon Sep 17 00:00:00 2001 From: FilomenoSanchez Date: Sun, 23 Jan 2022 11:28:12 +0000 Subject: [PATCH 6/6] update set_sequence_register tests --- conkit/core/contactmap.py | 2 +- conkit/core/tests/test_contactmap.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/conkit/core/contactmap.py b/conkit/core/contactmap.py index 48d41a9d..0292ca4c 100644 --- a/conkit/core/contactmap.py +++ b/conkit/core/contactmap.py @@ -539,7 +539,7 @@ def set_sequence_register(self, altloc=False): else: res1_index = c.res1_seq res2_index = c.res2_seq - if res1_index <= seq_len or res2_index <= seq_len: + if res1_index <= seq_len and res2_index <= seq_len: c.res1 = self.sequence.seq[res1_index - 1] c.res2 = self.sequence.seq[res2_index - 1] else: diff --git a/conkit/core/tests/test_contactmap.py b/conkit/core/tests/test_contactmap.py index 49c3a5f0..ad93c470 100644 --- a/conkit/core/tests/test_contactmap.py +++ b/conkit/core/tests/test_contactmap.py @@ -432,6 +432,22 @@ def test_set_sequence_register_2(self): [("A", "E"), ("B", "F"), ("A", "D"), ("C", "F"), ("B", "E")], [(c.res1, c.res2) for c in contact_map1] ) + def test_set_sequence_register_3(self): + contact_map1 = ContactMap("1") + for comb in [(1, 5, 1.0), (2, 6, 1.0), (1, 4, 1.0), (3, 6, 1.0), (2, 5, 1.0)]: + contact_map1.add(Contact(*comb)) + contact_map1.sequence = Sequence("foo", "ABCDE") + with self.assertRaises(ValueError): + contact_map1.set_sequence_register() + + def test_set_sequence_register_4(self): + contact_map1 = ContactMap("1") + for comb in [(1, 5, 1.0), (6, 3, 1.0), (1, 4, 1.0), (3, 2, 1.0), (2, 5, 1.0)]: + contact_map1.add(Contact(*comb)) + contact_map1.sequence = Sequence("foo", "ABCDE") + with self.assertRaises(ValueError): + contact_map1.set_sequence_register() + def test_match_1(self): contact_map1 = ContactMap("foo") for params in [(1, 5, 1.0), (1, 6, 1.0), (2, 7, 1.0), (3, 5, 1.0), (2, 8, 1.0)]: