Esempio n. 1
0
def test_mosflm_indexer(regression_test, ccp4, dials_data, run_in_tmpdir):
    template = dials_data("insulin").join("insulin_1_###.img").strpath

    from xia2.Modules.Indexer.MosflmIndexer import MosflmIndexer

    indexer = MosflmIndexer()
    indexer.set_working_directory(run_in_tmpdir.strpath)
    from dxtbx.model.experiment_list import ExperimentListTemplateImporter

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

    with mock.patch.object(
            sys, "argv",
        []):  # otherwise indexing fails when running pytest with '--runslow'
        indexer.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        (78.6657, 78.6657, 78.6657, 90.0, 90.0, 90.0), abs=1e-3)
    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.34, 94.57), abs=1e-2)
    assert indexer.get_indexer_images() == [(1, 1), (22, 22), (45, 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 = MosflmIndexer.from_json(string=json_str)
    indexer2.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell(), abs=1e-6)
    assert indexer.get_indexer_beam_centre() == pytest.approx(
        indexer2.get_indexer_beam_centre(), abs=1e-6)
    assert indexer2.get_indexer_images() == [
        [1, 1],
        [22, 22],
        [45, 45],
    ]  # coming from json these are now lists

    indexer.eliminate()
    indexer2.eliminate()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell(), abs=1e-6)
    assert indexer.get_indexer_lattice() == "hR"
    assert indexer2.get_indexer_lattice() == "hR"
Esempio n. 2
0
def exercise_mosflm_indexer():
  if not have_dials_regression:
    print "Skipping exercise_mosflm_indexer(): dials_regression not configured"
    return

  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.MosflmIndexer import MosflmIndexer
  indexer = MosflmIndexer()
  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)

  indexer.index()

  assert approx_equal(indexer.get_indexer_cell(),
                      (78.6657, 78.6657, 78.6657, 90.0, 90.0, 90.0), eps=1e-3)
  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.34, 94.57), eps=1e-2)
  assert indexer.get_indexer_images() == [(1, 1), (22, 22), (45, 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 = MosflmIndexer.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'
Esempio n. 3
0
def test_mosflm_indexer(ccp4, xia2_regression_build, tmpdir):
    template = os.path.join(xia2_regression_build, "test_data", "insulin",
                            "insulin_1_###.img")
    tmpdir.chdir()

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

    with mock.patch.object(
            sys, 'argv',
        []):  # otherwise indexing fails when running pytest with '--runslow'
        indexer.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        (78.6657, 78.6657, 78.6657, 90.0, 90.0, 90.0), abs=1e-3)
    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.34, 94.57), abs=1e-2)
    assert indexer.get_indexer_images() == [(1, 1), (22, 22), (45, 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 = MosflmIndexer.from_json(string=json_str)
    indexer2.index()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell(), abs=1e-6)
    assert indexer.get_indexer_beam_centre() == pytest.approx(
        indexer2.get_indexer_beam_centre(), abs=1e-6)
    assert indexer2.get_indexer_images() == [[1, 1], [22, 22], [
        45, 45
    ]]  # coming from json these are now lists

    indexer.eliminate()
    indexer2.eliminate()

    assert indexer.get_indexer_cell() == pytest.approx(
        indexer2.get_indexer_cell(), abs=1e-6)
    assert indexer.get_indexer_lattice() == 'hR'
    assert indexer2.get_indexer_lattice() == 'hR'
Esempio n. 4
0
def exercise_mosflm_index():
  if not have_dials_regression:
    print 'SKIP: dials_regression not configured'
    exit(0)

  xia2_demo_data = os.path.join(dials_regression, "xia2_demo_data")
  template = os.path.join(xia2_demo_data, "insulin_1_%03i.img")

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

  from xia2.Modules.Indexer.MosflmIndexer import MosflmIndexer
  m1 = MosflmIndexer()
  m1.set_working_directory(tmp_dir1)
  m1.setup_from_image(template % 1)
  m1.index()

  os.chdir(cwd)
  tmp_dir2 = os.path.abspath(open_tmp_directory())
  os.chdir(tmp_dir2)

  from Original import Mosflm
  m2 = Mosflm()
  m2.set_working_directory(tmp_dir2)
  m2.setup_from_image(template % 1)
  m2.index()

  assert m1.get_indexer_beam_centre() == m2.get_indexer_beam_centre()
  assert m1.get_indexer_distance() == m2.get_indexer_distance()
  assert m1.get_indexer_cell() == m2.get_indexer_cell()
  assert m1.get_indexer_lattice() == m2.get_indexer_lattice()
  assert m1.get_indexer_mosaic() == m2.get_indexer_mosaic()

  os.chdir(cwd)

  return