Beispiel #1
0
def test_stills_indexer_methods_i04_weak_data(i04_weak_data, indexing_method,
                                              space_group, unit_cell):
    reflections = slice_reflections(i04_weak_data["reflections"], [(1, 2)])
    experiments = slice_experiments(i04_weak_data["experiments"], [(1, 2)])
    for experiment in experiments:
        experiment.imageset = ImageSet(experiment.imageset.data(),
                                       experiment.imageset.indices())
        experiment.imageset.set_scan(None)
        experiment.imageset.set_goniometer(None)
        experiment.scan = None
        experiment.goniometer = None
    params = phil_scope.fetch().extract()
    params.indexing.method = indexing_method
    params.indexing.basis_vector_combinations.max_refine = 5
    if unit_cell is not None:
        params.indexing.known_symmetry.unit_cell = uctbx.unit_cell(unit_cell)
    if space_group is not None:
        params.indexing.known_symmetry.space_group = sgtbx.space_group_info(
            space_group)
    try:
        idxr = stills_indexer.StillsIndexerBasisVectorSearch(
            reflections, experiments, params)
    except RuntimeError:
        idxr = stills_indexer.StillsIndexerLatticeSearch(
            reflections, experiments, params)
    idxr.index()

    indexed_experiments = idxr.refined_experiments
    assert len(indexed_experiments) == 1
    assert indexed_experiments[0].crystal.get_unit_cell().parameters(
    ) == pytest.approx((57.752, 57.776, 150.013, 90.0101, 89.976, 90.008),
                       rel=1e-2)
Beispiel #2
0
def test_mmcif_p1_narrow_wedge(dials_data, tmp_path):
    """Call dials.export format=mmcif after scaling"""
    data_dir = dials_data("x4wide_processed", pathlib=True)

    refl = flex.reflection_table.from_file(data_dir / "AUTOMATIC_DEFAULT_scaled.refl")
    refl = slice_reflections(refl, [(1, 3)])
    refl.as_file(tmp_path / "p1_narrow.refl")

    expts = load.experiment_list(
        data_dir / "AUTOMATIC_DEFAULT_scaled.expt", check_format=False
    )
    expts = slice_experiments(expts, [(1, 3)])
    expts[0].crystal.set_space_group(sgtbx.space_group())
    expts.as_file(tmp_path / "p1_narrow.expt")

    command = [
        "dials.export",
        "format=mmcif",
        tmp_path / "p1_narrow.expt",
        tmp_path / "p1_narrow.refl",
        "mmcif.hklout=scaled.mmcif",
        "compress=None",
    ]
    result = procrunner.run(command, working_directory=tmp_path)
    assert not result.returncode and not result.stderr
    assert (tmp_path / "scaled.mmcif").is_file()

    model = iotbx.cif.reader(file_path=str(tmp_path / "scaled.mmcif")).model()
    assert model["dials"]["_reflns.pdbx_redundancy"] == "1.0"
    assert model["dials"]["_reflns.pdbx_CC_half"] == "0.0"
Beispiel #3
0
def i04_weak_data(dials_regression):
    data_dir = py.path.local(dials_regression).join("indexing_test_data",
                                                    "i04_weak_data")
    reflections_path = data_dir.join("full.pickle").strpath
    experiments_path = data_dir.join("experiments_import.json").strpath

    reflections = flex.reflection_table.from_file(reflections_path)
    experiments = load.experiment_list(experiments_path, check_format=False)

    return {
        "reflections": slice_reflections(reflections, [(1, 20)]),
        "experiments": slice_experiments(experiments, [(1, 20)]),
    }
Beispiel #4
0
def test_data_manager_filter_dose_out_of_range(
        protk_experiments_and_reflections):
    experiments, reflections = protk_experiments_and_reflections

    # Truncate one of the experiments so that one of the expt image ranges
    # doesn't overlap with the requested dose range
    image_range = [expt.scan.get_image_range() for expt in experiments]
    image_range[3] = (1, 10)
    experiments = slice_experiments(experiments, image_range)
    reflections = slice_reflections(reflections, image_range)

    # Construct the DataManager
    data_manager = ScaleAndMerge.DataManager(experiments, reflections)

    # Filter on dose and verify that one experiment has been removed
    data_manager.filter_dose(12, 25)
    assert len(data_manager.experiments) == 7
    assert len(data_manager.experiments) < len(experiments)
    for expt in data_manager.experiments:
        assert expt.scan.get_image_range() == (12, 25)
Beispiel #5
0
    def filter_dose(self, dose_min, dose_max):
        from dials.command_line.slice_sequence import (
            slice_experiments,
            slice_reflections,
        )

        image_range = [(
            max(dose_min,
                expt.scan.get_image_range()[0]),
            min(dose_max,
                expt.scan.get_image_range()[1]),
        ) for expt in self._experiments]
        n_refl_before = self._reflections.size()
        self._experiments = slice_experiments(self._experiments, image_range)
        flex.min_max_mean_double(
            self._reflections["xyzobs.px.value"].parts()[2]).show()
        self._reflections = slice_reflections(self._reflections, image_range)
        flex.min_max_mean_double(
            self._reflections["xyzobs.px.value"].parts()[2]).show()
        logger.info(
            "%i reflections out of %i remaining after filtering for dose" %
            (self._reflections.size(), n_refl_before))
Beispiel #6
0
    def filter_dose(self, dose_min, dose_max):
        from dials.command_line.slice_sequence import (
            slice_experiments,
            slice_reflections,
        )

        keep_expts = []
        for i, expt in enumerate(self._experiments):
            start, end = expt.scan.get_image_range()
            if (start <= dose_min <= end) or (start <= dose_max <= end):
                keep_expts.append(expt.identifier)
            else:
                logger.info(
                    f"Removing experiment {expt.identifier} (image range {start, end} does not overlap with dose range)"
                )
        if len(keep_expts):
            logger.info(
                f"Selecting {len(keep_expts)} experiments that overlap with dose range"
            )
        self.select(keep_expts)

        image_range = [(
            max(dose_min,
                expt.scan.get_image_range()[0]),
            min(dose_max,
                expt.scan.get_image_range()[1]),
        ) for expt in self._experiments]
        n_refl_before = self._reflections.size()
        self._experiments = slice_experiments(self._experiments, image_range)
        flex.min_max_mean_double(
            self._reflections["xyzobs.px.value"].parts()[2]).show()
        self._reflections = slice_reflections(self._reflections, image_range)
        flex.min_max_mean_double(
            self._reflections["xyzobs.px.value"].parts()[2]).show()
        logger.info(
            "%i reflections out of %i remaining after filtering for dose" %
            (self._reflections.size(), n_refl_before))