1 """@namespace IMP.EMageFit.utility
11 Snippet from Python website to process multiple values for
12 an option with OptionParser
25 for arg
in parser.rargs:
27 if arg[:2] ==
"--" and len(arg) > 2:
30 if arg[:1] ==
"-" and len(arg) > 1
and not floatable(arg):
34 del parser.rargs[:len(value)]
35 setattr(parser.values, option.dest, value)
42 Imports the configuration file
43 @param fn_params configuration file
44 @return Experiment Class with all the infomation from the config file
47 import importlib.machinery
51 name, ext = os.path.splitext(fn_params)
53 foo = importlib.machinery.SourceFileLoader(name,
54 fn_params).load_module()
56 foo = imp.load_source(name, fn_params)
57 exp = foo.Experiment()
59 exp.fn_pdbs = [base.get_relative_path(fn_params, fn)
for fn
in exp.fn_pdbs]
60 if hasattr(exp,
"sampling_positions"):
61 exp.sampling_positions.read = base.get_relative_path(
62 fn_params, exp.sampling_positions.read)
63 if hasattr(exp,
"benchmark"):
64 if hasattr(exp.benchmark,
"fn_pdb_native"):
65 exp.benchmark.fn_pdb_native = base.get_relative_path(
66 fn_params, exp.benchmark.fn_pdb_native)
67 if hasattr(exp.benchmark,
"fn_pdbs_native"):
69 for fn
in exp.benchmark.fn_pdbs_native:
70 fns.append(base.get_relative_path(fn_params, fn))
71 exp.benchmark.fn_pdbs_native = fns
73 if hasattr(exp,
"dock_transforms"):
74 for i
in range(len(exp.dock_transforms)):
75 exp.dock_transforms[i][2] = base.get_relative_path(
76 fn_params, exp.dock_transforms[i][2])
77 if hasattr(exp,
"em2d_restraints"):
78 for i
in range(len(exp.em2d_restraints)):
79 exp.em2d_restraints[i][1] = base.get_relative_path(
80 fn_params, exp.em2d_restraints[i][1])
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
def vararg_callback
Snippet from Python website to process multiple values for an option with OptionParser.
def get_experiment_params
Imports the configuration file.