Skip to content

Commit 1482d85

Browse files
authored
Merge pull request #780 from haddocking/fix_prot_segid
Fix prot segid
2 parents 4dad36f + a1a5011 commit 1482d85

File tree

6 files changed

+14
-46
lines changed

6 files changed

+14
-46
lines changed

examples/run_tests.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ def main(examples, break_on_errors=True):
153153
stderr=sys.stderr,
154154
)
155155

156-
subprocess.run(
157-
"haddock3 docking-protein-protein-test-start-from-cp.cfg --extend-run run2", # noqa: E501
158-
shell=True,
159-
check=break_on_errors,
160-
stdout=sys.stdout,
161-
stderr=sys.stderr,
162-
)
163-
164156
# test exit with extend-run
165157
rmtree("run2", ignore_errors=True)
166158
subprocess.run(

src/haddock/gear/prepare_run.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,22 +1043,8 @@ def populate_topology_molecule_params(topoaa: ParamMap) -> None:
10431043
"""Populate topoaa `molX` subdictionaries."""
10441044
topoaa_dft = _read_defaults("topoaa.1")
10451045

1046-
# list of possible prot_segids
1047-
uppers = list(string.ascii_uppercase)[::-1]
1048-
1049-
# removes from the list those prot_segids that are already defined
1050-
for param in topoaa:
1051-
if param.startswith("mol") and param[3:].isdigit():
1052-
with suppress(KeyError):
1053-
uppers.remove(topoaa[param]["prot_segid"])
1054-
1055-
# populates the prot_segids just for those that were not defined
1056-
# in the user configuration file. Other parameters are populated as
1057-
# well. `prot_segid` is the only one differing per molecule.
10581046
for i in range(1, len(topoaa["molecules"]) + 1):
10591047
mol = f"mol{i}"
1060-
if not (mol in topoaa and "prot_segid" in topoaa[mol]):
1061-
topoaa_dft["mol1"]["prot_segid"] = uppers.pop()
10621048

10631049
topoaa[mol] = recursive_dict_update(
10641050
topoaa_dft["mol1"],

src/haddock/libs/libcns.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ def prepare_cns_input(
330330
libpdb.identify_chainseg(pdb.rel_path, sort=False)
331331

332332
chainsegs = sorted(list(set(segids) | set(chains)))
333+
# check if any of chainsegs is already in chainid_list
334+
if not identifier.endswith("scoring"):
335+
if any(chainseg in chainid_list for chainseg in chainsegs):
336+
raise ValueError(
337+
f"Chain/seg IDs are not unique for pdbs {input_element}."
338+
)
333339
chainid_list.extend(chainsegs)
334340

335341
for i, _chainseg in enumerate(chainid_list, start=1):

src/haddock/libs/libpdb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ def identify_chainseg(pdb_file_path: FilePath,
218218
segids.append(segid)
219219
if chainid:
220220
chains.append(chainid)
221+
222+
if not segid and not chainid:
223+
raise ValueError(
224+
f"Could not identify chainID or segID in pdb {pdb_file_path}, line {line}"
225+
)
221226

222227
if sort:
223228
segids = sorted(list(set(segids)))

src/haddock/modules/topology/topoaa/defaults.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ tolerance:
8787
group: module
8888
explevel: expert
8989
mol1:
90-
prot_segid:
91-
default: A
92-
type: string
93-
minchars: 0
94-
maxchars: 4
95-
title: Segment ID
96-
short: Segment ID assigned to this molecule
97-
long: Segment ID assigned to this molecule in CNS. Used to distinguish different molecules
98-
group: molecule
99-
explevel: easy
10090
cyclicpept:
10191
default: false
10292
type: boolean

tests/test_gear_prepare_run.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def test_populate_topoaa_molecules():
5656
}
5757
populate_topology_molecule_params(topoaa)
5858
assert "mol2" in topoaa
59-
assert topoaa["mol2"]["prot_segid"] == "B"
60-
assert topoaa["mol1"]["prot_segid"] == "A"
6159
assert topoaa["mol2"]["cyclicpept"] is False
6260
assert topoaa["mol1"]["cyclicpept"] is True
6361
assert isnan(topoaa["mol2"]["hisd_1"])
@@ -74,12 +72,10 @@ def test_populate_topoaa_molecules_2():
7472
"""Test mols are polated."""
7573
topoaa = {
7674
"molecules": ["file1.pdb", "file2.pdb"],
77-
"mol2": {"cyclicpept": True, "prot_segid": "D"},
75+
"mol2": {"cyclicpept": True},
7876
}
7977
populate_topology_molecule_params(topoaa)
8078
assert "mol1" in topoaa
81-
assert topoaa["mol1"]["prot_segid"] == "A"
82-
assert topoaa["mol2"]["prot_segid"] == "D"
8379

8480
assert topoaa["mol1"]["cyclicpept"] is False
8581
assert topoaa["mol2"]["cyclicpept"] is True
@@ -99,27 +95,20 @@ def test_populate_topoaa_molecules_3():
9995
"""Test mols are polated."""
10096
topoaa = {
10197
"molecules": ["file1.pdb", "file2.pdb", "file3.pdb"],
102-
"mol2": {"cyclicpept": True, "prot_segid": "C"},
98+
"mol2": {"cyclicpept": True},
10399
}
104100
populate_topology_molecule_params(topoaa)
105101
assert "mol1" in topoaa
106-
assert topoaa["mol1"]["prot_segid"] == "A"
107-
assert topoaa["mol2"]["prot_segid"] == "C"
108-
assert topoaa["mol3"]["prot_segid"] == "B"
109102

110103

111104
def test_populate_topoaa_molecules_4():
112105
"""Test mols are polated with prot_segid sequence."""
113106
topoaa = {
114107
"molecules": ["file1.pdb", "file2.pdb", "file3.pdb", "file4.pdb"],
115-
"mol3": {"cyclicpept": True, "prot_segid": "A"},
108+
"mol3": {"cyclicpept": True},
116109
}
117110
populate_topology_molecule_params(topoaa)
118111
assert "mol1" in topoaa
119-
assert topoaa["mol1"]["prot_segid"] == "B"
120-
assert topoaa["mol2"]["prot_segid"] == "C"
121-
assert topoaa["mol3"]["prot_segid"] == "A"
122-
assert topoaa["mol4"]["prot_segid"] == "D"
123112

124113

125114
def test_populate_mol_params():

0 commit comments

Comments
 (0)