Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for phenix 1.21 #53

Merged
merged 22 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
81f9979
update _validate_environment to return a phenix version string
dennisbrookner May 21, 2024
0fdb1b0
start slogging through adding a phenix_version parameter for refinement
dennisbrookner May 21, 2024
f73d003
add argument for phenix_version
dennisbrookner May 28, 2024
593f648
Add preliminary phenix 1.21 support for main matchmaps utility
dennisbrookner May 28, 2024
9723c32
refactor rbr wrapper more elegantly
dennisbrookner May 29, 2024
998d963
add PyCharm files to gitignore
dennisbrookner May 29, 2024
1c2181c
PyCharm files removed
dennisbrookner May 29, 2024
e6f62f6
latest update to phenix utils
dennisbrookner May 29, 2024
4b88fca
remove extra parameter from phaser wrapper
dennisbrookner May 29, 2024
1fbbf19
update phenix refine
dennisbrookner May 29, 2024
e970d94
matchmaps.mr pays attention to phenix version
dennisbrookner May 29, 2024
be17f87
invert if condition
dennisbrookner May 29, 2024
4181a1b
parse phenix version
dennisbrookner May 29, 2024
e07eae4
preliminary phenix 1.21 support for matchmaps.mr
dennisbrookner May 29, 2024
70796c7
properly exclude pycharm files
dennisbrookner May 29, 2024
2144c2a
gitignore nonsense
dennisbrookner May 29, 2024
236c2a1
trick github into deleting pycharm files
dennisbrookner May 29, 2024
1277ae1
gitignore nonsense
dennisbrookner May 29, 2024
d3d9237
phenix version printed to output script
dennisbrookner Jun 3, 2024
21e29b2
update matchmaps.ncs to handle phenix versions
dennisbrookner Jun 3, 2024
89c23e8
remove extra imports
dennisbrookner Jun 3, 2024
ebcad70
Merge branch 'main' into phenix121
dennisbrookner Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ docs/images/logo.ai
docs/images/logo2.ai

# PyCharm files
.idea/*
.idea/*
.idea/*
45 changes: 26 additions & 19 deletions src/matchmaps/_compute_mr_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
import argparse
import os
import sys
import subprocess
import time
from functools import partial
from pathlib import Path

import gemmi
import numpy as np
import reciprocalspaceship as rs

from matchmaps._phenix_utils import rigid_body_refinement_wrapper, phaser_wrapper, _remove_waters
from matchmaps._utils import (
_handle_special_positions,
make_floatgrid_from_mtz,
rigid_body_refinement_wrapper,
_realspace_align_and_subtract,
_rbr_selection_parser,
_remove_waters,
_restore_ligand_occupancy,
_validate_environment,
_validate_inputs,
phaser_wrapper,
_clean_up_files,
_cif_or_pdb_to_pdb,
_cif_or_mtz_to_mtz,
Expand Down Expand Up @@ -51,7 +46,8 @@ def compute_mr_difference_map(
radius : float = 5,
alpha : float = 0,
no_bss = False,
):
phenix_version: str = None,
):
"""
Compute a real-space difference map from mtzs in different spacegroups.

Expand Down Expand Up @@ -105,7 +101,12 @@ def compute_mr_difference_map(
If True, skip bulk solvent scaling feature of phenix.refine
"""

_validate_environment(ccp4=False)
auto_phenix_version = _validate_environment(ccp4=False)

if phenix_version:
pass
else:
phenix_version = auto_phenix_version

output_dir_contents = list(output_dir.glob("*"))

Expand All @@ -130,15 +131,8 @@ def compute_mr_difference_map(
f"{time.strftime('%H:%M:%S')}: Running phenix.phaser to place 'off' model into 'on' data..."
)

phaser_nickname = phaser_wrapper(
mtzfile=mtzon,
pdb=pdboff,
input_dir=input_dir,
output_dir=output_dir,
off_labels=f"{Fon},{SigFon}",
eff=None,
verbose=verbose,
)
phaser_nickname = phaser_wrapper(mtzfile=mtzon, pdb=pdboff, output_dir=output_dir, off_labels=f"{Fon},{SigFon}",
phenix_style=phenix_version, eff=None, verbose=verbose)

# TO-DO: fix ligand occupancies in pdb_mr_to_on
edited_mr_pdb = _restore_ligand_occupancy(
Expand All @@ -161,6 +155,7 @@ def compute_mr_difference_map(
off_labels=f"{Fon},{SigFon}", # workaround for compatibility
mr_on=True,
no_bss=no_bss,
phenix_style=phenix_version,
)

print(f"{time.strftime('%H:%M:%S')}: Running phenix.refine for the 'off' data...")
Expand All @@ -175,8 +170,8 @@ def compute_mr_difference_map(
verbose=verbose,
rbr_selections=rbr_phenix,
off_labels=f"{Foff},{SigFoff}",
mr_off=True,
no_bss=no_bss,
phenix_style=phenix_version,
)

# from here down I just copied over the stuff from the normal version
Expand Down Expand Up @@ -443,6 +438,16 @@ def parse_arguments():
)
)

parser.add_argument(
"--phenix-version",
required=False,
help=(
"Specify phenix version as a string, e.g. '1.20'. "
"If omitted, matchmaps will attempt to automatically detect the version in use "
"by analyzing the output of phenix.version"
)
)

return parser


Expand Down Expand Up @@ -485,14 +490,16 @@ def main():
alpha=args.alpha,
on_as_stationary=args.on_as_stationary,
keep_temp_files=args.keep_temp_files,
no_bss = args.no_bss
no_bss = args.no_bss,
phenix_version = args.phenix_version,
)

if args.script:
_write_script(
utility = 'matchmaps.mr',
arguments = sys.argv[1:],
script_name = args.script,
phenix_version=args.phenix_version,
)

return
Expand Down
33 changes: 23 additions & 10 deletions src/matchmaps/_compute_ncs_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
import argparse
import os
import sys
import subprocess
import time
from functools import partial
from pathlib import Path

import gemmi
import numpy as np
import reciprocalspaceship as rs


from matchmaps._phenix_utils import rigid_body_refinement_wrapper, _renumber_waters
from matchmaps._utils import (
_handle_special_positions,
make_floatgrid_from_mtz,
rigid_body_refinement_wrapper,
_realspace_align_and_subtract,
_rbr_selection_parser,
_renumber_waters,
_ncs_align_and_subtract,
_validate_environment,
_validate_inputs,
Expand Down Expand Up @@ -48,6 +42,7 @@ def compute_ncs_difference_map(
eff : str = None,
keep_temp_files : str = None,
no_bss = False,
phenix_version: str = None,
):
"""
Compute an internal difference map across non-crystallographic symmetry
Expand Down Expand Up @@ -91,8 +86,13 @@ def compute_ncs_difference_map(
no_bss : bool, optional
If True, skip bulk solvent scaling feature of phenix.refine
"""
_validate_environment(ccp4=False)

auto_phenix_version = _validate_environment(ccp4=False)

if phenix_version:
pass
else:
phenix_version = auto_phenix_version

output_dir_contents = list(output_dir.glob("*"))

pdb = _cif_or_pdb_to_pdb(pdb, output_dir)
Expand Down Expand Up @@ -121,7 +121,8 @@ def compute_ncs_difference_map(
verbose=verbose,
rbr_selections=rbr_phenix,
off_labels=f"{F},{SigF}",
no_bss=no_bss
no_bss=no_bss,
phenix_style=phenix_version,
)

# use phenix names for columns when computing FloatGrid
Expand Down Expand Up @@ -327,6 +328,16 @@ def parse_arguments():
"Note that this file is written out in the current working directory, NOT the input or output directories"
)
)

parser.add_argument(
"--phenix-version",
required=False,
help=(
"Specify phenix version as a string, e.g. '1.20'. "
"If omitted, matchmaps will attempt to automatically detect the version in use "
"by analyzing the output of phenix.version"
)
)

return parser

Expand Down Expand Up @@ -366,13 +377,15 @@ def main():
spacing=args.spacing,
keep_temp_files=args.keep_temp_files,
no_bss=args.no_bss,
phenix_version=args.phenix_version,
)

if args.script:
_write_script(
utility = 'matchmaps.ncs',
arguments = sys.argv[1:],
script_name = args.script,
phenix_version=args.phenix_version,
)

return
Expand Down
37 changes: 26 additions & 11 deletions src/matchmaps/_compute_realspace_diff.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
"""Compute unbiased real space difference map."""

import argparse
import os
import sys
import glob
import subprocess
import sys
import time
from functools import partial
from pathlib import Path

import gemmi
import numpy as np
import reciprocalspaceship as rs

from IPython import embed

from matchmaps._phenix_utils import rigid_body_refinement_wrapper, _renumber_waters
from matchmaps._utils import (
_handle_special_positions,
make_floatgrid_from_mtz,
rigid_body_refinement_wrapper,
_realspace_align_and_subtract,
_rbr_selection_parser,
_renumber_waters,
_clean_up_files,
_validate_environment,
_validate_inputs,
Expand Down Expand Up @@ -51,7 +44,8 @@ def compute_realspace_difference_map(
keep_temp_files : str = None,
radius : float = 5,
alpha : float = 0,
no_bss = False
no_bss = False,
phenix_version: str = None,
):
"""
Compute a real-space difference map from mtzs.
Expand Down Expand Up @@ -103,9 +97,16 @@ def compute_realspace_difference_map(
Alpha to use in error weighting of F-obs prior to Fourier Transform. Defaults to 0, e.g. no weighting.
no_bss : bool, optional
If True, skip bulk solvent scaling feature of phenix.refine
phenix_version: str, optional
Phenix version string to override the automatically detected version. I don't know why this would be necessary.
"""

_validate_environment(ccp4=True)
auto_phenix_version = _validate_environment(ccp4=True)

if phenix_version:
pass
else:
phenix_version = auto_phenix_version

output_dir_contents = list(output_dir.glob("*"))

Expand Down Expand Up @@ -173,6 +174,7 @@ def compute_realspace_difference_map(
verbose=verbose,
rbr_selections=rbr_phenix,
no_bss=no_bss,
phenix_style=phenix_version,
)

print(f"{time.strftime('%H:%M:%S')}: Running phenix.refine for the 'off' data...")
Expand All @@ -188,6 +190,7 @@ def compute_realspace_difference_map(
rbr_selections=rbr_phenix,
off_labels=f"{Foff},{SigFoff}",
no_bss=no_bss,
phenix_style=phenix_version,
)

# read back in the files created by phenix
Expand Down Expand Up @@ -446,6 +449,16 @@ def parse_arguments():
"Note that this file is written out in the current working directory, NOT the input or output directories"
)
)

parser.add_argument(
"--phenix-version",
required=False,
help=(
"Specify phenix version as a string, e.g. '1.20'. "
"If omitted, matchmaps will attempt to automatically detect the version in use "
"by analyzing the output of phenix.version"
)
)

return parser

Expand Down Expand Up @@ -484,13 +497,15 @@ def main():
on_as_stationary=args.on_as_stationary,
keep_temp_files=args.keep_temp_files,
no_bss = args.no_bss,
phenix_version = args.phenix_version,
)

if args.script:
_write_script(
utility = 'matchmaps',
arguments = sys.argv[1:],
script_name = args.script,
phenix_version=args.phenix_version,
)

return
Expand Down
Loading
Loading