From 8ff280289a8473c203710124da9dc5d79f05ee9f Mon Sep 17 00:00:00 2001 From: Tim Dudgeon Date: Tue, 20 Aug 2024 15:37:50 +0100 Subject: [PATCH] don't allow to re-run aligner --- DEV-GUIDE.md | 9 ++++++--- src/xchemalign/aligner.py | 31 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/DEV-GUIDE.md b/DEV-GUIDE.md index 01438bf..693440a 100644 --- a/DEV-GUIDE.md +++ b/DEV-GUIDE.md @@ -12,16 +12,19 @@ This supersedes [Fragalysis-API](https://github.com/xchem/fragalysis-api). Project dependencies are defined in the `pyproject.toml` file. -You will need to use Python 3.10 or later (a requirement of the `pyproject.toml` file). +You will need to use Python 3.10 or 3.11 (a requirement of the `pyproject.toml` file). +Python 3.12 cannot currently be used. + If you prefer to use [conda] you can create a Python 3.10 environment using the -`environment.yaml` in this project, otherwise, if you have Python 3.10 or later, +`environment.yaml` in this project, otherwise, if you have Python 3.10 or 3.11, you can create an environment using the built-in `venv` module: - python -m venv venv source venv/bin/activate pip install --upgrade pip -Make sure you create the venv using Python 3.10 (or later). +Make sure you create the venv using Python 3.10 or 3.11 (e.g. change the first command to `python3.11 -m venv venv` +if needed). From your clean virtual environment you can now install the run-time and development dependencies like this: - diff --git a/src/xchemalign/aligner.py b/src/xchemalign/aligner.py index 1cba9bd..fe74dee 100644 --- a/src/xchemalign/aligner.py +++ b/src/xchemalign/aligner.py @@ -20,7 +20,6 @@ import gemmi from rich.traceback import install -install(show_locals=True) # Local alignment imports from ligand_neighbourhood_alignment import constants as lna_constants @@ -66,6 +65,8 @@ from xchemalign.utils import Constants from xchemalign.pdb_xtal import PDBXtal +install(show_locals=True) + def try_make(path): if not Path(path).exists(): @@ -215,6 +216,14 @@ def validate(self): elif not self.version_dir.is_dir(): self._log_error("version dir {} is not a directory".format(self.version_dir)) else: + output_meta_path = self.version_dir / Constants.METADATA_ALIGN_FILENAME + if output_meta_path.exists(): + self._log_error( + "aligner output {} already exists. You must run aligner on clean output from collator.".format( + str(output_meta_path) + ) + ) + p = self.metadata_file if not p.exists(): self._log_error("metadata file {} does not exist. Did the collator step run successfully?".format(p)) @@ -447,23 +456,16 @@ def _perform_alignments(self, meta): working_fs_model = fs_model if working_fs_model.assembly_landmarks.exists(): - assembly_landmarks = ah.load_yaml( - working_fs_model.assembly_landmarks, - ah.dict_to_assembly_landmarks - ) + assembly_landmarks = ah.load_yaml(working_fs_model.assembly_landmarks, ah.dict_to_assembly_landmarks) else: assembly_landmarks = {} # Get the assembly transforms if working_fs_model.assembly_landmarks.exists(): - assembly_transforms = ah.load_yaml( - working_fs_model.assembly_landmarks, - lambda x: x - ) + assembly_transforms = ah.load_yaml(working_fs_model.assembly_landmarks, lambda x: x) else: assembly_transforms = {} - # Run the update updated_fs_model = _update( fs_model, @@ -485,7 +487,6 @@ def _perform_alignments(self, meta): assembly_landmarks, assembly_transforms, self.version_dir.name[7:], - ) # Update the metadata_file with aligned file locations and site information @@ -650,9 +651,13 @@ def _perform_alignments(self, meta): aligned_xmap_path = version_output.aligned_xmaps[site_id] aligned_diff_map_path = version_output.aligned_diff_maps[site_id] - aligned_crystallographic_event_map_path = version_output.aligned_event_maps_crystallographic[site_id] + aligned_crystallographic_event_map_path = ( + version_output.aligned_event_maps_crystallographic[site_id] + ) aligned_crystallographic_xmap_path = version_output.aligned_xmaps_crystallographic[site_id] - aligned_crystallographic_diff_map_path = version_output.aligned_diff_maps_crystallographic[site_id] + aligned_crystallographic_diff_map_path = version_output.aligned_diff_maps_crystallographic[ + site_id + ] aligned_version_output[site_id] = { Constants.META_AIGNED_STRUCTURE: aligned_structure_path,