def exercise():
  if (iotbx_mtz is None):
    print \
      "Skipping iotbx/examples/tst_mtz_free_flipper.py: ccp4io not available"
    return
  input_file_name = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/reflection_files/l.mtz",
    test=os.path.isfile)
  if (input_file_name is None):
    print "Skipping exercise(): input file not available"
    return
  label = "R-free-flags(-)"
  mtz_free_flipper.run(args=[input_file_name], label=label)
  mtz_free_flipper.run(args=["free_flipped_l.mtz"], label=label)
  mtz_convert_free_to_work.run(args=[input_file_name], label=label)
  spreadsheets = []
  for file_name, expected in [
        (input_file_name, (13469,1065,2323)),
        ("free_flipped_l.mtz", (1065,13469,2323)),
        ("free_flipped_free_flipped_l.mtz", (13469,1065,2323)),
        ("less_free_l.mtz", (14002,532,2323))]:
    s = StringIO()
    mtz_obj = iotbx_mtz.object(file_name=file_name)
    mtz_obj.show_column_data(out=s, format="spreadsheet")
    s = s.getvalue()
    spreadsheets.append(s)
    n_0, n_1, n_rest = 0, 0, 0
    for line in s.splitlines()[1:]:
      if (line.endswith(",0")): n_0 += 1
      elif (line.endswith(",1")): n_1 += 1
      else:
        assert line.endswith(",")
        n_rest += 1
    assert mtz_obj.n_reflections() == n_0 + n_1 + n_rest
    assert (n_0, n_1, n_rest) == expected
  assert not show_diff(spreadsheets[0], spreadsheets[2])
  assert spreadsheets[0] != spreadsheets[1]
Example #2
0
            msg.warning('problem while dumping joboption file to [%s]:\n%s',
                        dump_jobo, err)

    from collections import namedtuple
    Options = namedtuple('Options',
                         'oname use_recex_links do_clean_up athena_opts')
    opts = Options(oname=output,
                   use_recex_links=use_recex_links,
                   do_clean_up=do_clean_up,
                   athena_opts=athena_opts)
    
    sc, out = 1, "<N/A>"
    msg.info('running dumper...')
    sc,out = _run_jobo(jobo, msg, opts)
    msg.info('dumper done')
    if output != os.devnull:
        msg.info('writing logfile: %s.log', output)
        try:
            with open('%s.log'%output, 'w') as f:
                for l in out.splitlines():
                    print >> f, l
                print >> f, "### EOF ###"
            
        except Exception, err:
            msg.warning('problem writing out logfile [%s.log]:\n%s',
                        output, err)

    msg.info('bye.')
    msg.info(':'*40)
    return sc, out