Skip to content

Commit

Permalink
don't allow to re-run aligner
Browse files Browse the repository at this point in the history
  • Loading branch information
tdudgeon committed Aug 20, 2024
1 parent 283f665 commit 8ff2802
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
9 changes: 6 additions & 3 deletions DEV-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: -
Expand Down
31 changes: 18 additions & 13 deletions src/xchemalign/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8ff2802

Please sign in to comment.