From b42d0716a230e0f358f6d4080cedcbc79473e0d1 Mon Sep 17 00:00:00 2001 From: paulzierep Date: Thu, 7 Nov 2024 16:38:59 +0100 Subject: [PATCH] test --- communities/microgalaxy/lab/base.yml | 2 +- .../microgalaxy/lab/sections/5_tools.yml | 9 +-- .../resources/.~lock.curated_tools.tsv# | 1 + sources/bin/populate_labs.py | 70 +++++++++++++++++++ 4 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 communities/microgalaxy/resources/.~lock.curated_tools.tsv# create mode 100644 sources/bin/populate_labs.py diff --git a/communities/microgalaxy/lab/base.yml b/communities/microgalaxy/lab/base.yml index 5a1f1be7..f48401be 100644 --- a/communities/microgalaxy/lab/base.yml +++ b/communities/microgalaxy/lab/base.yml @@ -64,6 +64,6 @@ sections: - sections/1_beginner.yml - sections/3_advanced.yml - sections/4_community.yml - # - sections/5_tools.yml + - sections/5_tools.yml # ----------------------------------------------------------------------------- diff --git a/communities/microgalaxy/lab/sections/5_tools.yml b/communities/microgalaxy/lab/sections/5_tools.yml index 11a75ac8..323d36c2 100644 --- a/communities/microgalaxy/lab/sections/5_tools.yml +++ b/communities/microgalaxy/lab/sections/5_tools.yml @@ -5,10 +5,5 @@ tabs: title: List of community curated tools available for microGalaxy content: - title_md: PAMPA - description_md: Tools to compute and analyse biodiversity metrics - - title_md: TreeBest - description_md: TreeBeST best - - title_md: abacas - description_md: Order and Orientate Contigs - - title_md: abricate - description_md: Mass screening of contigs for antiobiotic resistance genes + description_md: > + Tools to compute and analyse biodiversity metrics diff --git a/communities/microgalaxy/resources/.~lock.curated_tools.tsv# b/communities/microgalaxy/resources/.~lock.curated_tools.tsv# new file mode 100644 index 00000000..b540fde2 --- /dev/null +++ b/communities/microgalaxy/resources/.~lock.curated_tools.tsv# @@ -0,0 +1 @@ +,paul,paul-LIFEBOOK-U7410,07.11.2024 12:25,file:///home/paul/.config/libreoffice/4; \ No newline at end of file diff --git a/sources/bin/populate_labs.py b/sources/bin/populate_labs.py new file mode 100644 index 00000000..6e28ce12 --- /dev/null +++ b/sources/bin/populate_labs.py @@ -0,0 +1,70 @@ +import argparse +import os +from typing import List + +import oyaml as yaml +import pandas as pd + +# import yaml + + +def main() -> None: + parser = argparse.ArgumentParser(description="Create community tools.yml from tool.tsv.") + + # Adding positional arguments with short options + parser.add_argument( + "-c", "--tool_tsv", type=str, required=True, help="Path to the TSV file (e.g., curated_tools.tsv)" + ) + parser.add_argument( + "-y", "--tool_yml", type=str, required=True, help="Path to the output YAML file (e.g., tools.yml)" + ) + + args = parser.parse_args() + + # Check if the tool TSV file exists + if not os.path.exists(args.tool_tsv): + print(f"Error: The file '{args.tool_tsv}' does not exist.") + return + + try: + # Read the TSV file with pandas (use tab delimiter) + data = pd.read_csv(args.tool_tsv, sep="\t") + + # Construct the YAML data structure + yaml_data = { + "id": "tools", + "title": "Community Tools", + "tabs": [ + {"id": "tool_list", "title": "List of community curated tools available for microGalaxy", "content": []} + ], + } + + # Populate the content section with each row from the TSV + for _, row in data.iterrows(): + # Use the first column (assumed to be the tool title) as the title_md + title_md = row[data.columns[0]] # Get the first column's value as title_md + + # Start the unordered list " + + # Create the tool entry with the formatted HTML list + tool_entry = { + "title_md": title_md, + "description_md": description, # Directly insert the HTML string without escape sequences + } + yaml_data["tabs"][0]["content"].append(tool_entry) + + # Write the YAML data to the output file + with open(args.tool_yml, "w") as yaml_file: + yaml.dump(yaml_data, yaml_file, default_flow_style=False, allow_unicode=True, indent=2) + print(f"Data successfully written to '{args.tool_yml}'") + + except Exception as e: + print(f"An error occurred: {e}") + + +if __name__ == "__main__": + main()