Beispiel #1
0
def exercise_dials_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 = DialsIndexer()
    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, imageset.get_beam().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.14, 78.14, 78.14, 90, 90, 90), rel=1e-3)
    solution = indexer.get_solution()
    assert solution["rmsd"] == pytest.approx(0.03545, abs=1e-3)
    assert solution["metric"] == pytest.approx(0.02517, abs=5e-3)
    assert solution["number"] == 22
    assert solution["lattice"] == "cI"

    beam_centre = indexer.get_indexer_beam_centre()
    assert beam_centre == pytest.approx((94.41567208118963, 94.51337522659865),
                                        abs=1e-3)
    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()
    indexer2 = DialsIndexer.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())

    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"
def exercise_dials_multi_indexer(nproc=None):
    template = "/Volumes/touro/data/i19/4sweep/56_Reza-H2-normalhem_100K_3.75mmAl/56-RezaH2-hem_%02i_#####.cbf"

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

    cryst = None
    wav = None
    samp = None

    from xia2.Handlers.Phil import PhilIndex
    PhilIndex.params.xia2.settings.trust_beam_centre = True

    from xia2.Modules.Indexer.DialsIndexer import DialsIndexer

    from xia2.Modules.Indexer.DialsIndexer import DialsIndexer
    indexer = DialsIndexer()
    indexer.set_working_directory(tmp_dir)
    for i in range(4):
        from dxtbx.datablock import DataBlockTemplateImporter
        importer = DataBlockTemplateImporter([template % (i + 1)])
        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

        if cryst is None or wav is None:
            cryst = XCrystal("CRYST1", None)
            wav = XWavelength("WAVE1", cryst,
                              imageset.get_beam().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.add_indexer_sweep(sweep)

    indexer.index()

    assert approx_equal(indexer.get_indexer_cell(),
                        (9.088, 12.415, 17.420, 90.000, 90.000, 90.000),
                        eps=1e-2)
Beispiel #3
0
def exercise_dials_multi_indexer(nproc=None):
  template = "/Volumes/touro/data/i19/4sweep/56_Reza-H2-normalhem_100K_3.75mmAl/56-RezaH2-hem_%02i_#####.cbf"

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

  cryst = None
  wav = None
  samp = None

  from xia2.Handlers.Phil import PhilIndex
  PhilIndex.params.xia2.settings.trust_beam_centre = True

  from xia2.Modules.Indexer.DialsIndexer import DialsIndexer

  from xia2.Modules.Indexer.DialsIndexer import DialsIndexer
  indexer = DialsIndexer()
  indexer.set_working_directory(tmp_dir)
  for i in range(4):
    from dxtbx.datablock import DataBlockTemplateImporter
    importer = DataBlockTemplateImporter([template %(i+1)])
    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

    if cryst is None or wav is None:
      cryst = XCrystal("CRYST1", None)
      wav = XWavelength("WAVE1", cryst, imageset.get_beam().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.add_indexer_sweep(sweep)

  indexer.index()

  assert approx_equal(
    indexer.get_indexer_cell(),
    (9.088, 12.415, 17.420, 90.000, 90.000, 90.000), eps=1e-2)
Beispiel #4
0
def exercise_dials_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.DialsIndexer import DialsIndexer
    indexer = DialsIndexer()
    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, imageset.get_beam().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.14, 78.14, 78.14, 90, 90, 90),
                        eps=1e-1)
    solution = indexer.get_solution()
    assert approx_equal(solution['rmsd'], 0.041, eps=1e-2)
    assert approx_equal(solution['metric'], 0.027, eps=1e-2)
    assert solution['number'] == 22
    assert solution['lattice'] == 'cI'

    beam_centre = indexer.get_indexer_beam_centre()
    assert approx_equal(beam_centre, (94.4223, 94.5097), eps=1e-2)
    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 = DialsIndexer.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())

    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'
def exercise_dials_indexer(dials_data, tmp_dir, nproc=None):
    if nproc is not None:
        from xia2.Handlers.Phil import PhilIndex

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

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

    from xia2.Modules.Indexer.DialsIndexer import DialsIndexer

    indexer = DialsIndexer()
    indexer.set_working_directory(tmp_dir)
    from dxtbx.model.experiment_list import ExperimentListTemplateImporter

    importer = ExperimentListTemplateImporter([template])
    experiments = importer.experiments
    imageset = experiments.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, imageset.get_beam().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.14, 78.14, 78.14, 90, 90, 90),
                        eps=1e-1)
    solution = indexer.get_solution()
    assert approx_equal(solution["rmsd"], 0.041, eps=1e-2)
    assert approx_equal(solution["metric"], 0.027, eps=1e-2)
    assert solution["number"] == 22
    assert solution["lattice"] == "cI"

    beam_centre = indexer.get_indexer_beam_centre()
    assert approx_equal(beam_centre, (94.4223, 94.5097), eps=1e-2)
    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 = DialsIndexer.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())

    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"
Beispiel #6
0
def exercise_dials_indexer(nproc=None):
  if not have_dials_regression:
    print "Skipping exercise_dials_indexer(): dials_regression not configured"
    return

  if nproc is not None:
    from xia2.Handlers.Flags import Flags
    Flags.set_parallel(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.DialsIndexer import DialsIndexer
  indexer = DialsIndexer()
  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, imageset.get_beam().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.14, 78.14, 78.14, 90, 90, 90), eps=1e-1)
  solution = indexer.get_solution()
  assert approx_equal(solution['rmsd'], 0.041, eps=1e-2)
  assert approx_equal(solution['metric'], 0.027, eps=1e-2)
  assert solution['number'] == 22
  assert solution['lattice'] == 'cI'

  beam_centre = indexer.get_indexer_beam_centre()
  assert approx_equal(beam_centre, (94.4223, 94.5097), eps=1e-2)
  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 = DialsIndexer.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())

  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'