Skip to content

Commit

Permalink
MR and NCS functions accept sfCIFs
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisbrookner committed Oct 12, 2023
1 parent 67550b1 commit 8c9ecc1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
11 changes: 4 additions & 7 deletions src/matchmaps/_compute_mr_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
phaser_wrapper,
_clean_up_files,
_cif_or_pdb_to_pdb,
_cif_or_mtz_to_mtz,
)


Expand Down Expand Up @@ -94,17 +95,16 @@ def compute_mr_difference_map(

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

off_name = mtzoff.name.removesuffix(".mtz")
on_name = mtzon.name.removesuffix(".mtz")

pdboff = _cif_or_pdb_to_pdb(pdboff, output_dir)

mtzoff, off_name = _cif_or_mtz_to_mtz(mtzoff, output_dir)
mtzon, on_name = _cif_or_mtz_to_mtz(mtzon, output_dir)

# take in the list of rbr selections and parse them into phenix and gemmi selection formats
# if rbr_groups = None, just returns (None, None)
rbr_phenix, rbr_gemmi = _rbr_selection_parser(rbr_selections)

# this is where scaling takes place in the usual pipeline, but that doesn't make sense with different-spacegroup inputs
# side note: I need to test the importance of scaling even in the normal case!! Might be more artifact than good, who knows

pdboff = _handle_special_positions(pdboff, output_dir)

Expand Down Expand Up @@ -133,8 +133,6 @@ def compute_mr_difference_map(
output_dir=output_dir,
)

# the refinement process *should* be identical. Waters are gone already
# I just need to make sure that the phaser outputs go together
print(f"{time.strftime('%H:%M:%S')}: Running phenix.refine for the 'on' data...")

nickname_on = rigid_body_refinement_wrapper(
Expand Down Expand Up @@ -166,7 +164,6 @@ def compute_mr_difference_map(
)

# from here down I just copied over the stuff from the normal version
# this should be proofread for compatibility but should all work

# read back in the files created by phenix
# these have knowable names
Expand Down
5 changes: 4 additions & 1 deletion src/matchmaps/_compute_ncs_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
_validate_inputs,
_clean_up_files,
_cif_or_pdb_to_pdb,
_cif_or_mtz_to_mtz,
)


Expand Down Expand Up @@ -51,6 +52,8 @@ def compute_ncs_difference_map(

pdb = _cif_or_pdb_to_pdb(pdb, output_dir)

mtz, _ = _cif_or_mtz_to_mtz(mtz, output_dir)

rbr_phenix, rbr_gemmi = _rbr_selection_parser(ncs_chains)

if Phi is None: # do rigid-body refinement to get phases
Expand Down Expand Up @@ -109,7 +112,7 @@ def compute_ncs_difference_map(
)

print(f"{time.strftime('%H:%M:%S')}: Cleaning up files...")
print(keep_temp_files)

_clean_up_files(output_dir, output_dir_contents, keep_temp_files)

print(f"{time.strftime('%H:%M:%S')}: Done!")
Expand Down
3 changes: 0 additions & 3 deletions src/matchmaps/_compute_realspace_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ def compute_realspace_difference_map(

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

# off_name = mtzoff.name.removesuffix(".mtz")
# on_name = mtzon.name.removesuffix(".mtz")

pdboff = _cif_or_pdb_to_pdb(pdboff, output_dir)

mtzoff, off_name = _cif_or_mtz_to_mtz(mtzoff, output_dir)
Expand Down
22 changes: 20 additions & 2 deletions src/matchmaps/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,9 @@ def _cif_or_mtz_to_mtz(input_file, output_dir):
Parameters
----------
input_file : _type_
input_file : pathlib.Path
_description_
output_dir : _type_
output_dir : pathlib.Path
_description_
Returns
Expand Down Expand Up @@ -923,6 +923,24 @@ def _cif_or_mtz_to_mtz(input_file, output_dir):
input_file.name.removesuffix(input_file.suffix))

def _cif_or_pdb_to_pdb(input_file, output_dir):
"""
_summary_
Parameters
----------
input_file : pathlib.Path
output_dir : pathlib.Path
Returns
-------
pathlib.Path
path to output file
Raises
------
ValueError
_description_
"""

if input_file.suffix.lower() == '.pdb':

Expand Down

0 comments on commit 8c9ecc1

Please sign in to comment.