Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix_ssx_integrate_ima…
Browse files Browse the repository at this point in the history
…geviewer
  • Loading branch information
jbeilstenedmands committed Feb 2, 2024
2 parents cb68fbb + bf73681 commit c247470
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/2590.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated interfaces between DIALS and cctbx
1 change: 1 addition & 0 deletions newsfragments/2592.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reorganize imports in ``export_mtz.py`` so that its gemmi-less objects can be used by other gemmi-less software
10 changes: 9 additions & 1 deletion src/dials/util/export_mtz.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
from math import isclose
from typing import List, Optional

import gemmi
import numpy as np
import pandas as pd
try:
import gemmi
except ModuleNotFoundError as e:
gemmi = None
gemmi_import_error = e

from cctbx import uctbx
from dxtbx import flumpy
Expand Down Expand Up @@ -310,6 +314,8 @@ def add_batch_list(
if max_batch_number > batch_offset:
batch_offset = max_batch_number

if gemmi is None:
raise gemmi_import_error
batch = gemmi.Mtz.Batch()

# Setting fields that are the same for all batches
Expand Down Expand Up @@ -670,6 +676,8 @@ def export_mtz(
)

# Create the mtz file
if gemmi is None:
raise gemmi_import_error
mtz = gemmi.Mtz(with_base=True)
mtz.title = f"From {env.dispatcher_name}"
date_str = time.strftime("%Y-%m-%d at %H:%M:%S %Z")
Expand Down
10 changes: 8 additions & 2 deletions src/dials/util/reference.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from __future__ import annotations

from iotbx import cif, mtz, pdb
from mmtbx.command_line.fmodel import fmodel_from_xray_structure_master_params

try:
from mmtbx.command_line.fmodel import (
fmodel_from_xray_structure_master_params as fmodel_phil,
)
except ImportError:
from mmtbx.programs.fmodel import master_phil as fmodel_phil
from mmtbx.utils import fmodel_from_xray_structure

reference_phil_str = """
Expand Down Expand Up @@ -133,7 +139,7 @@ def _mmtbx_intensity_from_structure(
"""Use the mmtbx methods for quick calculation of fs from model."""
if wavelength:
xray_structure.set_inelastic_form_factors(photon=wavelength, table="sasaki")
params = fmodel_from_xray_structure_master_params.extract()
params = fmodel_phil.extract()
params.high_resolution = d_min
params.fmodel.k_sol = k_sol
params.fmodel.b_sol = b_sol
Expand Down

0 comments on commit c247470

Please sign in to comment.