Skip to content

Commit

Permalink
Merge branch 'master' into combi_soaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tdudgeon committed Oct 22, 2024
2 parents 5a09200 + 830d3b7 commit 5f974f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
13 changes: 11 additions & 2 deletions DEV-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,17 @@ To roll out a new version of this:
9. `conda env create -f environment.yaml -p env_xchem_align` - create the new conda environment

NOTE: the repo MUST be tagged before rolling out to users. Step 3 does this and is assumed to be done by the
developers. If you want to roll out a new environment and the repo is not tagged (step 3) then the commands in step 3
must instead be performed after step 5 and before step 6.
developers. If you want to roll out a new environment and the repo is not tagged follow the instructions below

### Rollout if no tag is made yet

1. ssh to Diamond and move into the `/dls/science/groups/i04-1/software/xchem-align` dir
2. `git pull` - update the repo
3. `git tag` - check you have the expected tag
4. Tag the XCA repo and push the tag: `git tag 1.2.3` and `git push origin 1.2.3` (using the appropriate tag number)
5. `rm -rf env_xchem_align` - remove the old conda environment
6. `conda deactivate` - deactivate the current conda env (if necessary)
7. `conda env create -f environment.yaml -p env_xchem_align` - create the new conda environment

---

Expand Down
34 changes: 19 additions & 15 deletions src/xchemalign/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def path_to_relative_string(
return str(rel_path)
except AttributeError:
return path
except ValueError:
return path


def traverse_dictionary(dic, func):
Expand All @@ -98,6 +100,8 @@ def traverse_dictionary(dic, func):
traverse_dictionary(value, func)
except AttributeError:
dic[key] = func(value)
except ValueError:
dic[key] = func(value)


def _get_xmap_path_or_none(output_path, binding_event):
Expand Down Expand Up @@ -352,7 +356,7 @@ def _perform_alignments(self, meta):

# Get assemblies
if source_fs_model:
assemblies: dict[str, dt.Assembly] = _load_assemblies(source_fs_model.xtalforms, self.assemblies_file)
assemblies: dict[str, dt.Assembly] = _load_assemblies(self.base_dir / source_fs_model.xtalforms, self.assemblies_file)
else:
assemblies = _load_assemblies(fs_model.xtalforms, self.assemblies_file)
self.logger.info(f"Got {len(assemblies)} assemblies")
Expand All @@ -362,35 +366,35 @@ def _perform_alignments(self, meta):

# # Get xtalforms
if source_fs_model:
xtalforms: dict[str, dt.XtalForm] = _load_xtalforms(source_fs_model.xtalforms, self.assemblies_file)
xtalforms: dict[str, dt.XtalForm] = _load_xtalforms(self.base_dir / source_fs_model.xtalforms, self.assemblies_file)
else:
xtalforms = _load_xtalforms(fs_model.xtalforms, self.assemblies_file)
self.logger.info(f"Got {len(xtalforms)} xtalforms")

# Get the dataset assignments
if source_fs_model:
dataset_assignments = _load_dataset_assignments(Path(source_fs_model.dataset_assignments))
dataset_assignments = _load_dataset_assignments(Path(self.base_dir / source_fs_model.dataset_assignments))
else:
dataset_assignments = _load_dataset_assignments(Path(fs_model.dataset_assignments))

# Get Ligand neighbourhoods
if source_fs_model:
ligand_neighbourhoods: dict[tuple[str, str, str], dt.Neighbourhood] = _load_ligand_neighbourhoods(
source_fs_model.ligand_neighbourhoods
self.base_dir / source_fs_model.ligand_neighbourhoods
)
else:
ligand_neighbourhoods = _load_ligand_neighbourhoods(fs_model.ligand_neighbourhoods)
self.logger.info(f"Got {len(ligand_neighbourhoods)} ligand neighbourhoods")

# Get alignability graph
if source_fs_model:
alignability_graph = _load_alignability_graph(source_fs_model.alignability_graph)
alignability_graph = _load_alignability_graph(self.base_dir / source_fs_model.alignability_graph)
else:
alignability_graph = _load_alignability_graph(fs_model.alignability_graph)

# Get the connected components
if source_fs_model:
connected_components = _load_connected_components(source_fs_model.connected_components)
connected_components = _load_connected_components(self.base_dir / source_fs_model.connected_components)
else:
connected_components = _load_connected_components(fs_model.connected_components)

Expand All @@ -399,7 +403,7 @@ def _perform_alignments(self, meta):
print(f"Have source fs model at {source_fs_model.ligand_neighbourhood_transforms}!")
ligand_neighbourhood_transforms: dict[
tuple[tuple[str, str, str], tuple[str, str, str]], dt.Transform
] = _load_ligand_neighbourhood_transforms(source_fs_model.ligand_neighbourhood_transforms)
] = _load_ligand_neighbourhood_transforms(self.base_dir / source_fs_model.ligand_neighbourhood_transforms)
else:
ligand_neighbourhood_transforms = _load_ligand_neighbourhood_transforms(
fs_model.ligand_neighbourhood_transforms
Expand All @@ -408,42 +412,42 @@ def _perform_alignments(self, meta):

# Get conformer sites
if source_fs_model:
conformer_sites: dict[str, dt.ConformerSite] = _load_conformer_sites(source_fs_model.conformer_sites)
conformer_sites: dict[str, dt.ConformerSite] = _load_conformer_sites(self.base_dir / source_fs_model.conformer_sites)
else:
conformer_sites = _load_conformer_sites(fs_model.conformer_sites)

#
if source_fs_model:
conformer_site_transforms: dict[tuple[str, str], dt.Transform] = _load_conformer_site_transforms(
source_fs_model.conformer_site_transforms
self.base_dir / source_fs_model.conformer_site_transforms
)
else:
conformer_site_transforms = _load_conformer_site_transforms(fs_model.conformer_site_transforms)

# Get canonical sites
if source_fs_model:
canonical_sites: dict[str, dt.CanonicalSite] = _load_canonical_sites(source_fs_model.canonical_sites)
canonical_sites: dict[str, dt.CanonicalSite] = _load_canonical_sites(self.base_dir / source_fs_model.canonical_sites)
else:
canonical_sites = _load_canonical_sites(fs_model.canonical_sites)

#
if source_fs_model:
canonical_site_transforms: dict[str, dt.Transform] = _load_canonical_site_transforms(
source_fs_model.conformer_site_transforms
self.base_dir / source_fs_model.conformer_site_transforms
)
else:
canonical_site_transforms = _load_canonical_site_transforms(fs_model.conformer_site_transforms)

# Get xtalform sites
if source_fs_model:
xtalform_sites: dict[str, dt.XtalFormSite] = _load_xtalform_sites(source_fs_model.xtalform_sites)
xtalform_sites: dict[str, dt.XtalFormSite] = _load_xtalform_sites(self.base_dir / source_fs_model.xtalform_sites)
else:
xtalform_sites = _load_xtalform_sites(fs_model.xtalform_sites)

# Get reference structure transforms
if source_fs_model:
reference_structure_transforms: dict[tuple[str, str], dt.Transform] = _load_reference_stucture_transforms(
source_fs_model.reference_structure_transforms
self.base_dir / source_fs_model.reference_structure_transforms
)
else:
reference_structure_transforms = _load_reference_stucture_transforms(
Expand All @@ -456,13 +460,13 @@ 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(self.base_dir /working_fs_model.assembly_landmarks, ah.dict_to_assembly_landmarks)
else:
assembly_landmarks = {}

# Get the assembly transforms
if working_fs_model.assembly_transforms.exists():
assembly_transforms = ah.load_yaml(working_fs_model.assembly_transforms, lambda x: x)
assembly_transforms = ah.load_yaml(self.base_dir / working_fs_model.assembly_transforms, lambda x: x)
else:
assembly_transforms = {}

Expand Down

0 comments on commit 5f974f2

Please sign in to comment.