Skip to content

Set PDB sequence register at conkit-plot peval and conkit-precision #99

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

Merged
merged 7 commits into from
Jan 23, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions conkit/command_line/conkit_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion conkit/command_line/conkit_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion conkit/command_line/conkit_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions conkit/core/contactmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,20 @@ 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
res2_index = c.res2_altseq
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 and 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):
Expand Down Expand Up @@ -826,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
Expand Down Expand Up @@ -1159,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
16 changes: 16 additions & 0 deletions conkit/core/tests/test_contactmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]:
Expand Down