comparison fill_ctd_clargs.py @ 0:fe6eddc2e756 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
author galaxyp
date Thu, 27 Aug 2020 19:47:24 -0400
parents
children 92864c71ac6a
comparison
equal deleted inserted replaced
-1:000000000000 0:fe6eddc2e756
1 #!/usr/bin/env python3
2 from argparse import ArgumentParser
3 from io import StringIO
4
5 from CTDopts.CTDopts import (
6 CTDModel,
7 ModelTypeError,
8 Parameters
9 )
10
11 if __name__ == "__main__":
12 # note add_help=False since otherwise arguments starting with -h will
13 # trigger an error (despite allow_abbreviate)
14 parser = ArgumentParser(prog="fill_ctd_clargs",
15 description="fill command line arguments"
16 "into a CTD file and write the CTD file to",
17 add_help=False, allow_abbrev=False)
18 parser.add_argument("--ctd", dest="ctd", help="input ctd file",
19 metavar='CTD', default=None, required=True)
20 args, cliargs = parser.parse_known_args()
21 # load CTDModel
22 model = None
23 try:
24 model = CTDModel(from_file=args.ctd)
25 except ModelTypeError:
26 pass
27 try:
28 model = Parameters(from_file=args.ctd)
29 except ModelTypeError:
30 pass
31 assert model is not None, "Could not parse %s, seems to be no CTD/PARAMS" % (args.ctd)
32
33 # get a dictionary of the ctd arguments where the values of the parameters
34 # given on the command line are overwritten
35 margs = model.parse_cl_args(cl_args=cliargs, ignore_required=True)
36
37 # write the ctd with the values taken from the dictionary
38 out = StringIO()
39 ctd_tree = model.write_ctd(out, margs)
40 print(out.getvalue())