4 def vararg_callback(option, opt_str, value, parser):
6 Snippet from Python website to process multiple values for
7 an option with OptionParser
20 for arg
in parser.rargs:
22 if arg[:2] ==
"--" and len(arg) > 2:
25 if arg[:1] ==
"-" and len(arg) > 1
and not floatable(arg):
29 del parser.rargs[:len(value)]
30 setattr(parser.values, option.dest, value)
35 def get_experiment_params(fn_params):
37 Imports the configuration file
38 @param fn_params configuration file
39 @return Experiment Class with all the infomation from the config file
42 name, ext = os.path.splitext(fn_params)
44 foo = imp.load_source(name, fn_params)
45 exp = foo.Experiment()
47 exp.fn_pdbs = [base.get_relative_path(fn_params, fn)
for fn
in exp.fn_pdbs]
48 if hasattr(exp,
"sampling_positions"):
49 exp.sampling_positions.read = base.get_relative_path(fn_params, exp.sampling_positions.read)
50 if hasattr(exp,
"benchmark"):
51 if hasattr(exp.benchmark,
"fn_pdb_native"):
52 exp.benchmark.fn_pdb_native = base.get_relative_path(
53 fn_params, exp.benchmark.fn_pdb_native)
54 if hasattr(exp.benchmark,
"fn_pdbs_native"):
56 for fn
in exp.benchmark.fn_pdbs_native:
57 fns.append( base.get_relative_path(fn_params, fn) )
58 exp.benchmark.fn_pdbs_native = fns
60 if hasattr(exp,
"dock_transforms"):
61 for i
in range(len(exp.dock_transforms)):
62 exp.dock_transforms[i][2] = base.get_relative_path(fn_params, exp.dock_transforms[i][2])
63 if hasattr(exp,
"em2d_restraints"):
64 for i
in range(len(exp.em2d_restraints)):
65 exp.em2d_restraints[i][1] = base.get_relative_path(fn_params, exp.em2d_restraints[i][1])