Skip to content

Commit

Permalink
Merge version 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsbond committed Jun 1, 2022
2 parents 2196ce7 + c3a9281 commit aa7450b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org).

## [2.4.0] - 2022-06-01

### Changed

- Comparing per-cycle outputs using R-work instead of R-free

### Fixed

- Nautilus test that was looking for a space in a residue name

## [2.3.6] - 2022-05-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion modelcraft/__init__.py
@@ -1,4 +1,4 @@
__version__ = "2.3.6"
__version__ = "2.4.0"

from .cell import max_distortion as max_cell_distortion
from .cell import remove_scale
Expand Down
43 changes: 20 additions & 23 deletions modelcraft/modelcraft.py
Expand Up @@ -60,7 +60,7 @@ def run(self):
for self.cycle in range(1, args.cycles + 1):
print("\n## Cycle %d\n" % self.cycle)
self.run_cycle()
self.process_cycle_output()
self.process_cycle_output(self.last_refmac)
if (
self.cycles_without_improvement == args.auto_stop_cycles
and args.auto_stop_cycles > 0
Expand All @@ -76,7 +76,7 @@ def run(self):
self.cycle += 1
self.update_current_from_refmac_result(self.output_refmac)
self.fixsidechains()
self.process_cycle_output()
self.process_cycle_output(self.last_refmac)
print("\n## Best Model:")
self.print_refmac_result(self.output_refmac)
self.terminate(reason="Normal")
Expand Down Expand Up @@ -204,20 +204,13 @@ def refmac(self, structure: gemmi.Structure, cycles: int, auto_accept: bool):
cycles=cycles,
).run(self)
self._finished_job("Refmac", result)
if auto_accept or self._is_better(result, self.last_refmac):
if auto_accept or result.rfree < self.last_refmac.rfree:
if not auto_accept:
print("(accepted)")
self.update_current_from_refmac_result(result)
else:
print("(rejected)")

def _is_better(self, new_result: RefmacResult, old_result: RefmacResult):
return (
old_result is None
or (self.args.mode == "xray" and new_result.rfree < old_result.rfree)
or (self.args.mode == "em" and new_result.fsc > old_result.fsc)
)

def update_current_from_refmac_result(self, result: RefmacResult):
self.current_structure = result.structure
self.current_phases = result.abcd
Expand Down Expand Up @@ -283,30 +276,34 @@ def findwaters(self, dummy=False):
self._finished_job(name, result)
self.refmac(result.structure, cycles=10, auto_accept=False)

def process_cycle_output(self):
self.print_refmac_result(self.last_refmac)
model_stats = ModelStats(self.last_refmac.structure)
def process_cycle_output(self, result: RefmacResult):
self.print_refmac_result(result)
model_stats = ModelStats(result.structure)
stats = {"cycle": self.cycle, "residues": model_stats.residues}
if self.args.mode == "xray":
stats["waters"] = model_stats.waters
stats["r_work"] = self.last_refmac.rwork
stats["r_free"] = self.last_refmac.rfree
stats["r_work"] = result.rwork
stats["r_free"] = result.rfree
if self.args.mode == "em":
stats["fsc"] = self.last_refmac.fsc
stats["fsc"] = result.fsc
self.report["cycles"].append(stats)
if self._is_better(self.last_refmac, self.output_refmac):
if (
self.output_refmac is None
or (self.args.mode == "xray" and result.rwork < self.output_refmac.rwork)
or (self.args.mode == "em" and result.fsc > self.output_refmac.fsc)
):
self.cycles_without_improvement = 0
self.output_refmac = self.last_refmac
write_mmcif(self.path("modelcraft.cif"), self.last_refmac.structure)
self.output_refmac = result
write_mmcif(self.path("modelcraft.cif"), result.structure)
write_mtz(
self.path("modelcraft.mtz"),
[
self.args.fmean,
self.args.freer,
self.last_refmac.abcd,
self.last_refmac.fphi_best,
self.last_refmac.fphi_diff,
self.last_refmac.fphi_calc,
result.abcd,
result.fphi_best,
result.fphi_diff,
result.fphi_calc,
],
)
self.report["final"] = stats
Expand Down
2 changes: 1 addition & 1 deletion modelcraft/tests/integration/test_nautilus.py
Expand Up @@ -50,7 +50,7 @@ def test_102d():
structure=structure,
).run(pipeline)
stats = ModelStats(nautilus.structure)
assert contains_residue(nautilus.structure, " DT")
assert contains_residue(nautilus.structure, "DT")
assert stats.residues > 22
assert nautilus.fragments_built == 2
assert nautilus.residues_built > 22
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="modelcraft",
version="2.3.6",
version="2.4.0",
author="Paul Bond",
author_email="paul.bond@york.ac.uk",
description="Automated model building pipeline for X-ray crystallography",
Expand Down

0 comments on commit aa7450b

Please sign in to comment.