| 58 | |
| 59 | |
| 60 | def parseCTDCommandLine(argv, model, openms_param): |
| 61 | # Configure CTDOpt to use OpenMS style on the command line. |
| 62 | directives = parse_cl_directives(argv, input_ctd='ini', write_tool_ctd='write_ini', prefix='-') |
| 63 | |
| 64 | if directives["write_tool_ctd"] is not None: # triggered if -write_ini was provided on CML |
| 65 | # if called with -write_ini write CTD |
| 66 | model.write_ctd(directives["write_tool_ctd"]) |
| 67 | exit(0) |
| 68 | elif directives["input_ctd"] is not None: # read ctd/ini file |
| 69 | model = CTDModel(from_file=directives["input_ctd"]) |
| 70 | # print(model.get_defaults()) |
| 71 | |
| 72 | param = pms.Param() |
| 73 | fh = pms.ParamXMLFile() |
| 74 | fh.load(directives["input_ctd"], param) |
| 75 | openms_param.update(param, True) |
| 76 | return model.get_defaults(), openms_param |
| 77 | |
| 78 | else: # only command line options provided |
| 79 | temp = tempfile.NamedTemporaryFile(suffix='ini') # makes sure we get a writable file |
| 80 | tmp_name = temp.name |
| 81 | temp.close() # removes the file |
| 82 | |
| 83 | model.write_ctd(tmp_name) |
| 84 | param = pms.Param() |
| 85 | fh = pms.ParamXMLFile() |
| 86 | fh.load(tmp_name, param) |
| 87 | openms_param.update(param) |
| 88 | os.remove(tmp_name) |
| 89 | return model.parse_cl_args(argv), openms_param |