Skip to content

Commit

Permalink
Merge branch 'master' into windows_issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pckroon authored Mar 7, 2024
2 parents 53f13e9 + b1fd08c commit 0cd9bd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vermouth/dssp/dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,15 @@ def convert_dssp_to_martini(sequence):
cg_sequence = ''.join(ss_cg[secstruct] for secstruct in sequence)
wildcard_sequence = ''.join('H' if secstruct == 'H' else '.'
for secstruct in cg_sequence)
# Flank the sequence with dots. Otherwise in a sequence consisting of only
# H will not have a start or end. See also issue 566.
# This should not cause further issues, since '..' doesn't map to anything
wildcard_sequence = '.' + wildcard_sequence + '.'
for pattern, replacement in patterns.items():
wildcard_sequence = wildcard_sequence.replace(pattern, replacement)
while pattern in wildcard_sequence: # EXPENSIVE! :'(
wildcard_sequence = wildcard_sequence.replace(pattern, replacement)
# And remove the flanking dots again
wildcard_sequence = wildcard_sequence[1:-1]
result = ''.join(
wildcard if wildcard != '.' else cg
for wildcard, cg in zip(wildcard_sequence, cg_sequence)
Expand Down
15 changes: 15 additions & 0 deletions vermouth/tests/test_dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,18 @@ def test_cterm_atomnames():
vermouth.processors.CanonicalizeModifications().run_system(system)
dssp_out = dssp.run_dssp(system, executable=DSSP_EXECUTABLE)
assert dssp_out == list("CC")


@pytest.mark.parametrize('sequence, expected', [
('H', '3'),
('HH', '33'),
('CHH', 'C33'),
('HHHHHH', '113322'),
('EHHHHHHC', 'E113322C'),
('HHHHHHHHH', '1111H2222'),
('CHHHHHHHHHC', 'C1111H2222C'),
('CHHHHEHHHHC', 'C3333E3333C'),
])
def test_convert_dssp_to_martini(sequence, expected):
found = dssp.convert_dssp_to_martini(sequence)
assert expected == found

0 comments on commit 0cd9bd0

Please sign in to comment.