def get_em2d_restraint(assembly, images_selection_file, restraint_params, mode="fast", n_optimized=1): """ Sets a restraint for comparing the model to a set of EM images """ model = assembly.get_model() # Setup the restraint sc = em2d.EM2DScore() r = em2d.Em2DRestraint(model) r.setup(sc, restraint_params) names = em2d.read_selection_file(images_selection_file) names = [base.get_relative_path(images_selection_file, x) for x in names] log.debug("names of the images %s", names) srw = em2d.SpiderImageReaderWriter() imgs = em2d.read_images(names, srw) r.set_images(imgs) ps = atom.get_leaves(assembly) lsc = container.ListSingletonContainer(ps) r.set_particles(lsc) if (mode == "coarse"): r.set_coarse_registration_mode(True) elif (mode == "fast"): r.set_fast_mode(n_optimized) elif (mode == "complete"): pass else: raise ValueError("Em2DRestraint mode not recognized") return r
def get_em2d_restraint( assembly, images_selection_file, restraint_params, mode="fast", n_optimized=1): """ Sets a restraint for comparing the model to a set of EM images """ model = assembly.get_model() # Setup the restraint sc = em2d.EM2DScore() r = em2d.Em2DRestraint() r.setup(sc, restraint_params) names = em2d.read_selection_file(images_selection_file) names = [base.get_relative_path(images_selection_file, x) for x in names] log.debug("names of the images %s", names) srw = em2d.SpiderImageReaderWriter() imgs = em2d.read_images(names, srw) r.set_images(imgs) ps = atom.get_leaves(assembly) lsc = container.ListSingletonContainer(ps) r.set_particles(lsc) if (mode == "coarse"): r.set_coarse_registration_mode(True) elif (mode == "fast"): r.set_fast_mode(n_optimized) elif(mode == "complete"): pass else: raise ValueError("Em2DRestraint mode not recognized") return r
def get_experiment_params(fn_params): """ Imports the configuration file @param fn_params configuration file @return Experiment Class with all the infomation from the config file """ name, ext = os.path.splitext(fn_params) import imp foo = imp.load_source(name, fn_params) exp = foo.Experiment() # convert to absolute paths exp.fn_pdbs = [base.get_relative_path(fn_params, fn) for fn in exp.fn_pdbs] if hasattr(exp, "sampling_positions"): exp.sampling_positions.read = base.get_relative_path(fn_params, exp.sampling_positions.read) if hasattr(exp, "benchmark"): if hasattr(exp.benchmark, "fn_pdb_native"): exp.benchmark.fn_pdb_native = base.get_relative_path( fn_params, exp.benchmark.fn_pdb_native) if hasattr(exp.benchmark, "fn_pdbs_native"): fns = [] for fn in exp.benchmark.fn_pdbs_native: fns.append( base.get_relative_path(fn_params, fn) ) exp.benchmark.fn_pdbs_native = fns if hasattr(exp, "dock_transforms"): for i in range(len(exp.dock_transforms)): exp.dock_transforms[i][2] = base.get_relative_path(fn_params, exp.dock_transforms[i][2]) if hasattr(exp, "em2d_restraints"): for i in range(len(exp.em2d_restraints)): exp.em2d_restraints[i][1] = base.get_relative_path(fn_params, exp.em2d_restraints[i][1]) return exp
def get_experiment_params(fn_params): """ Imports the configuration file @param fn_params configuration file @return Experiment Class with all the infomation from the config file """ name, ext = os.path.splitext(fn_params) import imp foo = imp.load_source(name, fn_params) exp = foo.Experiment() # convert to absolute paths exp.fn_pdbs = [base.get_relative_path(fn_params, fn) for fn in exp.fn_pdbs] if hasattr(exp, "sampling_positions"): exp.sampling_positions.read = base.get_relative_path( fn_params, exp.sampling_positions.read) if hasattr(exp, "benchmark"): if hasattr(exp.benchmark, "fn_pdb_native"): exp.benchmark.fn_pdb_native = base.get_relative_path( fn_params, exp.benchmark.fn_pdb_native) if hasattr(exp.benchmark, "fn_pdbs_native"): fns = [] for fn in exp.benchmark.fn_pdbs_native: fns.append(base.get_relative_path(fn_params, fn)) exp.benchmark.fn_pdbs_native = fns if hasattr(exp, "dock_transforms"): for i in range(len(exp.dock_transforms)): exp.dock_transforms[i][2] = base.get_relative_path( fn_params, exp.dock_transforms[i][2]) if hasattr(exp, "em2d_restraints"): for i in range(len(exp.em2d_restraints)): exp.em2d_restraints[i][1] = base.get_relative_path( fn_params, exp.em2d_restraints[i][1]) return exp