From b1ed79120be850557e23634ab15b5e618c49889d Mon Sep 17 00:00:00 2001 From: Samantha Cox Date: Mon, 5 Aug 2024 22:42:05 -0700 Subject: [PATCH] residues in ss msg more accurate --- .../analysis_tools/secondary_structure.py | 26 +++---- .../test_analysis/test_secondary_structure.py | 76 +++++++++---------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/mdagent/tools/base_tools/analysis_tools/secondary_structure.py b/mdagent/tools/base_tools/analysis_tools/secondary_structure.py index 8503972b..64c312e6 100644 --- a/mdagent/tools/base_tools/analysis_tools/secondary_structure.py +++ b/mdagent/tools/base_tools/analysis_tools/secondary_structure.py @@ -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: diff --git a/tests/test_analysis/test_secondary_structure.py b/tests/test_analysis/test_secondary_structure.py index 9fe304ca..dc829f0f 100644 --- a/tests/test_analysis/test_secondary_structure.py +++ b/tests/test_analysis/test_secondary_structure.py @@ -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 @@ -43,10 +41,10 @@ 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() @@ -54,15 +52,15 @@ def test_dssp_codes(compute_dssp_simple, compute_dssp): 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", } @@ -71,9 +69,9 @@ 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} @@ -81,14 +79,14 @@ def test_convert_dssp_counts(compute_dssp_simple, compute_dssp): 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, } @@ -96,24 +94,24 @@ 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, }