From 8c9ecc150d8b5d412179f157c8fa8944ae7ee9f7 Mon Sep 17 00:00:00 2001 From: dennisbrookner Date: Thu, 12 Oct 2023 11:45:54 -0400 Subject: [PATCH] MR and NCS functions accept sfCIFs --- src/matchmaps/_compute_mr_diff.py | 11 ++++------- src/matchmaps/_compute_ncs_diff.py | 5 ++++- src/matchmaps/_compute_realspace_diff.py | 3 --- src/matchmaps/_utils.py | 22 ++++++++++++++++++++-- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/matchmaps/_compute_mr_diff.py b/src/matchmaps/_compute_mr_diff.py index 06ff21a..65b9555 100644 --- a/src/matchmaps/_compute_mr_diff.py +++ b/src/matchmaps/_compute_mr_diff.py @@ -23,6 +23,7 @@ phaser_wrapper, _clean_up_files, _cif_or_pdb_to_pdb, + _cif_or_mtz_to_mtz, ) @@ -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) @@ -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( @@ -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 diff --git a/src/matchmaps/_compute_ncs_diff.py b/src/matchmaps/_compute_ncs_diff.py index d2cff72..75e8ab0 100644 --- a/src/matchmaps/_compute_ncs_diff.py +++ b/src/matchmaps/_compute_ncs_diff.py @@ -24,6 +24,7 @@ _validate_inputs, _clean_up_files, _cif_or_pdb_to_pdb, + _cif_or_mtz_to_mtz, ) @@ -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 @@ -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!") diff --git a/src/matchmaps/_compute_realspace_diff.py b/src/matchmaps/_compute_realspace_diff.py index 096ffc2..1cb0dec 100755 --- a/src/matchmaps/_compute_realspace_diff.py +++ b/src/matchmaps/_compute_realspace_diff.py @@ -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) diff --git a/src/matchmaps/_utils.py b/src/matchmaps/_utils.py index 558edac..fc32388 100644 --- a/src/matchmaps/_utils.py +++ b/src/matchmaps/_utils.py @@ -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 @@ -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':