def exercise(): from cctbx import xray from cctbx import crystal from cctbx.array_family import flex sc = xray.scatterer xs = xray.structure( # COD entry 2103456, selected atoms crystal_symmetry=crystal.symmetry(unit_cell=(10.1053, 10.1053, 10.1053, 90, 90, 90), space_group_symbol="P 21 3"), scatterers=flex.xray_scatterer((sc(label='ER1', site=(-0.16698, 0.66698, 0.33302)), sc(label='ER2', site=(0.39957, 0.60043, 0.10043))))) # from iotbx.shelx import fvar_encoding xsm = fvar_encoding.move_sites_if_necessary_for_shelx_fvar_encoding(xs) from six.moves import cStringIO as StringIO sio = StringIO() xsm.show_scatterers(f=sio) from libtbx.test_utils import show_diff assert not show_diff( sio.getvalue(), """\ Label, Scattering, Multiplicity, Coordinates, Occupancy, Uiso, Ustar as Uiso ER1 Er 4 (-0.1670 -0.3330 0.3330) 1.00 0.0000 [ - ] ER2 Er 4 ( 0.3996 -0.3996 0.1004) 1.00 0.0000 [ - ] """) # from iotbx.shelx.errors import error from libtbx.test_utils import Exception_expected, approx_equal try: fvar_encoding.dev_build_shelx76_fvars(xs) except error: pass else: raise Exception_expected # fvars, encoded_sites = fvar_encoding.dev_build_shelx76_fvars(xsm) assert approx_equal(fvars, [1, 0.33396, 0.79914]) assert approx_equal(encoded_sites, [[19.5, -19.5, -20.5], [30.5, 29.5, -30.5]])
def process(params, pickle_file_name): cod_id = op.basename(pickle_file_name).split(".", 1)[0] print "cod_id:", cod_id c_obs, structure_prep, edge_list = easy_pickle.load( file_name=pickle_file_name) changes = structure_prep.make_scatterer_labels_shelx_compatible_in_place() if (params.sites_mod_short): structure_prep = structure_prep.sites_mod_short() from iotbx.shelx import fvar_encoding structure_prep = \ fvar_encoding.move_sites_if_necessary_for_shelx_fvar_encoding( xray_structure=structure_prep) structure_prep.show_summary().show_scatterers() if (len(changes) != 0): from libtbx.utils import plural_s print "INFO: %d atom name%s changed for compatibility with SHELXL:" \ % plural_s(len(changes)) for change in changes: print ' changed: "%s" -> "%s"' % change structure_prep.scattering_type_registry(table="it1992").show() fvar_encoding.dev_build_shelx76_fvars(structure_prep) # only an exercise print "." * 79 # if (len(params.optimizers) == 0): return # assert c_obs.is_xray_intensity_array() or c_obs.is_xray_amplitude_array() if (c_obs.is_xray_intensity_array()): i_obs = c_obs f_obs = c_obs.f_sq_as_f(algorithm="xtal_3_7") else: f_obs = c_obs i_obs = c_obs.f_as_f_sq(algorithm="shelxl") process_continue(params=params, cod_id=cod_id, c_obs=c_obs, i_obs=i_obs, f_obs=f_obs, structure_prep=structure_prep)
def process(params, pickle_file_name): cod_id = op.basename(pickle_file_name).split(".",1)[0] print "cod_id:", cod_id c_obs, structure_prep, edge_list = easy_pickle.load( file_name=pickle_file_name) changes = structure_prep.make_scatterer_labels_shelx_compatible_in_place() if (params.sites_mod_short): structure_prep = structure_prep.sites_mod_short() from iotbx.shelx import fvar_encoding structure_prep = \ fvar_encoding.move_sites_if_necessary_for_shelx_fvar_encoding( xray_structure=structure_prep) structure_prep.show_summary().show_scatterers() if (len(changes) != 0): from libtbx.utils import plural_s print "INFO: %d atom name%s changed for compatibility with SHELXL:" \ % plural_s(len(changes)) for change in changes: print ' changed: "%s" -> "%s"' % change structure_prep.scattering_type_registry(table="it1992").show() fvar_encoding.dev_build_shelx76_fvars(structure_prep) # only an exercise print "."*79 # if (len(params.optimizers) == 0): return # assert c_obs.is_xray_intensity_array() or c_obs.is_xray_amplitude_array() if (c_obs.is_xray_intensity_array()): i_obs = c_obs f_obs = c_obs.f_sq_as_f(algorithm="xtal_3_7") else: f_obs = c_obs i_obs = c_obs.f_as_f_sq(algorithm="shelxl") process_continue( params=params, cod_id=cod_id, c_obs=c_obs, i_obs=i_obs, f_obs=f_obs, structure_prep=structure_prep)
def exercise(): from cctbx import xray from cctbx import crystal from cctbx.array_family import flex sc = xray.scatterer xs = xray.structure( # COD entry 2103456, selected atoms crystal_symmetry=crystal.symmetry( unit_cell=(10.1053, 10.1053, 10.1053, 90, 90, 90), space_group_symbol="P 21 3"), scatterers=flex.xray_scatterer(( sc(label='ER1', site=(-0.16698, 0.66698, 0.33302)), sc(label='ER2', site=(0.39957, 0.60043, 0.10043))))) # from iotbx.shelx import fvar_encoding xsm = fvar_encoding.move_sites_if_necessary_for_shelx_fvar_encoding(xs) from cStringIO import StringIO sio = StringIO() xsm.show_scatterers(f=sio) from libtbx.test_utils import show_diff assert not show_diff(sio.getvalue(), """\ Label, Scattering, Multiplicity, Coordinates, Occupancy, Uiso, Ustar as Uiso ER1 Er 4 (-0.1670 -0.3330 0.3330) 1.00 0.0000 [ - ] ER2 Er 4 ( 0.3996 -0.3996 0.1004) 1.00 0.0000 [ - ] """) # from iotbx.shelx.errors import error from libtbx.test_utils import Exception_expected, approx_equal try: fvar_encoding.dev_build_shelx76_fvars(xs) except error: pass else: raise Exception_expected # fvars, encoded_sites = fvar_encoding.dev_build_shelx76_fvars(xsm) assert approx_equal(fvars, [1, 0.33396, 0.79914]) assert approx_equal(encoded_sites, [[19.5, -19.5, -20.5], [30.5, 29.5, -30.5]])