예제 #1
0
def exercise_end_of_line(exe_name, verbose):
  lines = """\
a
bc
def
ghij
klmno
""".splitlines()
  open("unix.txt", "wb").write("\n".join(lines)+"\n")
  open("dos.txt", "wb").write("\r\n".join(lines)+"\r\n")
  open("dos2.txt", "wb").write("\r\r\n".join(lines)+"\r\n")
  open("mac.txt", "wb").write("\r".join(lines)+"\r")
  from libtbx import easy_run
  from libtbx.utils import remove_files
  import os
  op = os.path
  expected_outputs = [
    "a   \nbc  \ndef \nghij\nklmn\n",
    "a   \nbc  \ndef \nghij\nklmn\n",
    "a\r  \nbc\r \ndef\r\nghij\nklmn\n",
    "a\rbc\n"]
  for vers,expected in zip(["unix", "dos", "dos2", "mac"], expected_outputs):
    remove_files(paths=["read_lines_out"])
    cmd = "%s < %s.txt > read_lines_out" % (op.join(".", exe_name), vers)
    if (verbose): print cmd
    easy_run.fully_buffered(command=cmd).raise_if_errors_or_output()
    assert op.isfile("read_lines_out")
    result = open("read_lines_out", "rb").read()
    assert result == expected.replace("\n", os.linesep)
예제 #2
0
 def run_and_check(cmd, pdbs_file, expected_out):
     abs_paths = []
     for rel_path in open(op.join(dd, pdbs_file)).read().splitlines():
         abs_paths.append(op.normpath(op.join(dd, rel_path)))
     list_of_pdbs = "list_of_pdbs_%d" % run_serial.next()
     print >> open(list_of_pdbs, "w"), "\n".join(abs_paths)
     cmd = cmd % list_of_pdbs
     if (valgrind):
         cmd = "valgrind " + cmd
     print cmd
     remove_files("out")
     if (not valgrind):
         buffers = easy_run.fully_buffered(command=cmd).raise_if_errors()
         if (expected_out is None):
             return buffers.stdout_lines
     else:
         easy_run.call(command=cmd)
         if (expected_out is None):
             return None
     filtered_lines = []
     for line in open("out").read().splitlines():
         sw = line.startswith
         if (sw("pole") or sw("members") or sw("min: ") or sw("max: ")):
             filtered_lines.append(line)
     assert not show_diff("\n".join(filtered_lines) + "\n", expected_out)
     print "OK"
예제 #3
0
def check_adp_set_b_iso(
      cmd, xrsp_init, output, selection, selection_str, verbose,
      tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  assert approx_equal(xrsp.occ,        xrsp_init.occ,tolerance)
  assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart,tolerance)
  assert approx_equal(xrsp.use_u_iso,  xrsp_init.use_u_iso,tolerance)
  assert approx_equal(xrsp.use_u_aniso,xrsp_init.use_u_aniso,tolerance)
  assert approx_equal(xrsp.u_iso_not_used,  xrsp_init.u_iso_not_used,tolerance)
  assert approx_equal(xrsp.u_cart_not_used,xrsp_init.u_cart_not_used,tolerance)
  if(selection_str is None):
    assert not_approx_equal(xrsp.u_iso_used,  xrsp_init.u_iso_used,tolerance)
    for ucart in xrsp.u_cart:
      b_iso = adptbx.u_as_b(adptbx.u_cart_as_u_iso(ucart))
      if b_iso > 0: assert approx_equal(b_iso, 10, 0.005)
      else: assert approx_equal(b_iso, -78.956, 0.005)
  else:
    arg1 = xrsp.u_iso_used.select(selection.select(xrsp.use_u_iso))
    arg2 = xrsp_init.u_iso_used.select(selection.select(xrsp_init.use_u_iso))
    if(arg1.size() > 0): assert not_approx_equal(arg1, arg2,tolerance)
    for ucart in xrsp.u_cart:
      b_iso = adptbx.u_as_b(adptbx.u_cart_as_u_iso(ucart))
      if b_iso > 0: assert approx_equal(b_iso, 10, 0.005)
      else: assert approx_equal(b_iso, -78.956, 0.005)
예제 #4
0
def check_keep_selection(cmd,
                         xrsp_init,
                         output,
                         selection,
                         selection_str,
                         keep_selection_str,
                         verbose,
                         tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    keep_selection = xrsp_init.selection(selection_strings=keep_selection_str)
    assert approx_equal(xrsp.sites_cart,
                        xrsp_init.sites_cart.select(keep_selection), tolerance)
    assert approx_equal(xrsp.occ, xrsp_init.occ.select(keep_selection),
                        tolerance)
    assert approx_equal(xrsp.u_iso, xrsp_init.u_iso.select(keep_selection),
                        tolerance)
    assert approx_equal(xrsp.u_cart, xrsp_init.u_cart.select(keep_selection),
                        tolerance)
    sct1 = xrsp_init.xray_structure.scatterers().extract_scattering_types()
    assert sct1.count("C") > 0 and sct1.size() > sct1.count("C")
    sct2 = xrsp.xray_structure.scatterers().extract_scattering_types()
    assert sct2.count("C") == sct2.size()
    assert sct1.size() > keep_selection.count(True)
    assert sct1.size() > sct2.size()
예제 #5
0
 def run_and_check(cmd, pdbs_file, expected_out):
   abs_paths = []
   for rel_path in open(op.join(dd, pdbs_file)).read().splitlines():
     abs_paths.append(op.normpath(op.join(dd, rel_path)))
   list_of_pdbs = "list_of_pdbs_%d" % run_serial.next()
   print >> open(list_of_pdbs, "w"), "\n".join(abs_paths)
   cmd = cmd % list_of_pdbs
   if (valgrind):
     cmd = "valgrind " + cmd
   print cmd
   remove_files("out")
   if (not valgrind):
     buffers = easy_run.fully_buffered(command=cmd).raise_if_errors()
     if (expected_out is None):
       return buffers.stdout_lines
   else:
     easy_run.call(command=cmd)
     if (expected_out is None):
       return None
   filtered_lines = []
   for line in open("out").read().splitlines():
     sw = line.startswith
     if (sw("pole") or sw("members") or sw("min: ") or sw("max: ")):
       filtered_lines.append(line)
   assert not show_diff("\n".join(filtered_lines)+"\n", expected_out)
   print "OK"
예제 #6
0
def check_adp_set_b_iso(cmd,
                        xrsp_init,
                        output,
                        selection,
                        selection_str,
                        verbose,
                        tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    assert approx_equal(xrsp.occ, xrsp_init.occ, tolerance)
    assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart, tolerance)
    assert approx_equal(xrsp.use_u_iso, xrsp_init.use_u_iso, tolerance)
    assert approx_equal(xrsp.use_u_aniso, xrsp_init.use_u_aniso, tolerance)
    assert approx_equal(xrsp.u_iso_not_used, xrsp_init.u_iso_not_used,
                        tolerance)
    assert approx_equal(xrsp.u_cart_not_used, xrsp_init.u_cart_not_used,
                        tolerance)
    if (selection_str is None):
        assert not_approx_equal(xrsp.u_iso_used, xrsp_init.u_iso_used,
                                tolerance)
        for ucart in xrsp.u_cart:
            b_iso = adptbx.u_as_b(adptbx.u_cart_as_u_iso(ucart))
            if b_iso > 0: assert approx_equal(b_iso, 10, 0.005)
            else: assert approx_equal(b_iso, -78.956, 0.005)
    else:
        arg1 = xrsp.u_iso_used.select(selection.select(xrsp.use_u_iso))
        arg2 = xrsp_init.u_iso_used.select(
            selection.select(xrsp_init.use_u_iso))
        if (arg1.size() > 0): assert not_approx_equal(arg1, arg2, tolerance)
        for ucart in xrsp.u_cart:
            b_iso = adptbx.u_as_b(adptbx.u_cart_as_u_iso(ucart))
            if b_iso > 0: assert approx_equal(b_iso, 10, 0.005)
            else: assert approx_equal(b_iso, -78.956, 0.005)
예제 #7
0
def exercise_end_of_line(exe_name, verbose):
    lines = """\
a
bc
def
ghij
klmno
""".splitlines()
    open("unix.txt", "wb").write("\n".join(lines) + "\n")
    open("dos.txt", "wb").write("\r\n".join(lines) + "\r\n")
    open("dos2.txt", "wb").write("\r\r\n".join(lines) + "\r\n")
    open("mac.txt", "wb").write("\r".join(lines) + "\r")
    from libtbx import easy_run
    from libtbx.utils import remove_files
    import os
    op = os.path
    expected_outputs = [
        "a   \nbc  \ndef \nghij\nklmn\n", "a   \nbc  \ndef \nghij\nklmn\n",
        "a\r  \nbc\r \ndef\r\nghij\nklmn\n", "a\rbc\n"
    ]
    for vers, expected in zip(["unix", "dos", "dos2", "mac"],
                              expected_outputs):
        remove_files(paths=["read_lines_out"])
        cmd = "%s < %s.txt > read_lines_out" % (op.join(".", exe_name), vers)
        if (verbose): print cmd
        easy_run.fully_buffered(command=cmd).raise_if_errors_or_output()
        assert op.isfile("read_lines_out")
        result = open("read_lines_out", "rb").read()
        assert result == expected.replace("\n", os.linesep)
예제 #8
0
def check_all_none(cmd, xrsp_init, output, verbose, tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  assert approx_equal(xrsp.occ,         xrsp_init.occ,tolerance)
  assert approx_equal(xrsp.sites_cart,  xrsp_init.sites_cart,tolerance)
  assert approx_equal(xrsp.use_u_iso,   xrsp_init.use_u_iso,tolerance)
  assert approx_equal(xrsp.use_u_aniso, xrsp_init.use_u_aniso,tolerance)
  assert approx_equal(xrsp.u_iso,       xrsp_init.u_iso,tolerance)
  assert approx_equal(xrsp.u_cart,      xrsp_init.u_cart,tolerance)
예제 #9
0
def test_quiet(file_name, verbose):
    output_file_name = "shifted.pdb"
    remove_files("log")
    remove_files(output_file_name)
    assert file_name.find('"') < 0
    cmd = 'phenix.pdbtools "%s" output.file_name=%s shake=0.1 --quiet > log' % (
        file_name, output_file_name)
    run_command(command=cmd, verbose=verbose)
    lines = open("log", "r").readlines()
    assert len(lines) == 0
예제 #10
0
def check_all_none(cmd, xrsp_init, output, verbose, tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    assert approx_equal(xrsp.occ, xrsp_init.occ, tolerance)
    assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart, tolerance)
    assert approx_equal(xrsp.use_u_iso, xrsp_init.use_u_iso, tolerance)
    assert approx_equal(xrsp.use_u_aniso, xrsp_init.use_u_aniso, tolerance)
    assert approx_equal(xrsp.u_iso, xrsp_init.u_iso, tolerance)
    assert approx_equal(xrsp.u_cart, xrsp_init.u_cart, tolerance)
예제 #11
0
def test_quiet(file_name, verbose):
  output_file_name = "shifted.pdb"
  remove_files("log")
  remove_files(output_file_name)
  assert file_name.find('"') < 0
  cmd= 'phenix.pdbtools "%s" output.file_name=%s shake=0.1 --quiet > log'%(
    file_name, output_file_name)
  run_command(command=cmd, verbose=verbose)
  lines = open("log","r").readlines()
  assert len(lines) == 0
예제 #12
0
def exercise_show_number_of_removed(pdb_dir, verbose):
    file_name = os.path.join(pdb_dir, "phe_h.pdb")
    log = "exercise_show_number_of_removed.log"
    assert file_name.find('"') < 0
    cmd = 'phenix.pdbtools "%s" remove="element H" > %s' % (file_name, log)
    remove_files(log)
    run_command(command=cmd, verbose=verbose)
    assert os.path.isfile(log)
    n_found = 0
    for line in open(log).read().splitlines():
        if (line == "Atoms to be kept: 13 of 24"):
            n_found += 1
    assert n_found == 1
예제 #13
0
def exercise_show_number_of_removed(pdb_dir, verbose):
  file_name = os.path.join(pdb_dir, "phe_h.pdb")
  log = "exercise_show_number_of_removed.log"
  assert file_name.find('"') < 0
  cmd = 'phenix.pdbtools "%s" remove="element H" > %s' % (file_name, log)
  remove_files(log)
  run_command(command=cmd, verbose=verbose)
  assert os.path.isfile(log)
  n_found = 0
  for line in open(log).read().splitlines():
    if (line == "Atoms to be kept: 13 of 24"):
      n_found += 1
  assert n_found == 1
예제 #14
0
def check_adp_to_iso(
      cmd, xrsp_init, output, selection, selection_str, verbose,
      tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  assert approx_equal(xrsp.occ,        xrsp_init.occ,tolerance)
  assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart,tolerance)
  assert not_approx_equal(xrsp.use_u_iso,  xrsp_init.use_u_iso,tolerance)
  assert not_approx_equal(xrsp.use_u_aniso,xrsp_init.use_u_aniso,tolerance)
  assert xrsp.u_iso_not_used.size() == 0
  assert xrsp_init.u_iso_not_used.size() > 0
  assert xrsp.u_cart_used.size() == 0
  assert xrsp_init.u_cart_used.size() > 0
예제 #15
0
def check_sites_rt(
      cmd, xrsp_init, output, selection, selection_str, verbose,
      tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  assert approx_equal(xrsp.occ,    xrsp_init.occ,tolerance)
  assert approx_equal(xrsp.u_iso,  xrsp_init.u_iso,tolerance)
  assert approx_equal(xrsp.u_cart, xrsp_init.u_cart,tolerance)
  if(selection_str is None):
    diff = xrsp.sites_cart - xrsp_init.sites_cart
    assert math.sqrt(flex.mean(diff.dot())) > 1.0
  else:
    diff = xrsp.sites_cart - xrsp_init.sites_cart
    assert math.sqrt(flex.mean(diff.select(selection).dot())) > 1.0
    assert approx_equal(
              math.sqrt(flex.mean(diff.select(~selection).dot())),0.,tolerance)
예제 #16
0
def check_adp_to_iso(cmd,
                     xrsp_init,
                     output,
                     selection,
                     selection_str,
                     verbose,
                     tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    assert approx_equal(xrsp.occ, xrsp_init.occ, tolerance)
    assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart, tolerance)
    assert not_approx_equal(xrsp.use_u_iso, xrsp_init.use_u_iso, tolerance)
    assert not_approx_equal(xrsp.use_u_aniso, xrsp_init.use_u_aniso, tolerance)
    assert xrsp.u_iso_not_used.size() == 0
    assert xrsp_init.u_iso_not_used.size() > 0
    assert xrsp.u_cart_used.size() == 0
    assert xrsp_init.u_cart_used.size() > 0
예제 #17
0
def check_occ_randomize(
      cmd, xrsp_init, output, selection,selection_str, verbose,
      tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  assert approx_equal(xrsp.sites_cart,xrsp_init.sites_cart,tolerance)
  assert approx_equal(xrsp.u_iso,     xrsp_init.u_iso,tolerance)
  assert approx_equal(xrsp.u_cart,    xrsp_init.u_cart,tolerance)
  if(selection_str is None):
    diff = flex.abs(xrsp.occ - xrsp_init.occ)
    assert flex.mean(diff) > 0.0
    assert flex.max(diff) > 0.0
  else:
    diff = flex.abs(xrsp.occ - xrsp_init.occ)
    assert flex.mean(diff) > 0.0
    assert flex.max(diff) > 0.0
    assert approx_equal(flex.mean(diff.select(~selection)),0.,tolerance)
예제 #18
0
def check_keep_selection(
      cmd, xrsp_init, output, selection, selection_str,
      keep_selection_str, verbose, tolerance=1.e-3):
  remove_files(output)
  run_command(command=cmd, verbose=verbose)
  xrsp = xray_structure_plus(file_name = output)
  keep_selection = xrsp_init.selection(selection_strings = keep_selection_str)
  assert approx_equal(xrsp.sites_cart,
                      xrsp_init.sites_cart.select(keep_selection),tolerance)
  assert approx_equal(xrsp.occ, xrsp_init.occ.select(keep_selection),tolerance)
  assert approx_equal(
    xrsp.u_iso, xrsp_init.u_iso.select(keep_selection),tolerance)
  assert approx_equal(
    xrsp.u_cart, xrsp_init.u_cart.select(keep_selection),tolerance)
  sct1 = xrsp_init.xray_structure.scatterers().extract_scattering_types()
  assert sct1.count("C") > 0 and sct1.size() > sct1.count("C")
  sct2 = xrsp.xray_structure.scatterers().extract_scattering_types()
  assert sct2.count("C") == sct2.size()
  assert sct1.size() > keep_selection.count(True)
  assert sct1.size() > sct2.size()
예제 #19
0
def check_sites_rt(cmd,
                   xrsp_init,
                   output,
                   selection,
                   selection_str,
                   verbose,
                   tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    assert approx_equal(xrsp.occ, xrsp_init.occ, tolerance)
    assert approx_equal(xrsp.u_iso, xrsp_init.u_iso, tolerance)
    assert approx_equal(xrsp.u_cart, xrsp_init.u_cart, tolerance)
    if (selection_str is None):
        diff = xrsp.sites_cart - xrsp_init.sites_cart
        assert math.sqrt(flex.mean(diff.dot())) > 1.0
    else:
        diff = xrsp.sites_cart - xrsp_init.sites_cart
        assert math.sqrt(flex.mean(diff.select(selection).dot())) > 1.0
        assert approx_equal(
            math.sqrt(flex.mean(diff.select(~selection).dot())), 0., tolerance)
예제 #20
0
def check_occ_randomize(cmd,
                        xrsp_init,
                        output,
                        selection,
                        selection_str,
                        verbose,
                        tolerance=1.e-3):
    remove_files(output)
    run_command(command=cmd, verbose=verbose)
    xrsp = xray_structure_plus(file_name=output)
    assert approx_equal(xrsp.sites_cart, xrsp_init.sites_cart, tolerance)
    assert approx_equal(xrsp.u_iso, xrsp_init.u_iso, tolerance)
    assert approx_equal(xrsp.u_cart, xrsp_init.u_cart, tolerance)
    if (selection_str is None):
        diff = flex.abs(xrsp.occ - xrsp_init.occ)
        assert flex.mean(diff) > 0.0
        assert flex.max(diff) > 0.0
    else:
        diff = flex.abs(xrsp.occ - xrsp_init.occ)
        assert flex.mean(diff) > 0.0
        assert flex.max(diff) > 0.0
        assert approx_equal(flex.mean(diff.select(~selection)), 0., tolerance)
예제 #21
0
 def build(O,
       link,
       file_name_cpp,
       obj_name=None,
       exe_name=None,
       pch_name=None,
       disable_warnings=False,
       show_command=False,
       Error=RuntimeError):
   assert [obj_name, exe_name, pch_name].count(None) >= 2
   if (link):
     out_name = exe_name
     out_suffix = O.exe_suffix
   elif (pch_name is None):
     out_name = obj_name
     out_suffix = O.obj_suffix
   else:
     assert O.pch_suffix is not None
     out_name = pch_name + O.pch_suffix
     out_suffix = None
   if (out_name is None):
     assert file_name_cpp.endswith(".cpp")
     out_name = file_name_cpp[:-4] + out_suffix
   from libtbx.utils import remove_files
   remove_files(out_name)
   cmd = O.assemble_command(
     link=link,
     disable_warnings=disable_warnings,
     file_names=[file_name_cpp],
     out_name=out_name)
   if (show_command):
     print cmd
   from libtbx import easy_run
   buffers = easy_run.fully_buffered(command=cmd)
   if (O.compiler != "cl" or buffers.stderr_lines != [file_name_cpp]):
     buffers.raise_if_errors(Error=Error)
   return out_name
예제 #22
0
 def build(O,
           link,
           file_name_cpp,
           obj_name=None,
           exe_name=None,
           pch_name=None,
           disable_warnings=False,
           show_command=False,
           Error=RuntimeError):
     assert [obj_name, exe_name, pch_name].count(None) >= 2
     if (link):
         out_name = exe_name
         out_suffix = O.exe_suffix
     elif (pch_name is None):
         out_name = obj_name
         out_suffix = O.obj_suffix
     else:
         assert O.pch_suffix is not None
         out_name = pch_name + O.pch_suffix
         out_suffix = None
     if (out_name is None):
         assert file_name_cpp.endswith(".cpp")
         out_name = file_name_cpp[:-4] + out_suffix
     from libtbx.utils import remove_files
     remove_files(out_name)
     cmd = O.assemble_command(link=link,
                              disable_warnings=disable_warnings,
                              file_names=[file_name_cpp],
                              out_name=out_name)
     if (show_command):
         print cmd
     from libtbx import easy_run
     buffers = easy_run.fully_buffered(command=cmd)
     if (O.compiler != "cl" or buffers.stderr_lines != [file_name_cpp]):
         buffers.raise_if_errors(Error=Error)
     return out_name
예제 #23
0
def run(args):
    assert len(args) == 0
    tmpdir = "scitbx_rigid_body_essence"
    if (not os.path.isdir(tmpdir)):
        os.mkdir(tmpdir)
    os.chdir(tmpdir)
    scitbx_dist = libtbx.env.dist_path(module_name="scitbx")

    def cp(file_name, target="."):
        copy_file(os.path.join(scitbx_dist, file_name), target)

    cp("matrix/__init__.py", "scitbx_matrix.py")
    cp("rigid_body/essence/featherstone.py")
    cp("rigid_body/essence/spatial_lib.py")
    cp("rigid_body/essence/joint_lib.py")
    cp("rigid_body/essence/body_lib.py")
    cp("rigid_body/essence/tst_basic.py")
    open("README.txt", "w").write(__doc__)
    os.chdir("..")
    if (os.name == "nt" or not libtbx.env.has_module(name="docutils")):
        return
    remove_files("scitbx_rigid_body_essence.tgz")
    remove_files("scitbx_rigid_body_essence.zip")
    easy_run.fully_buffered(
      command="tar zcf scitbx_rigid_body_essence.tgz scitbx_rigid_body_essence")\
        .raise_if_errors_or_output()
    assert os.path.isfile("scitbx_rigid_body_essence.tgz")
    easy_run.fully_buffered(
      command="zip -r scitbx_rigid_body_essence.zip scitbx_rigid_body_essence")\
        .raise_if_errors()
    assert os.path.isfile("scitbx_rigid_body_essence.zip")
    os.chdir("scitbx_rigid_body_essence")
    easy_run.fully_buffered(
      command="docutils.rst2html README.txt > README.html")\
        .raise_if_errors()
    remove_files("README.txt")
    print >> open(".htaccess", "w").write("""\
Options Indexes
""")
예제 #24
0
def run(args):
  assert len(args) == 0
  tmpdir = "scitbx_rigid_body_essence"
  if (not os.path.isdir(tmpdir)):
    os.mkdir(tmpdir)
  os.chdir(tmpdir)
  scitbx_dist = libtbx.env.dist_path(module_name="scitbx")
  def cp(file_name, target="."):
    copy_file(os.path.join(scitbx_dist, file_name), target)
  cp("matrix/__init__.py", "scitbx_matrix.py")
  cp("rigid_body/essence/featherstone.py")
  cp("rigid_body/essence/spatial_lib.py")
  cp("rigid_body/essence/joint_lib.py")
  cp("rigid_body/essence/body_lib.py")
  cp("rigid_body/essence/tst_basic.py")
  open("README.txt", "w").write(__doc__)
  os.chdir("..")
  if (   os.name == "nt"
      or not libtbx.env.has_module(name="docutils")):
    return
  remove_files("scitbx_rigid_body_essence.tgz")
  remove_files("scitbx_rigid_body_essence.zip")
  easy_run.fully_buffered(
    command="tar zcf scitbx_rigid_body_essence.tgz scitbx_rigid_body_essence")\
      .raise_if_errors_or_output()
  assert os.path.isfile("scitbx_rigid_body_essence.tgz")
  easy_run.fully_buffered(
    command="zip -r scitbx_rigid_body_essence.zip scitbx_rigid_body_essence")\
      .raise_if_errors()
  assert os.path.isfile("scitbx_rigid_body_essence.zip")
  os.chdir("scitbx_rigid_body_essence")
  easy_run.fully_buffered(
    command="docutils.rst2html README.txt > README.html")\
      .raise_if_errors()
  remove_files("README.txt")
  print >> open(".htaccess", "w").write("""\
Options Indexes
""")