Skip to content

Commit

Permalink
feat: implement summary file concatenation and sorting in Snakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Jan 22, 2025
1 parent 40cad13 commit 5efb8e8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
configfile: "nbia.yaml"

COLLECTION_NAMES = config["datasets"].keys()
# COLLECTION_NAMES = list(COLLECTION_NAMES)[:1]

rule all:
input:
expand("results/{collection}.tar.gz", collection=COLLECTION_NAMES),
expand("results/{collection}_summary.md", collection=COLLECTION_NAMES)
shell:
"echo 'All done!'"
output:
report = "results/combined_summary.md"
run:
# use python to concatenate all the summary files, then sort by collection name
summaries = []
for collection in COLLECTION_NAMES:
with open(f"results/{collection}_summary.md") as summary:
summaries.append((collection, summary.read()))

summaries.sort(key=lambda x: x[0])

with open("results/combined_summary.md", "w") as combined_summary:
for collection, content in summaries:
combined_summary.write(content)
combined_summary.write("\n")

rule compress:
input:
Expand Down

0 comments on commit 5efb8e8

Please sign in to comment.