Skip to content

Commit

Permalink
Add script to generate from tool table a YAML to install the tool
Browse files Browse the repository at this point in the history
  • Loading branch information
bebatut committed Feb 22, 2024
1 parent 15c14da commit 817b975
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions bin/generate_tool_install_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

import argparse

import pandas as pd
import yaml

COLUMNS = {
"Galaxy tool ids": "name",
"Galaxy wrapper owner": "owner",
"EDAM operation": "tool_panel_section_label",
}


def generate_install_yaml(
tsv_path: str,
output_path: str,
) -> None:
df = pd.read_csv(tsv_path, sep="\t").assign(Expand=lambda df: "").fillna("")
if "To keep" in df.columns:
df["To keep"] = df["To keep"].replace("", False)
df = df.query("`To keep`")
df = df.loc[:, COLUMNS.keys()].reindex(columns=COLUMNS.keys()).rename(columns=COLUMNS)
df["name"] = df["name"].str.split(", ")
df = df.explode("name")
print(df)

tool_dict = {
"install_tool_dependencies": True,
"install_repository_dependencies": True,
"install_resolver_dependencies": True,
"tools": df.to_dict("records"),
}

with open(output_path, "w") as output:
yaml.dump(tool_dict, output, default_flow_style=False)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Generate the YAML to install the tools on a Galaxy server \
from TSV file"
)
parser.add_argument(
"--table",
"-ta",
required=True,
help="Path to TSV file with tools",
)
parser.add_argument(
"--output",
"-out",
required=True,
help="Path to YAML output",
)

args = parser.parse_args()
generate_install_yaml(args.table, args.output)

0 comments on commit 817b975

Please sign in to comment.