From 2779fde785a9821526f315c4a13746c5692823f8 Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Fri, 9 Feb 2024 12:16:19 -0800 Subject: [PATCH] add return of file instead of stream --- bin/validate.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bin/validate.py b/bin/validate.py index 5e0fc600..74ef1192 100755 --- a/bin/validate.py +++ b/bin/validate.py @@ -340,19 +340,19 @@ def make_products(dataset, gaf_path, products, ontology_graph): @tools.gzips def make_gpads(dataset, gaf_path, products, ontology_graph, noctua_gpad_file): + gpad_file_path = os.path.join(os.path.split(gaf_path)[0], f"{dataset}_gpad.gpad") + product_files = { "gpad": open(os.path.join(os.path.split(gaf_path)[0], "{}_gpad.gpad".format(dataset)), "wb") } if not products["gpad"]: - # Bail if we have no products return [] # logger.info("AssocParserConfig used: {}".format(config)) - validated_gpad_path = product_files["gpad"] - outfile = open(validated_gpad_path, "w") - gpadwriter = GpadWriter(file=outfile, version="GPAD_2_0") + with open(gpad_file_path, "w") as outfile: + gpadwriter = GpadWriter(file=outfile, version="GPAD_2_0") print("noctua-gpad-file: {}".format(noctua_gpad_file)) if noctua_gpad_file is not None: @@ -386,10 +386,8 @@ def make_gpads(dataset, gaf_path, products, ontology_graph, noctua_gpad_file): gpadwriter.write_assoc(association) # After we run through associations - for f in product_files.values(): - f.close() + return [gpad_file_path] if products["gpad"] else [] - return [product_files["gpad"].name for prod in sorted(product_files.keys()) if products[prod]] @tools.gzips def produce_gpi(dataset, target_dir, gaf_path, ontology_graph):