Skip to content

Commit

Permalink
Merge pull request #189 from haddocking/refinement-sampling
Browse files Browse the repository at this point in the history
Add `sampling_factor` parameter to refinement modules
  • Loading branch information
rvhonorato committed Dec 8, 2021
2 parents ebac760 + f32e486 commit 4cb69b3
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 74 deletions.
1 change: 1 addition & 0 deletions examples/refine-complex/refine-complex.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ hise_1 = 15

[mdref]
noecv = false
sampling_factor = 10

[caprieval]
reference = 'data/e2a-hpr_1GGR.pdb'
Expand Down
62 changes: 39 additions & 23 deletions src/haddock/modules/refinement/emref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,49 @@ def _run(self):
self.finish_with_error(e)

refined_structure_list = []
for idx, model in enumerate(models_to_refine, start=1):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"emref",
ambig_fname=self.params["ambig_fname"],
)
out_file = Path(self.path, f"emref_{idx}.out")
idx = 1
sampling_factor = self.params["sampling_factor"]
if sampling_factor > 1:
self.log(f"sampling_factor={sampling_factor}")
if sampling_factor == 0:
self.log("[Warning] sampling_factor cannot be 0, setting it to 1")
sampling_factor = 1
if sampling_factor > 100:
self.log("[Warning] sampling_factor is larger than 100")

idx = 1
for model in models_to_refine:
for _ in range(self.params['sampling_factor']):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"emref",
ambig_fname=self.params["ambig_fname"],
)
out_file = Path(self.path, f"emref_{idx}.out")

# create the expected PDBobject
expected_pdb = prepare_expected_pdb(
model, idx, self.path, "emref"
)

# create the expected PDBobject
expected_pdb = prepare_expected_pdb(model, idx, self.path, "emref")
refined_structure_list.append(expected_pdb)

refined_structure_list.append(expected_pdb)
job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)

job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)
jobs.append(job)

jobs.append(job)
idx += 1

# Run CNS engine
self.log(f"Running CNS engine with {len(jobs)} jobs")
Expand Down
1 change: 1 addition & 0 deletions src/haddock/modules/refinement/emref/defaults.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log_level = "verbose"
sampling_factor = 1
ambig_fname = ""
unambig_fname = ""
hbond_fname = ""
Expand Down
66 changes: 40 additions & 26 deletions src/haddock/modules/refinement/flexref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,49 @@ def _run(self):
self.finish_with_error(e)

refined_structure_list = []
for idx, model in enumerate(models_to_refine, start=1):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"flexref",
ambig_fname=self.params["ambig_fname"],
)
idx = 1
sampling_factor = self.params["sampling_factor"]
if sampling_factor > 1:
self.log(f"sampling_factor={sampling_factor}")
if sampling_factor == 0:
self.log("[Warning] sampling_factor cannot be 0, setting it to 1")
sampling_factor = 1
if sampling_factor > 100:
self.log("[Warning] sampling_factor is larger than 100")

idx = 1
for model in models_to_refine:
for _ in range(self.params['sampling_factor']):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"flexref",
ambig_fname=self.params["ambig_fname"],
)

out_file = Path(self.path, f"flexref_{idx}.out")
out_file = Path(self.path, f"flexref_{idx}.out")

# create the expected PDBobject
expected_pdb = prepare_expected_pdb(
model, idx, self.path, "flexref"
)
refined_structure_list.append(expected_pdb)

job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)
# create the expected PDBobject
expected_pdb = prepare_expected_pdb(
model, idx, self.path, "flexref"
)
refined_structure_list.append(expected_pdb)

job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)

jobs.append(job)

jobs.append(job)
idx += 1

# Run CNS engine
self.log(f"Running CNS engine with {len(jobs)} jobs")
Expand Down
1 change: 1 addition & 0 deletions src/haddock/modules/refinement/flexref/defaults.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log_level = "verbose"
sampling_factor = 1
ambig_fname = ""
unambig_fname = ""
dihe_fname = ""
Expand Down
65 changes: 40 additions & 25 deletions src/haddock/modules/refinement/mdref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,47 @@ def _run(self):
self.finish_with_error(e)

refined_structure_list = []
for idx, model in enumerate(models_to_refine, start=1):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"mdref",
ambig_fname=self.params["ambig_fname"],
)
out_file = Path(self.path, f"mdref_{idx}.out")

# create the expected PDBobject
expected_pdb = prepare_expected_pdb(model, idx, self.path, "mdref")
refined_structure_list.append(expected_pdb)

job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)
idx = 1
sampling_factor = self.params["sampling_factor"]
if sampling_factor > 1:
self.log(f"sampling_factor={sampling_factor}")
if sampling_factor == 0:
self.log("[Warning] sampling_factor cannot be 0, setting it to 1")
sampling_factor = 1
if sampling_factor > 100:
self.log("[Warning] sampling_factor is larger than 100")

for model in models_to_refine:
for _ in range(self.params['sampling_factor']):
inp_file = prepare_cns_input(
idx,
model,
self.path,
self.recipe_str,
self.params,
"mdref",
ambig_fname=self.params["ambig_fname"],
)
out_file = Path(self.path, f"mdref_{idx}.out")

# create the expected PDBobject
expected_pdb = prepare_expected_pdb(
model, idx, self.path, "mdref"
)
refined_structure_list.append(expected_pdb)

job = CNSJob(
inp_file,
out_file,
cns_folder=self.cns_folder_path,
modpath=self.path,
config_path=self.params["config_path"],
cns_exec=self.params["cns_exec"],
)

jobs.append(job)

jobs.append(job)
idx += 1

# Run CNS engine
self.log(f"Running CNS engine with {len(jobs)} jobs")
Expand Down
1 change: 1 addition & 0 deletions src/haddock/modules/refinement/mdref/defaults.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log_level = "verbose"
sampling_factor = 1
ambig_fname = ""
unambig_fname = ""
hbond_fname = ""
Expand Down

0 comments on commit 4cb69b3

Please sign in to comment.