Exemple #1
0
def exercise_solver():
  import libtbx.load_env
  if (not libtbx.env.has_module("spotfinder")):
    print "Skipping some tests due to missing module: spotfinder"
    return
  from libtbx.test_utils import block_show_diff, contains_substring
  from libtbx import easy_run
  def run(args):
    cmd = " ".join(["rstbx.simage.solver"] + args)
    print cmd
    buf = easy_run.fully_buffered(
      command=cmd, stdout_splitlines=False).raise_if_errors().stdout_buffer
    for key in [
          "Final:"]:
      assert contains_substring(buf, key)
    return buf
  buf = run(["d_min=5"])
  assert not block_show_diff(buf, """\
input_im0_i_perm: 0

Correlation of input and estimated I-obs:
  i_perm=0:  1.00000 (r1: 0.00000)
""")
  buf = run(["d_min=5", "lattice_symmetry=R32:R", "intensity_symmetry=R3:R"])
  assert not block_show_diff(buf, """\
input_im0_i_perm: 1

Correlation of input and estimated I-obs:
  i_perm=0:  0.06799 (r1: 0.37555)
  i_perm=1:  1.00000 (r1: 0.00000)
""")
  buf = run(["d_min=5", "lattice_symmetry=R32:R", "intensity_symmetry=P1"])
  assert not block_show_diff(buf, """\
input_im0_i_perm: 5

Correlation of input and estimated I-obs:
  i_perm=0:  0.07524 (r1: 0.38937)
  i_perm=1: -0.02385 (r1: 0.40114)
  i_perm=2: -0.04577 (r1: 0.41742)
  i_perm=3: -0.00099 (r1: 0.40390)
  i_perm=4:  0.00764 (r1: 0.39213)
  i_perm=5:  1.00000 (r1: 0.00000)
""")
  if (not libtbx.env.has_module("labelit")):
    print "Skipping some tests due to missing module: labelit"
  else:
    from libtbx import easy_mp
    mp_problem = easy_mp.detect_problem()
    if (mp_problem is not None):
      print "Skipping some tests:", mp_problem
    else:
      buf = run([
        "d_min=5", "lattice_symmetry=P422", "intensity_symmetry=P4",
        "index_and_integrate=True", "multiprocessing=True"])
      assert contains_substring(buf, "Refined unit cell 9 (")
      assert contains_substring(
        buf, "Correlation of input and estimated I-obs:")
      assert contains_substring(buf, "  Best correlation:  0.999")
Exemple #2
0
def exercise_explore_completeness():
    import libtbx.load_env
    if (not libtbx.env.has_module("spotfinder")):
        print("Skipping some tests due to missing module: spotfinder")
        return
    from libtbx.test_utils import contains_substring
    from libtbx import easy_run

    def run(args):
        cmd = " ".join(["rstbx.simage.explore_completeness"] + args)
        print(cmd)
        buf = easy_run.fully_buffered(
            command=cmd,
            stdout_splitlines=False).raise_if_errors().stdout_buffer
        for key in [
                "Complete with ", "Observations per reflection:", "  Median: "
        ]:
            assert contains_substring(buf, key)
        return buf

    run(["d_min=10"])
    args = ["d_min=10", "intensity_symmetry=P4", "use_symmetry=True"]
    from libtbx import easy_mp
    if (easy_mp.detect_problem() is None):
        args.append("multiprocessing=True")
    buf = run(args)
    assert contains_substring(buf, 'lattice_symmetry = "P 4 2 2"')
Exemple #3
0
def exercise_explore_completeness():
  import libtbx.load_env
  if (not libtbx.env.has_module("spotfinder")):
    print "Skipping some tests due to missing module: spotfinder"
    return
  from libtbx.test_utils import contains_substring
  from libtbx import easy_run
  def run(args):
    cmd = " ".join(["rstbx.simage.explore_completeness"] + args)
    print cmd
    buf = easy_run.fully_buffered(
      command=cmd, stdout_splitlines=False).raise_if_errors().stdout_buffer
    for key in [
          "Complete with ",
          "Observations per reflection:",
          "  Median: "]:
      assert contains_substring(buf, key)
    return buf
  run(["d_min=10"])
  args = ["d_min=10", "intensity_symmetry=P4", "use_symmetry=True"]
  from libtbx import easy_mp
  if (easy_mp.detect_problem() is None):
    args.append("multiprocessing=True")
  buf = run(args)
  assert contains_substring(buf, 'lattice_symmetry = "P 4 2 2"')
Exemple #4
0
 def run(args):
     cmd = " ".join(["rstbx.simage.solver"] + args)
     print(cmd)
     buf = easy_run.fully_buffered(
         command=cmd,
         stdout_splitlines=False).raise_if_errors().stdout_buffer
     for key in ["Final:"]:
         assert contains_substring(buf, key)
     return buf
Exemple #5
0
 def run(args):
   cmd = " ".join(["rstbx.simage.solver"] + args)
   print cmd
   buf = easy_run.fully_buffered(
     command=cmd, stdout_splitlines=False).raise_if_errors().stdout_buffer
   for key in [
         "Final:"]:
     assert contains_substring(buf, key)
   return buf
Exemple #6
0
 def run(args):
     cmd = " ".join(["rstbx.simage.explore_completeness"] + args)
     print(cmd)
     buf = easy_run.fully_buffered(
         command=cmd,
         stdout_splitlines=False).raise_if_errors().stdout_buffer
     for key in [
             "Complete with ", "Observations per reflection:", "  Median: "
     ]:
         assert contains_substring(buf, key)
     return buf
Exemple #7
0
 def run(args):
   cmd = " ".join(["rstbx.simage.explore_completeness"] + args)
   print cmd
   buf = easy_run.fully_buffered(
     command=cmd, stdout_splitlines=False).raise_if_errors().stdout_buffer
   for key in [
         "Complete with ",
         "Observations per reflection:",
         "  Median: "]:
     assert contains_substring(buf, key)
   return buf
Exemple #8
0
def test_hklinfo_run(cifstr, filename, philstr, expectedstr):
  with open(filename, "w") as fh:
    fh.write(cifstr)
  with open("philinput.txt", "w") as fh:
    fh.write(philstr)

  obj = subprocess.Popen("cctbx.HKLinfo %s philinput.txt" %filename,
                         shell=True,
                         stdin = subprocess.PIPE,
                         stdout = subprocess.PIPE,
                         stderr = subprocess.STDOUT)
  out,err = obj.communicate()
  fullstdout = out.decode().replace("\r\n", "\n") # omit \r\n line endings on Windows
  #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
  assert (contains_substring( fullstdout, expectedstr ) )
Exemple #9
0
def exercise_solver():
    import libtbx.load_env
    if (not libtbx.env.has_module("spotfinder")):
        print("Skipping some tests due to missing module: spotfinder")
        return
    from libtbx.test_utils import block_show_diff, contains_substring
    from libtbx import easy_run

    def run(args):
        cmd = " ".join(["rstbx.simage.solver"] + args)
        print(cmd)
        buf = easy_run.fully_buffered(
            command=cmd,
            stdout_splitlines=False).raise_if_errors().stdout_buffer
        for key in ["Final:"]:
            assert contains_substring(buf, key)
        return buf

    buf = run(["d_min=5"])
    assert not block_show_diff(
        buf, """\
input_im0_i_perm: 0

Correlation of input and estimated I-obs:
  i_perm=0:  1.00000 (r1: 0.00000)
""")
    buf = run(["d_min=5", "lattice_symmetry=R32:R", "intensity_symmetry=R3:R"])
    assert not block_show_diff(
        buf, """\
input_im0_i_perm: 1

Correlation of input and estimated I-obs:
  i_perm=0:  0.06799 (r1: 0.37555)
  i_perm=1:  1.00000 (r1: 0.00000)
""")
    buf = run(["d_min=5", "lattice_symmetry=R32:R", "intensity_symmetry=P1"])
    assert not block_show_diff(
        buf, """\
input_im0_i_perm: 5

Correlation of input and estimated I-obs:
  i_perm=0:  0.07524 (r1: 0.38937)
  i_perm=1: -0.02385 (r1: 0.40114)
  i_perm=2: -0.04577 (r1: 0.41742)
  i_perm=3: -0.00099 (r1: 0.40390)
  i_perm=4:  0.00764 (r1: 0.39213)
  i_perm=5:  1.00000 (r1: 0.00000)
""")
    if (not libtbx.env.has_module("labelit")):
        print("Skipping some tests due to missing module: labelit")
    else:
        from libtbx import easy_mp
        mp_problem = easy_mp.detect_problem()
        if (mp_problem is not None):
            print("Skipping some tests:", mp_problem)
        else:
            buf = run([
                "d_min=5", "lattice_symmetry=P422", "intensity_symmetry=P4",
                "index_and_integrate=True", "multiprocessing=True"
            ])
            assert contains_substring(buf, "Refined unit cell 9 (")
            assert contains_substring(
                buf, "Correlation of input and estimated I-obs:")
            assert contains_substring(buf, "  Best correlation:  0.999")