예제 #1
0
def exercise_xds_indexer(dials_data, tmp_dir, nproc=None):
    if nproc is not None:
        PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc

    template = dials_data("insulin").join("insulin_1_###.img").strpath

    indexer = XDSIndexer()
    indexer.set_working_directory(tmp_dir)

    importer = ExperimentListTemplateImporter([template])
    experiments = importer.experiments
    imageset = experiments.imagesets()[0]
    indexer.add_indexer_imageset(imageset)

    cryst = XCrystal("CRYST1", None)
    wav = XWavelength("WAVE1", cryst, indexer.get_wavelength())
    samp = XSample("X1", cryst)
    directory, image = os.path.split(imageset.get_path(1))
    sweep = XSweep("SWEEP1", wav, samp, directory=directory, image=image)
    indexer.set_indexer_sweep(sweep)

    indexer.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        (78.076, 78.076, 78.076, 90, 90, 90),
        abs=1), indexer.get_indexer_cell()
    experiment = indexer.get_indexer_experiment_list()[0]
    sgi = experiment.crystal.get_space_group().info()
    assert sgi.type().number() == 197

    beam_centre = indexer.get_indexer_beam_centre()
    assert beam_centre == pytest.approx((94.4221, 94.5096), abs=1e-1)
    assert indexer.get_indexer_images() == [(1, 5), (20, 24), (41, 45)]
    print(indexer.get_indexer_experiment_list()[0].crystal)
    print(indexer.get_indexer_experiment_list()[0].detector)

    # test serialization of indexer
    json_str = indexer.as_json()
    print(json_str)
    indexer2 = XDSIndexer.from_json(string=json_str)
    indexer2.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell())
    assert indexer.get_indexer_beam_centre() == pytest.approx(
        indexer2.get_indexer_beam_centre())
    assert indexer.get_indexer_images() == [
        tuple(i) for i in indexer2.get_indexer_images()
    ]

    indexer.eliminate()
    indexer2.eliminate()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell())
    assert indexer.get_indexer_lattice() == "hR"
    assert indexer2.get_indexer_lattice() == "hR"
예제 #2
0
def exercise_xds_indexer(xia2_regression_build, tmp_dir, nproc=None):
    if nproc is not None:
        from xia2.Handlers.Phil import PhilIndex
        PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc

    xia2_demo_data = os.path.join(xia2_regression_build, "test_data",
                                  "insulin")
    template = os.path.join(xia2_demo_data, "insulin_1_###.img")

    from xia2.Modules.Indexer.XDSIndexer import XDSIndexer
    indexer = XDSIndexer()
    indexer.set_working_directory(tmp_dir)
    from dxtbx.datablock import DataBlockTemplateImporter
    importer = DataBlockTemplateImporter([template])
    datablocks = importer.datablocks
    imageset = datablocks[0].extract_imagesets()[0]
    indexer.add_indexer_imageset(imageset)

    from xia2.Schema.XCrystal import XCrystal
    from xia2.Schema.XWavelength import XWavelength
    from xia2.Schema.XSweep import XSweep
    from xia2.Schema.XSample import XSample
    cryst = XCrystal("CRYST1", None)
    wav = XWavelength("WAVE1", cryst, indexer.get_wavelength())
    samp = XSample("X1", cryst)
    directory, image = os.path.split(imageset.get_path(1))
    sweep = XSweep('SWEEP1', wav, samp, directory=directory, image=image)
    indexer.set_indexer_sweep(sweep)

    indexer.index()

    assert approx_equal(indexer.get_indexer_cell(),
                        (78.076, 78.076, 78.076, 90, 90, 90),
                        eps=1), indexer.get_indexer_cell()
    experiment = indexer.get_indexer_experiment_list()[0]
    sgi = experiment.crystal.get_space_group().info()
    assert sgi.type().number() == 197

    beam_centre = indexer.get_indexer_beam_centre()
    assert approx_equal(beam_centre, (94.4221, 94.5096), eps=1e-1)
    assert indexer.get_indexer_images() == [(1, 5), (20, 24), (41, 45)]
    print(indexer.get_indexer_experiment_list()[0].crystal)
    print(indexer.get_indexer_experiment_list()[0].detector)

    # test serialization of indexer
    json_str = indexer.as_json()
    print(json_str)
    indexer2 = XDSIndexer.from_json(string=json_str)
    indexer2.index()

    assert approx_equal(indexer.get_indexer_cell(),
                        indexer2.get_indexer_cell())
    assert approx_equal(indexer.get_indexer_beam_centre(),
                        indexer2.get_indexer_beam_centre())
    assert approx_equal(indexer.get_indexer_images(),
                        indexer2.get_indexer_images())

    indexer.eliminate()
    indexer2.eliminate()

    assert approx_equal(indexer.get_indexer_cell(),
                        indexer2.get_indexer_cell())
    assert indexer.get_indexer_lattice() == 'hR'
    assert indexer2.get_indexer_lattice() == 'hR'
예제 #3
0
파일: TstXDSIndexer.py 프로젝트: xia2/xia2
def exercise_xds_indexer(nproc=None):
    if not have_dials_regression:
        print "Skipping exercise_xds_indexer(): dials_regression not configured"
        return

    if nproc is not None:
        from xia2.Handlers.Phil import PhilIndex

        PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc

    xia2_demo_data = os.path.join(dials_regression, "xia2_demo_data")
    template = os.path.join(xia2_demo_data, "insulin_1_###.img")

    cwd = os.path.abspath(os.curdir)
    tmp_dir = os.path.abspath(open_tmp_directory())
    os.chdir(tmp_dir)

    from xia2.Modules.Indexer.XDSIndexer import XDSIndexer

    indexer = XDSIndexer()
    indexer.set_working_directory(tmp_dir)
    from dxtbx.datablock import DataBlockTemplateImporter

    importer = DataBlockTemplateImporter([template])
    datablocks = importer.datablocks
    imageset = datablocks[0].extract_imagesets()[0]
    indexer.add_indexer_imageset(imageset)

    from xia2.Schema.XCrystal import XCrystal
    from xia2.Schema.XWavelength import XWavelength
    from xia2.Schema.XSweep import XSweep
    from xia2.Schema.XSample import XSample

    cryst = XCrystal("CRYST1", None)
    wav = XWavelength("WAVE1", cryst, indexer.get_wavelength())
    samp = XSample("X1", cryst)
    directory, image = os.path.split(imageset.get_path(1))
    sweep = XSweep("SWEEP1", wav, samp, directory=directory, image=image)
    indexer.set_indexer_sweep(sweep)

    indexer.index()

    assert approx_equal(
        indexer.get_indexer_cell(), (78.07336, 78.07337, 78.07336, 90, 90, 90), eps=1e-3
    ), indexer.get_indexer_cell()
    experiment = indexer.get_indexer_experiment_list()[0]
    sgi = experiment.crystal.get_space_group().info()
    assert sgi.type().number() == 197

    beam_centre = indexer.get_indexer_beam_centre()
    assert approx_equal(beam_centre, (94.4221, 94.5096), eps=1e-3)
    assert indexer.get_indexer_images() == [(1, 5), (20, 24), (41, 45)]
    print indexer.get_indexer_experiment_list()[0].crystal
    print indexer.get_indexer_experiment_list()[0].detector

    # test serialization of indexer
    json_str = indexer.as_json()
    print json_str
    indexer2 = XDSIndexer.from_json(string=json_str)
    indexer2.index()

    assert approx_equal(indexer.get_indexer_cell(), indexer2.get_indexer_cell())
    assert approx_equal(indexer.get_indexer_beam_centre(), indexer2.get_indexer_beam_centre())
    assert approx_equal(indexer.get_indexer_images(), indexer2.get_indexer_images())

    indexer.eliminate()
    indexer2.eliminate()

    assert approx_equal(indexer.get_indexer_cell(), indexer2.get_indexer_cell())
    assert indexer.get_indexer_lattice() == "hR"
    assert indexer2.get_indexer_lattice() == "hR"