def exercise_with_tst_input_map_2(use_mrcfile=None,file_name=None): if not file_name: file_name = libtbx.env.under_dist( module_name="iotbx", path="ccp4_map/ccp4_20_21_22_to_30_40_50.ccp4") print("\nTesting read of input map with offset origin and axis order 3 1 2 "+\ "\n and use_mrcfile=",use_mrcfile) if use_mrcfile: m = mrcfile.map_reader(file_name=file_name,verbose=True) else: m = iotbx.ccp4_map.map_reader(file_name=file_name) print(m.unit_cell_grid,m.map_data().origin(),m.map_data().all(),m.unit_cell().parameters(), end=' ') assert m.unit_cell_grid == (55, 59, 61) assert approx_equal(m.unit_cell().parameters(), (24.53101921081543, 24.61971664428711, 26.457056045532227, 90.0, 90.0, 90.0)) assert m.map_data().origin() == (20, 21, 22) assert m.map_data().all() == (11, 20, 29)
def exercise_with_tst_input_map(use_mrcfile=None,file_name=None): if not file_name: file_name = libtbx.env.under_dist( module_name="iotbx", path="ccp4_map/tst_input.map") print("\nTesting read of input map with axis order 3 1 2 "+\ "\n and use_mrcfile=",use_mrcfile) if use_mrcfile: m = mrcfile.map_reader(file_name=file_name,verbose=True) for label in m.labels: print(label) else: m = iotbx.ccp4_map.map_reader(file_name=file_name) assert approx_equal(m.header_min, -0.422722190619) assert approx_equal(m.header_max, 0.335603952408) assert approx_equal(m.header_mean, 0) assert approx_equal(m.header_rms, 0.140116646886) assert m.unit_cell_grid == (16, 8, 16) assert approx_equal(m.unit_cell().parameters(), ( 82.095001220703125, 37.453998565673828, 69.636001586914062, 90.0, 101.47599792480469, 90.0)) assert m.unit_cell_crystal_symmetry().space_group_number()==5 assert m.map_data().origin() == (0, 0, 0) assert m.map_data().all() == (16, 8, 16) assert approx_equal(m.pixel_sizes(),(5.130937576293945, 4.6817498207092285, 4.352250099182129)) assert not m.map_data().is_padded() out = StringIO() m.show_summary(out=out) assert ("map cell grid: (16, 8, 16)" in out.getvalue()) uc = m.unit_cell_crystal_symmetry().unit_cell() assert approx_equal(m.unit_cell().parameters(), m.unit_cell().parameters()) assert approx_equal(m.grid_unit_cell().parameters(), (5.13094, 4.68175, 4.35225, 90, 101.476, 90)) # Read and write map with offset print("\nReading and writing map with origin not at zero, use_mrcfile=",use_mrcfile) from scitbx.array_family.flex import grid from scitbx.array_family import flex from cctbx import uctbx, sgtbx real_map=m.map_data().as_double() grid_start=(5,5,5) grid_end=(9,10,11) if use_mrcfile: iotbx.mrcfile.write_ccp4_map( file_name="shifted_map.mrc", unit_cell=uctbx.unit_cell(m.unit_cell().parameters()), space_group=sgtbx.space_group_info("P1").group(), gridding_first=grid_start, gridding_last=grid_end, map_data=real_map, labels=flex.std_string(["iotbx.ccp4_map.tst"]), verbose=True) m = mrcfile.map_reader(file_name='shifted_map.mrc',verbose=True) else: iotbx.ccp4_map.write_ccp4_map( file_name="shifted_map.ccp4", unit_cell=uctbx.unit_cell(m.unit_cell().parameters()), space_group=sgtbx.space_group_info("P1").group(), gridding_first=grid_start, gridding_last=grid_end, map_data=real_map, labels=flex.std_string(["iotbx.ccp4_map.tst"])) m = iotbx.ccp4_map.map_reader(file_name='shifted_map.ccp4') print(m.map_data().origin(),m.map_data().all()) print("GRID:",m.unit_cell_grid) assert m.unit_cell_grid == (16, 8, 16) assert approx_equal(m.unit_cell().parameters(), ( 82.095001220703125, 37.453998565673828, 69.636001586914062, 90.0, 101.47599792480469, 90.0)) assert m.unit_cell_crystal_symmetry().space_group_number()== 1 print(m.map_data().origin(),m.map_data().all()) assert m.map_data().origin() == (5,5,5) assert m.map_data().all() == (5,6,7)