Skip to content

Commit

Permalink
add test case if idr regions but no secstruct.
Browse files Browse the repository at this point in the history
- need to modify create_sys_all_attrs so cgsecstruct not always written
- remove duplicate annotation in annotate_idrs.py
  • Loading branch information
csbrasnett committed Jan 29, 2025
1 parent cddf4eb commit c5df2ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion vermouth/processors/annotate_idrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def annotate_disorder(molecule, id_regions, annotation="cgidr"):
molecule.nodes[key][annotation] = True
if "cgsecstruct" in molecule.nodes[key]:
molecule.nodes[key]["cgsecstruct"] = "C"
molecule.nodes[key][annotation] = True # ???
else:
molecule.nodes[key][annotation] = False

Expand Down
5 changes: 3 additions & 2 deletions vermouth/tests/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_in_path(names=('martinize2', 'martinize2.py')):
if os.path.isfile(fullpath):
return fullpath

def create_sys_all_attrs(molecule, moltype, secstruc, defaults, attrs):
def create_sys_all_attrs(molecule, moltype, secstruc, defaults, attrs, write_secstruct=True):
"""
Generate a test system from a molecule
with all attributes set and blocks in
Expand Down Expand Up @@ -138,7 +138,8 @@ def create_sys_all_attrs(molecule, moltype, secstruc, defaults, attrs):
resid = res_graph.nodes[node]['resid']
# assign secondary structure
for mol_node in mol_nodes:
molecule.nodes[mol_node]['cgsecstruct'] = secstruc[resid]
if write_secstruct:
molecule.nodes[mol_node]['cgsecstruct'] = secstruc[resid]
block.add_node(molecule.nodes[mol_node]['atomname'],
atype=molecule.nodes[mol_node]['atype'])

Expand Down
22 changes: 13 additions & 9 deletions vermouth/tests/test_annotate_idrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,28 @@ def test_make_disorder_string(test_molecule,
result.append(False)
assert result == expected

@pytest.mark.parametrize('idr_regions, expected',(
@pytest.mark.parametrize('idr_regions, write_sec, expected',(
([(1, 4)],
True,
{0: "C", 1: "C", 2: "C",
3: "C", 4: "C",
5: "C",
6: "C", 7: "C", 8: "C"}),
([(1, 2)],
True,
{0: "C", 1: "C", 2: "C",
3: "C", 4: "C",
5: "H",
6: "H", 7: "H", 8: "H"}),
([(1, 2)],
False,
{0: None, 1: None, 2: None,
3: None, 4: None,
5: None,
6: None, 7: None, 8: None})
))
def test_ss_reassign(test_molecule, idr_regions, expected):
def test_ss_reassign(test_molecule, idr_regions, write_sec, expected):
secstruc = {1: "H", 2: "H", 3: "H", 4: "H"}
resnames = {0: "A", 1: "A", 2: "A",
3: "B", 4: "B",
Expand All @@ -82,20 +90,16 @@ def test_ss_reassign(test_molecule, idr_regions, expected):
3: "SP1", 4: "C1",
5: "TP1",
6: "P1", 7: "SN3a", 8: "SP4"}
cgsectruc = {0: "H", 1: "H", 2: "H",
3: "H", 4: "H",
5: "H",
6: "H", 7: "H", 8: "H"} # i.e. all ss is H to begin

system = create_sys_all_attrs(test_molecule,
moltype="molecule_0",
secstruc=secstruc,
defaults={"chain": "A"},
attrs={"resname": resnames,
"atype": atypes,
"cgsecstruct": cgsectruc})
"atype": atypes},
write_secstruct=write_sec)

AnnotateIDRs(id_regions=idr_regions).run_system(system)

for key, node in system.molecules[0].nodes.items():
assert system.molecules[0].nodes[key]["cgsecstruct"] == expected[key]
assert system.molecules[0].nodes[key].get("cgsecstruct", None) == expected[key]

0 comments on commit c5df2ee

Please sign in to comment.