def exercise_xds_input(): xds_file = libtbx.env.find_in_repositories( relative_path= "phenix_regression/reflection_files/xds_correct_unmerged.hkl", test=os.path.isfile) if (xds_file is None): print "phenix_regression not available, skipping exercise_xds_input" return False xds_in = file_reader.any_file(xds_file) wl = xds_in.file_server.miller_arrays[0].info().wavelength p = reflection_file_editor.run(args=[ xds_file, "output_file=xds.mtz", ], out=null_out()) mtz_in = file_reader.any_file("xds.mtz") wl2 = mtz_in.file_server.miller_arrays[0].info().wavelength assert approx_equal(wl, wl2) p = reflection_file_editor.run(args=[ xds_file, "output_file=xds.mtz", "wavelength=0.9792", ], out=null_out()) mtz_in = file_reader.any_file("xds.mtz") wl2 = mtz_in.file_server.miller_arrays[0].info().wavelength assert approx_equal(wl2, 0.9792)
def exercise_xds_input () : xds_file = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/xds_correct_unmerged.hkl", test=os.path.isfile) if (xds_file is None) : print "phenix_regression not available, skipping exercise_xds_input" return False xds_in = file_reader.any_file(xds_file) wl = xds_in.file_server.miller_arrays[0].info().wavelength p = reflection_file_editor.run( args=[xds_file, "output_file=xds.mtz",], out=null_out()) mtz_in = file_reader.any_file("xds.mtz") wl2 = mtz_in.file_server.miller_arrays[0].info().wavelength assert approx_equal(wl, wl2) p = reflection_file_editor.run( args=[xds_file, "output_file=xds.mtz", "wavelength=0.9792",], out=null_out()) mtz_in = file_reader.any_file("xds.mtz") wl2 = mtz_in.file_server.miller_arrays[0].info().wavelength assert approx_equal(wl2, 0.9792)
def exercise_command_line(): if (not libtbx.env.has_module("phenix_regression")): print "phenix_regression not available, skipping" return file1 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk.mtz", test=os.path.isfile) file2 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk_r1A.mtz", test=os.path.isfile) log = null_out() test_file = "tst_hkl_editor_cmdline-1.mtz" test_file2 = "tst_hkl_editor_cmdline-2.mtz" if os.path.exists(test_file2): os.remove(test_file2) try: p = reflection_file_editor.run(args=[file1, file2, "dry_run=True"], out=log) except Sorry, e: assert str(e).startswith("Duplicate column label 'R-free-flags'.")
def exercise_command_line () : if (not libtbx.env.has_module("phenix_regression")) : print "phenix_regression not available, skipping" return file1 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk.mtz", test=os.path.isfile) file2 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk_r1A.mtz", test=os.path.isfile) log = null_out() test_file = "tst_hkl_editor_cmdline-1.mtz" test_file2 = "tst_hkl_editor_cmdline-2.mtz" if os.path.exists(test_file2) : os.remove(test_file2) try : p = reflection_file_editor.run( args=[file1, file2, "dry_run=True"], out=log) except Sorry, e : assert str(e).startswith("Duplicate column label 'R-free-flags'.")
test=os.path.isfile) log = null_out() test_file = "tst_hkl_editor_cmdline-1.mtz" test_file2 = "tst_hkl_editor_cmdline-2.mtz" if os.path.exists(test_file2): os.remove(test_file2) try: p = reflection_file_editor.run(args=[file1, file2, "dry_run=True"], out=log) except Sorry, e: assert str(e).startswith("Duplicate column label 'R-free-flags'.") else: raise Exception_expected p = reflection_file_editor.run(args=[ file1, file2, "dry_run=True", "resolve_label_conflicts=True", "output_file=%s" % test_file ], out=log) assert ([c.label() for c in p.mtz_object.columns()] == [ 'H', 'K', 'L', 'I-obs', 'SIGI-obs', 'F-obs', 'R-free-flags', 'R-free-flags_2' ]) p.finish() mtz_in = file_reader.any_file(test_file) miller_arrays = mtz_in.file_object.as_miller_arrays() flags1 = miller_arrays[-2] assert flags1.info().label_string() == "R-free-flags" (d_max, d_min) = flags1.d_max_min() assert (approx_equal(d_max, 11.14, eps=0.01) and approx_equal(d_min, 1.503, eps=0.01)) flags2 = miller_arrays[-1]
def exercise_command_line(): if (not libtbx.env.has_module("phenix_regression")): print("phenix_regression not available, skipping") return file1 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk.mtz", test=os.path.isfile) file2 = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/enk_r1A.mtz", test=os.path.isfile) log = null_out() test_file = "tst_hkl_editor_cmdline-1.mtz" test_file2 = "tst_hkl_editor_cmdline-2.mtz" if os.path.exists(test_file2): os.remove(test_file2) try: p = reflection_file_editor.run(args=[file1, file2, "dry_run=True"], out=log) except Sorry as e: assert str(e).startswith("Duplicate column label 'R-free-flags'.") else: raise Exception_expected p = reflection_file_editor.run(args=[ file1, file2, "dry_run=True", "resolve_label_conflicts=True", "output_file=%s" % test_file ], out=log) assert ([c.label() for c in p.mtz_object.columns()] == [ 'H', 'K', 'L', 'I-obs', 'SIGI-obs', 'F-obs', 'R-free-flags', 'R-free-flags_2' ]) p.finish() mtz_in = file_reader.any_file(test_file) miller_arrays = mtz_in.file_object.as_miller_arrays() flags1 = miller_arrays[-2] assert flags1.info().label_string() == "R-free-flags" (d_max, d_min) = flags1.d_max_min() assert (approx_equal(d_max, 11.14, eps=0.01) and approx_equal(d_min, 1.503, eps=0.01)) flags2 = miller_arrays[-1] assert flags2.info().label_string() == "R-free-flags_2" (d_max, d_min) = flags2.d_max_min() assert (approx_equal(d_max, 11.14, eps=0.01) and approx_equal(d_min, 1.00, eps=0.01)) p = reflection_file_editor.run(args=[ file1, file2, "resolve_label_conflicts=True", "extend=True", "output_file=%s" % test_file ], out=log) mtz_in = file_reader.any_file(test_file) miller_arrays = mtz_in.file_object.as_miller_arrays() (d_max_first, d_min_first) = miller_arrays[1].d_max_min() (d_max_last, d_min_last) = miller_arrays[-1].d_max_min() assert (d_max_first <= d_max_last) assert (d_min_first == d_min_last) #os.remove(test_file) old_r_free_1 = miller_arrays[-2] old_r_free_2 = miller_arrays[-1] # export to CCP4 convention p = reflection_file_editor.run(args=[ file1, file2, "resolve_label_conflicts=True", "extend=False", "export_for_ccp4=False", "output_file=%s" % test_file ], out=log) mtz_in = file_reader.any_file(test_file) miller_arrays = mtz_in.file_object.as_miller_arrays() # os.remove(test_file) assert miller_arrays[-2].info().label_string() == "R-free-flags" assert miller_arrays[-1].info().label_string() == "R-free-flags_2" old_r_free_1 = miller_arrays[-2] old_r_free_2 = miller_arrays[-1] p = reflection_file_editor.run(args=[ file1, file2, "resolve_label_conflicts=True", "extend=False", "export_for_ccp4=True", "preserve_input_values=False", "output_file=%s" % test_file2 ], out=log) mtz_in = file_reader.any_file(test_file2) miller_arrays = mtz_in.file_object.as_miller_arrays() assert (len(set(miller_arrays[-2].data())) == 5) assert (len(set(miller_arrays[-1].data())) == 10) old_flags_1 = (old_r_free_1.data() == 1) old_flags_2 = (old_r_free_2.data() == 1) new_flags_1 = (miller_arrays[-2].data() == 0) new_flags_2 = (miller_arrays[-1].data() == 0) #.select(old_flags_2) assert (old_flags_1 == new_flags_1).count(False) == 0 assert (old_flags_2 == new_flags_2).count(False) == 0 cns_file = libtbx.env.find_in_repositories( relative_path="phenix_regression/reflection_files/l.cv", test=os.path.isfile) p = reflection_file_editor.run(args=[ cns_file, "space_group=P212121", "output_file=l_new.mtz", "unit_cell=28.17,52.857,68.93,90,90,90" ], out=log) mtz_in = file_reader.any_file("l_new.mtz") assert (mtz_in.file_server.miller_arrays[0].info().labels == [ 'F_INFL(+)', 'S_INFL(+)', 'F_INFL(-)', 'S_INFL(-)' ])
from __future__ import division import sys from iotbx import reflection_file_editor if __name__ == "__main__": reflection_file_editor.run(sys.argv[1:])
test=os.path.isfile) log = null_out() test_file = "tst_hkl_editor_cmdline-1.mtz" test_file2 = "tst_hkl_editor_cmdline-2.mtz" if os.path.exists(test_file2) : os.remove(test_file2) try : p = reflection_file_editor.run( args=[file1, file2, "dry_run=True"], out=log) except Sorry, e : assert str(e).startswith("Duplicate column label 'R-free-flags'.") else : raise Exception_expected p = reflection_file_editor.run( args=[file1, file2, "dry_run=True", "resolve_label_conflicts=True", "output_file=%s" % test_file], out=log) assert ([ c.label() for c in p.mtz_object.columns() ] == ['H','K','L','I-obs','SIGI-obs','F-obs','R-free-flags','R-free-flags_2']) p.finish() mtz_in = file_reader.any_file(test_file) miller_arrays = mtz_in.file_object.as_miller_arrays() flags1 = miller_arrays[-2] assert flags1.info().label_string() == "R-free-flags" (d_max, d_min) = flags1.d_max_min() assert (approx_equal(d_max, 11.14, eps=0.01) and approx_equal(d_min, 1.503, eps=0.01)) flags2 = miller_arrays[-1] assert flags2.info().label_string() == "R-free-flags_2" (d_max, d_min) = flags2.d_max_min() assert (approx_equal(d_max, 11.14, eps=0.01) and
from __future__ import division import sys from iotbx import reflection_file_editor if __name__ == "__main__" : reflection_file_editor.run(sys.argv[1:])