Mercurial > repos > bimib > marea_2
changeset 325:7cf50f1de512 draft
Uploaded
author | luca_milaz |
---|---|
date | Mon, 05 Aug 2024 19:22:26 +0000 |
parents | e471f829344a |
children | 77fa38217b6f |
files | marea_2/custom_data_generator.py |
diffstat | 1 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2/custom_data_generator.py Mon Aug 05 14:37:21 2024 +0000 +++ b/marea_2/custom_data_generator.py Mon Aug 05 19:22:26 2024 +0000 @@ -30,14 +30,18 @@ parser.add_argument("-mn", "--name", type = str, required = True, help = "Input model name") # ^ I need this because galaxy converts my files into .dat but I need to know what extension they were in - parser.add_argument( - "-of", "--output_format", - # vvv I have to use .fromExt because enums in python are the plague and have been implemented by a chimpanzee. - type = utils.FileFormat.fromExt, default = utils.FileFormat.PICKLE, - choices = [utils.FileFormat.CSV, utils.FileFormat.PICKLE], - # ^^^ Not all variants are valid here, otherwise list(utils.FileFormat) would be best. - required = True, help = "Extension of all output files") - + parser.add_argument('-bounds', '--bounds', + type = str, + help = 'output of bounds tsv') + parser.add_argument('-reactions', '--reactions', + type = str, + help = 'output of reactions tsv') + parser.add_argument('-medium', '--medium', + type = str, + help = 'output of medium tsv') + parser.add_argument('-rules', '--rules', + type = str, + help = 'output of rules tsv') argsNamespace = parser.parse_args() argsNamespace.out_dir = "result" # ^ can't get this one to work from xml, there doesn't seem to be a way to get the directory attribute from the collection @@ -160,7 +164,7 @@ None """ with open(file_path.show(), 'w', newline='') as csvfile: - writer = csv.DictWriter(csvfile, fieldnames = fieldNames) + writer = csv.DictWriter(csvfile, fieldnames = fieldNames, delimiter='\t') writer.writeheader() for key, value in data.items(): @@ -185,6 +189,8 @@ model = load_custom_model( utils.FilePath.fromStrPath(ARGS.input), utils.FilePath.fromStrPath(ARGS.name).ext) + ARGS.output_format = utils.FileFormat.CSV + # generate data and save it in the desired format and in a location galaxy understands # (it should show up as a collection in the history) rulesPath = utils.FilePath("rules", ARGS.output_format, prefix = ARGS.out_dir) @@ -209,10 +215,10 @@ reactions = generate_reactions(model, asParsed = False) bounds = generate_bounds(model) medium = get_medium(model) - save_as_csv(rules, rulesPath, ("ReactionID", "Rule")) - save_as_csv(reactions, reactionsPath, ("ReactionID", "Reaction")) - bounds.to_csv(boundsPath.show()) - medium.to_csv(mediumPath.show()) + save_as_csv(rules, ARGS.rules, ("ReactionID", "Rule")) + save_as_csv(reactions, ARGS.reactions, ("ReactionID", "Reaction")) + bounds.to_csv(ARGS.bounds) + medium.to_csv(ARGS.medium) # ^ Please if anyone works on this after updating python to 3.12 change the if/elif into a match statement!!