5 def vararg_callback(option, opt_str, value, parser):
7 Snippet from Python website to process multiple values for
8 an option with OptionParser
21 for arg
in parser.rargs:
23 if arg[:2] ==
"--" and len(arg) > 2:
26 if arg[:1] ==
"-" and len(arg) > 1
and not floatable(arg):
30 del parser.rargs[:len(value)]
31 setattr(parser.values, option.dest, value)
36 def get_experiment_params(fn_params):
38 Imports the configuration file
39 @param fn_params configuration file
40 @return Experiment Class with all the infomation from the config file
43 name, ext = os.path.splitext(fn_params)
45 foo = imp.load_source(name, fn_params)
46 exp = foo.Experiment()
48 exp.fn_pdbs = [base.get_relative_path(fn_params, fn)
for fn
in exp.fn_pdbs]
49 if hasattr(exp,
"sampling_positions"):
50 exp.sampling_positions.read = base.get_relative_path(
51 fn_params, exp.sampling_positions.read)
52 if hasattr(exp,
"benchmark"):
53 if hasattr(exp.benchmark,
"fn_pdb_native"):
54 exp.benchmark.fn_pdb_native = base.get_relative_path(
55 fn_params, exp.benchmark.fn_pdb_native)
56 if hasattr(exp.benchmark,
"fn_pdbs_native"):
58 for fn
in exp.benchmark.fn_pdbs_native:
59 fns.append(base.get_relative_path(fn_params, fn))
60 exp.benchmark.fn_pdbs_native = fns
62 if hasattr(exp,
"dock_transforms"):
63 for i
in range(len(exp.dock_transforms)):
64 exp.dock_transforms[i][2] = base.get_relative_path(
65 fn_params, exp.dock_transforms[i][2])
66 if hasattr(exp,
"em2d_restraints"):
67 for i
in range(len(exp.em2d_restraints)):
68 exp.em2d_restraints[i][1] = base.get_relative_path(
69 fn_params, exp.em2d_restraints[i][1])
See IMP.base for more information.