Skip to content

Commit

Permalink
residues in ss msg more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCox822 committed Aug 6, 2024
1 parent 6cbf844 commit b1ed791
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 52 deletions.
26 changes: 13 additions & 13 deletions mdagent/tools/base_tools/analysis_tools/secondary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ def _dssp_natural_language(self) -> dict[str, str]:
used. Otherwise, the full set of codes is used."""
if self.simplified:
return {
"H": "helix",
"E": "strand",
"C": "coil",
"NA": "not assigned, not a protein residue",
"H": "residues in helix",
"E": "residues in strand",
"C": "residues in coil",
"NA": "residues not assigned, not a protein residue",
}
return {
"H": "alpha helix",
"B": "beta bridge",
"E": "extended strand",
"G": "three helix",
"I": "five helix",
"T": "hydrogen bonded turn",
"S": "bend",
" ": "loop or irregular",
"NA": "not assigned, not a protein residue",
"H": "residues in alpha helix",
"B": "residues in beta bridge",
"E": "residues in extended strand",
"G": "residues in three helix",
"I": "residues in five helix",
"T": "residues in hydrogen bonded turn",
"S": "residues in bend",
" ": "residues in loop or irregular",
"NA": "residues not assigned, not a protein residue",
}

def _convert_dssp_counts(self, dssp_counts: dict) -> dict:
Expand Down
76 changes: 37 additions & 39 deletions tests/test_analysis/test_secondary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ def compute_dssp_simple(get_registry):
registry = get_registry("raw", True)
return ComputeDSSP(path_registry=registry, simplified=True)


@pytest.fixture
def compute_dssp(get_registry):
registry = get_registry("raw", True)
return ComputeDSSP(path_registry=registry, simplified=False)


def test_compute_dssp(loaded_cif_traj, compute_dssp_simple, compute_dssp):
dssp_simple = compute_dssp_simple._compute_dssp(loaded_cif_traj)
assert dssp_simple.shape[1] == 374
Expand All @@ -43,26 +41,26 @@ def test_dssp_codes(compute_dssp_simple, compute_dssp):

nl_simple = compute_dssp_simple._dssp_natural_language()
assert nl_simple == {
"H": "helix",
"E": "strand",
"C": "coil",
"NA": "not assigned, not a protein residue",
"H": "residues in helix",
"E": "residues in strand",
"C": "residues in coil",
"NA": "residues not assigned, not a protein residue",
}

dssp_codes = compute_dssp._dssp_codes()
assert dssp_codes == ["H", "B", "E", "G", "I", "T", "S", " ", "NA"]

nl = compute_dssp._dssp_natural_language()
assert nl == {
"H": "alpha helix",
"B": "beta bridge",
"E": "extended strand",
"G": "three helix",
"I": "five helix",
"T": "hydrogen bonded turn",
"S": "bend",
" ": "loop or irregular",
"NA": "not assigned, not a protein residue",
"H": "residues in alpha helix",
"B": "residues in beta bridge",
"E": "residues in extended strand",
"G": "residues in three helix",
"I": "residues in five helix",
"T": "residues in hydrogen bonded turn",
"S": "residues in bend",
" ": "residues in loop or irregular",
"NA": "residues not assigned, not a protein residue",
}


Expand All @@ -71,49 +69,49 @@ def test_convert_dssp_counts(compute_dssp_simple, compute_dssp):

descriptive_counts = compute_dssp_simple._convert_dssp_counts(dssp_counts)
assert descriptive_counts == {
"helix": 0,
"strand": 5,
"coil": 5,
"residues in helix": 0,
"residues in strand": 5,
"residues in coil": 5,
}

dssp_counts = {"H": 0, "B": 0, "E": 5, "G": 0, "I": 0, "T": 0, "S": 0, " ": 5}

descriptive_counts = compute_dssp._convert_dssp_counts(dssp_counts)

assert descriptive_counts == {
"alpha helix": 0,
"beta bridge": 0,
"extended strand": 5,
"three helix": 0,
"five helix": 0,
"hydrogen bonded turn": 0,
"bend": 0,
"loop or irregular": 5,
"residues in alpha helix": 0,
"residues in beta bridge": 0,
"residues in extended strand": 5,
"residues in three helix": 0,
"residues in five helix": 0,
"residues in hydrogen bonded turn": 0,
"residues in bend": 0,
"residues in loop or irregular": 5,
}


def test_summarize_dssp(compute_dssp_simple, compute_dssp):
dssp_array = np.array([["C", "C", "C", "E", "E", "E", "C", "C", "E", "E"]])
summary = compute_dssp_simple._summarize_dssp(dssp_array)
assert summary == {
"helix": 0,
"strand": 5,
"coil": 5,
"not assigned, not a protein residue": 0,
"residues in helix": 0,
"residues in strand": 5,
"residues in coil": 5,
"residues not assigned, not a protein residue": 0,
}

dssp_array = np.array([[" ", " ", " ", "E", "E", "E", "T", "T", "E", "E"]])
summary = compute_dssp._summarize_dssp(dssp_array)
assert summary == {
"alpha helix": 0,
"beta bridge": 0,
"extended strand": 5,
"three helix": 0,
"five helix": 0,
"hydrogen bonded turn": 2,
"bend": 0,
"loop or irregular": 3,
"not assigned, not a protein residue": 0,
"residues in alpha helix": 0,
"residues in beta bridge": 0,
"residues in extended strand": 5,
"residues in three helix": 0,
"residues in five helix": 0,
"residues in hydrogen bonded turn": 2,
"residues in bend": 0,
"residues in loop or irregular": 3,
"residues not assigned, not a protein residue": 0,
}


Expand Down

0 comments on commit b1ed791

Please sign in to comment.