Skip to content

Commit

Permalink
Parse tools for usegalaxy.org.au
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Jul 28, 2024
1 parent 348abea commit ea90041
Show file tree
Hide file tree
Showing 3 changed files with 1,017 additions and 0 deletions.
4 changes: 4 additions & 0 deletions subdomains/scripts/parse_tools_to_produce_yml_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import re
import argparse

import tools_au

parser = argparse.ArgumentParser(description='Create installation yaml files from a Yaml file containing the panel_view/Toolkit data')
parser.add_argument('--tk', action="store", dest='toolkit', help='Path of the toolkit.yaml file') # Toolkit.yaml file
parser.add_argument('--yml-folder', action="store", dest='dest', help='Folder containing the yml files with tool installed in the target instance') # Folder containing the .yml and yml.lock containing the tools installed in the target instance
Expand Down Expand Up @@ -33,3 +35,5 @@
f.write("- name: "+tool+"\n")
f.write(" owner: "+owner+"\n")
f.close()

tools_au.parse()
49 changes: 49 additions & 0 deletions subdomains/scripts/tools_au.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Convert YAML files for install on AU.
Assumes that wdir contains tool yaml files.
"""

import yaml
from pathlib import Path

WDIR = Path(__file__).parent
EXCLUDE_KEYS = [
'install_repository_dependencies',
'tool_panel_section_label',
]
OUTPUT_FILE = WDIR / 'usegalaxy.org.au.yml'


def parse():
data = {'tools': []}
for f in WDIR.glob('*.yml.lock'):
if not f.name.endswith('.yml.lock'):
continue
print(f"Extracting data from {f}...")
with open(f, 'r') as handle:
section_data = yaml.safe_load(handle)
section_data['tools'] = [
_transcribe_to_au(x) for x in section_data['tools']
]
for key in EXCLUDE_KEYS:
section_data.pop(key)
data['tools'] += section_data['tools']
for key in ('install_resolver_dependencies', 'install_tool_dependencies'):
data[key] = section_data[key]
write_data(data)
print(f'Data transcribed and written to {OUTPUT_FILE}')


def _transcribe_to_au(tool):
tool['tool_panel_section_label'] = 'Single-Cell'
tool.pop('tool_panel_section_id')
return tool


def write_data(data):
with open(OUTPUT_FILE, 'w') as handle:
yaml.dump(data, handle, default_flow_style=False)


if __name__ == '__main__':
parse()
Loading

0 comments on commit ea90041

Please sign in to comment.