File: test_simple_integrate.py

package info (click to toggle)
dials 3.25.0%2Bdfsg3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,112 kB
  • sloc: python: 134,740; cpp: 34,526; makefile: 160; sh: 142
file content (95 lines) | stat: -rw-r--r-- 3,644 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from __future__ import annotations

import shutil
import subprocess

import pytest

from dials.array_family import flex


def test_against_dials_integrate(dials_data, tmp_path):
    ## ensure insulin folder exists
    dials_data("insulin", pathlib=True)

    # Run as a single job to avoid splitting reflections
    subprocess.run(
        (
            shutil.which("dials.integrate"),
            dials_data("insulin_processed", pathlib=True) / "refined.expt",
            dials_data("insulin_processed", pathlib=True) / "refined.refl",
            "mp.njobs=1",
            "mp.nproc=1",
            "scan_range=1,2",
        ),
        cwd=tmp_path,
        capture_output=True,
    ).check_returncode()

    subprocess.run(
        (
            shutil.which("dev.dials.simple_integrate"),
            dials_data("insulin_processed", pathlib=True) / "refined.expt",
            dials_data("insulin_processed", pathlib=True) / "refined.refl",
            "scan_range=1,2",
        ),
        cwd=tmp_path,
        capture_output=True,
    ).check_returncode()

    simple_refl = flex.reflection_table.from_file(tmp_path / "simple_integrated.refl")
    dials_refl = flex.reflection_table.from_file(tmp_path / "integrated.refl")

    matches = dials_refl.match_with_reference(simple_refl)[0]
    dials_refl = dials_refl.select(matches)

    assert len(simple_refl) == len(dials_refl)
    assert sum(
        simple_refl["intensity.sum.value"] - dials_refl["intensity.sum.value"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["intensity.prf.value"] - dials_refl["intensity.prf.value"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["background.sum.value"] - dials_refl["background.sum.value"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["background.mean"] - dials_refl["background.mean"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["background.dispersion"] - dials_refl["background.dispersion"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["background.mse"] - dials_refl["background.mse"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["background.sum.variance"] - dials_refl["background.sum.variance"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["intensity.prf.variance"] - dials_refl["intensity.prf.variance"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(
        simple_refl["intensity.sum.variance"] - dials_refl["intensity.sum.variance"]
    ) == pytest.approx(0.0, abs=1e-7)
    assert sum(simple_refl["lp"] - dials_refl["lp"]) == pytest.approx(0.0, abs=1e-7)
    assert sum(simple_refl["zeta"] - dials_refl["zeta"]) == pytest.approx(0.0, abs=1e-7)
    assert sum(simple_refl["d"] - dials_refl["d"]) == pytest.approx(0.0, abs=1e-7)
    assert sum(simple_refl["partiality"] - dials_refl["partiality"]) == pytest.approx(
        0.0, abs=1e-7
    )
    assert (
        simple_refl["num_pixels.foreground"] == dials_refl["num_pixels.foreground"]
    ).count(True) == len(simple_refl)
    assert (
        simple_refl["num_pixels.background"] == dials_refl["num_pixels.background"]
    ).count(True) == len(simple_refl)
    assert (simple_refl["num_pixels.valid"] == dials_refl["num_pixels.valid"]).count(
        True
    ) == len(simple_refl)
    assert (
        simple_refl["num_pixels.background_used"]
        == dials_refl["num_pixels.background_used"]
    ).count(True) == len(simple_refl)
    assert sum(
        simple_refl["profile.correlation"] - dials_refl["profile.correlation"]
    ) == pytest.approx(0.0, abs=1e-7)