Skip to content

Commit

Permalink
add biii parsing and allow for multiple xref parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
paulzierep committed Mar 1, 2024
1 parent acc84e1 commit eb3cfe4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bin/create_interactive_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd

# TODO maybe allow comunities to modify
# TODO maybe allow communities to modify
COLUMNS = [
"Expand",
"Galaxy wrapper id",
Expand All @@ -18,6 +18,7 @@
"EDAM topic",
"Description",
"bio.tool description",
"biii",
"Status",
"Source",
"ToolShed categories",
Expand Down
19 changes: 16 additions & 3 deletions bin/extract_galaxy_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,13 @@ def get_xref(el: et.Element, attrib_type: str) -> Optional[str]:
:param el: Element object
:attrib_type: the type of the xref (e.g.: bio.tools or biii)
"""

xrefs = el.find("xrefs")
if xrefs is not None:
xref = xrefs.find("xref")
if xref is not None and xref.attrib["type"] == attrib_type:
return xref.text
xref_items = xrefs.findall("xref") # check all xref items
for xref in xref_items:
if xref is not None and xref.attrib["type"] == attrib_type:
return xref.text
return None


Expand Down Expand Up @@ -298,9 +300,14 @@ def get_tool_metadata(tool: ContentFile, repo: Repository) -> Optional[Dict[str,
metadata["Galaxy wrapper version"] = child.text
elif child.attrib["name"] == "requirements":
metadata["Conda id"] = get_conda_package(child)
# bio.tools
biotools = get_xref(child, attrib_type="bio.tools")
if biotools is not None:
metadata["bio.tool id"] = biotools
# biii
biii = get_xref(child, attrib_type="biii")
if biii is not None:
metadata["biii"] = biii
# parse XML file and get meta data from there, also tool ids
for file in file_list:
if file.name.endswith("xml") and "macro" not in file.name:
Expand Down Expand Up @@ -329,6 +336,12 @@ def get_tool_metadata(tool: ContentFile, repo: Repository) -> Optional[Dict[str,
biotools = get_xref(root, attrib_type="bio.tools")
if biotools is not None:
metadata["bio.tool id"] = biotools
# bio.tools
# biii
if metadata["biii"] is None:
biii = get_xref(root, attrib_type="biii")
if biii is not None:
metadata["biii"] = biii
# conda package
if metadata["Conda id"] is None:
reqs = get_conda_package(root)
Expand Down

0 comments on commit eb3cfe4

Please sign in to comment.