Ejemplo n.º 1
0
    except ModelTypeError:
        pass
    try:
        ini_model = Parameters(from_file=args.ini_file)
    except ModelTypeError:
        pass
    assert ini_model is not None, "Could not parse %s, seems to be no CTD/PARAMS" % (
        args.ini_file)

    # get a dictionary of the ctd arguments where the values of the parameters
    # given on the command line are overwritten
    ini_values = ini_model.parse_cl_args(cl_args=cliargs, ignore_required=True)

    if args.ctd_file:
        ctd_model = CTDModel(from_file=args.ctd_file)
        ctd_values = ctd_model.get_defaults()
        for param in ini_model.get_parameters():
            if not param.required and (param.default is None
                                       or type(param.default) is _Null):
                lineage = param.get_lineage(name_only=True)
                try:
                    default = getFromDict(ctd_values, lineage)
                except KeyError:
                    continue
                setInDict(ini_values, lineage, default)

    # write the ctd with the values taken from the dictionary
    out = StringIO()
    ctd_tree = ini_model.write_ctd(out, ini_values)
    print(out.getvalue())
Ejemplo n.º 2
0
# therefore hardcoded params change the name of spectra:in to spectra:_in
# which is corrected here again
# TODO remove once PR is in and adapt profile accordingly
fix_underscores(args)

model = CTDModel(from_file=input_ctd)

# transform values from json that correspond to
# - old style booleans (string + restrictions) -> transformed to a str
# - new style booleans that get a string (happens for hidden parameters [-test])
#   are transformed to a bool
# - unrestricted ITEMLIST which are represented as strings
#   ("=quoted and space separated) in Galaxy -> transform to lists
# - optional data input parameters that have defaults and for which no
#   value is given -> overwritte with the default
for p in model.get_parameters():

    # check if the parameter is in the arguments from the galaxy tool
    # (from the json file(s)), since advanced parameters are absent
    # if the conditional is set to basic parameters
    try:
        getFromDict(args, p.get_lineage(name_only=True))
    except KeyError:
        # few tools use dashes in parameters which are automatically replaced
        # by underscores by Galaxy. in these cases the dictionary needs to be
        # updated (better: then dash and the underscore variant are in the dict)
        # TODO might be removed later https://github.com/OpenMS/OpenMS/pull/4529
        try:
            lineage = [
                _.replace("-", "_") for _ in p.get_lineage(name_only=True)
            ]