Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ bioepic essdive-dataset 7a9f0b1f-1234-5678-9abc-def012345678
bioepic match-terms variable_names.tsv bervo_terms.txt --fuzzy
```

Note: If `--output` is omitted for `bioepic match-terms`, the default output path is
`<terms_file_stem>_matched.tsv` in the same directory as the input terms file.

**TRY Skills (CLI-free helpers):**
```bash
# Download TRY datasets page (use --insecure if certificate checks fail)
Expand Down
26 changes: 13 additions & 13 deletions bioepic_skills/trowel_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import subprocess
from pathlib import Path
from typing import Optional


Expand Down Expand Up @@ -40,7 +41,8 @@ def get_essdive_metadata(doi_file: str, output_dir: str = ".") -> dict[str, str]
if not os.path.exists(output_dir):
raise FileNotFoundError(f"Output directory not found: {output_dir}")

cmd = ["trowel", "get-essdive-metadata", "--path", doi_file, "--outpath", output_dir]
cmd = ["trowel", "get-essdive-metadata",
"--path", doi_file, "--outpath", output_dir]

result = subprocess.run(cmd, capture_output=True, text=True)

Expand Down Expand Up @@ -80,7 +82,8 @@ def get_essdive_variables(
if not os.path.exists(output_dir):
raise FileNotFoundError(f"Output directory not found: {output_dir}")

cmd = ["trowel", "get-essdive-variables", "--outpath", output_dir, "--workers", str(workers)]
cmd = ["trowel", "get-essdive-variables", "--outpath",
output_dir, "--workers", str(workers)]

if filetable_path:
if not os.path.exists(filetable_path):
Expand Down Expand Up @@ -135,7 +138,13 @@ def match_term_lists(
]

if output:
cmd.extend(["--output", output])
output_path = output
else:
terms_path = Path(terms_file)
output_path = str(terms_path.with_name(
f"{terms_path.stem}_matched.tsv"))

cmd.extend(["--output", output_path])

if fuzzy:
cmd.append("--fuzzy")
Expand All @@ -146,13 +155,4 @@ def match_term_lists(
if result.returncode != 0:
raise RuntimeError(f"trowel command failed: {result.stderr}")

# Parse output to get the result file path
if output:
return output
else:
# Extract the output path from the command output
for line in result.stdout.split("\n"):
if "Matched terms written to" in line:
return line.split("Matched terms written to")[-1].strip()

raise RuntimeError("Could not determine output file path")
return output_path
3 changes: 3 additions & 0 deletions skills/essdive-extraction/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ Examples:
# Save to specific output file
bioepic match-terms vars.tsv refs.txt --output matched.tsv

Default output (if --output is omitted):
<terms_file_stem>_matched.tsv in the same directory as the terms file

╭─ Arguments ────────────────────────────────────────────────────────────────────╮
│ * terms_file PATH TSV file with terms in first column [required] │
│ * list_file PATH Text file with terms, one per line [required] │
Expand Down
Loading