def load_xmap_from_ccp4(event_map_path): xmap = clipper.Xmap_float() ccp4_file = clipper.CCP4MAPfile() ccp4_file.open_read(event_map_path) ccp4_file.import_xmap_float(xmap) ccp4_file.close_read() return xmap
def transform_fft(hkl_info, hkl_data): grid = clipper.Grid_sampling(hkl_info.spacegroup, hkl_info.cell, hkl_info.resolution) xmap = clipper.Xmap_float(hkl_info.spacegroup, hkl_info.cell, grid) xmap.fft_from(hkl_data) return xmap, grid
def b_factor_smoothing_real_space( reference_reflections: Reflections, reflections: Reflections, ): print("Reference_res: {}; Res: {}".format( reference_reflections.hkl_info.resolution.limit, reflections.hkl_info.resolution.limit, )) if reference_reflections.hkl_info.resolution.limit < reflections.hkl_info.resolution.limit: raise AssertionError( "Reference reflections MUST be lower than reflections resolution") spacegroup = reference_reflections.hkl_info.spacegroup cell = reference_reflections.hkl_info.cell sample_res = reference_reflections.hkl_info.resolution grid = clipper_python.Grid_sampling( spacegroup, cell, sample_res, ) xmap_reference = clipper_python.Xmap_float( spacegroup, cell, grid, ) xmap_reference.fft_from(reference_reflections.hkl_data) xmap = clipper_python.Xmap_float( spacegroup, cell, grid, ) xmap.fft_from(reflections.hkl_data) xmap_reference_np = xmap_reference.export_numpy() xmap_np = xmap.export_numpy() print(xmap_reference_np.shape) print(xmap_np.shape) # optimise blur of xmap # target_func = ndimage.gaussian_filter()
def load_ccp4_map(ccp4_path): print("Opening XMAP") xmap = clipper_python.Xmap_float() print("starting map file") mapout = clipper_python.CCP4MAPfile() print("opening read") mapout.open_read(str(ccp4_path)) print("importing xmap") mapout.import_xmap_float(xmap) print("closing read") mapout.close_read() return xmap
def transform_fft(hkl_info, hkl_data): grid = clipper.Grid_sampling(hkl_info.spacegroup, hkl_info.cell, hkl_info.resolution) # print("Making sampling grid") xmap = clipper.Xmap_float(hkl_info.spacegroup, hkl_info.cell, grid) xmap.fft_from(hkl_data) # print("fft'd") # map_numpy = np.zeros((xmap.grid_asu.nu(), xmap.grid_asu.nv(), xmap.grid_asu.nw()), dtype='double') # # xmap.export_numpy(map_numpy) # return map_numpy return xmap, grid
def align_structures(ref_structure, mobile_structure, mobile_xmap): # translation_mobile_to_ref = ref_structure.atoms.center_of_mass() - mobile_structure.atoms.center_of_mass() # # # mobile0 = mobile_structure.select_atoms('name CA').positions - mobile_structure.atoms.center_of_mass() # ref0 = ref_structure.select_atoms('name CA').positions - ref_structure.atoms.center_of_mass() # rotation_mobile_to_ref, rmsd = align.rotation_matrix(mobile0, ref0) ref_atoms = [] alt_atoms = [] for (ref_model, alt_model) in zip(ref_structure, mobile_structure): for (ref_chain, alt_chain) in zip(ref_model, alt_model): for ref_res, alt_res in zip(ref_chain, alt_chain): # CA = alpha carbon try: # print("\tModel: {}".format(ref_model)) # print("\tChain: {}".format(ref_chain)) # print("\tResidue: {}".format(ref_res)) # print(ref_res) # print(dir(ref_res)) # print([x for x in ref_res.get_atoms()]) ref_atoms.append(ref_res['CA']) alt_atoms.append(alt_res['CA']) except: pass super_imposer = PDB.Superimposer() super_imposer.set_atoms( ref_atoms, alt_atoms, ) translation_mobile_to_ref = super_imposer.rotran[1] rotation_mobile_to_ref = super_imposer.rotran[0] # print("\tTranslation is: {}".format(translation_mobile_to_ref)) # print("\tRotation is: {}".format(rotation_mobile_to_ref)) # xmap_np = interpolate_uniform_grid(mobile_xmap, # translation_mobile_to_ref, # np.transpose(rotation_mobile_to_ref), # ) rtop = clipper_python.RTop_orth( clipper_python.Mat33_double(np.transpose(rotation_mobile_to_ref)), clipper_python.Vec3_double(translation_mobile_to_ref), ) xmap_new = clipper_python.Xmap_float( mobile_xmap.xmap.spacegroup, mobile_xmap.xmap.cell, mobile_xmap.xmap.grid_sampling, ) clipper_python.rotate_translate( mobile_xmap.xmap, xmap_new, rtop, ) return xmap_new.export_numpy()