Skip to content
Open
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
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Synapse credentials
# Copy this file to .env and fill in your values.
# Then load before running htan:
# source .env
# Or for a single command:
# SYNAPSE_AUTH_TOKEN=your_token htan upload synapse file ...
#
# Get your token at: https://www.synapse.org/#!Profile:v/settings (Access Tokens tab)
# IMPORTANT: Never commit .env to git. It is already in .gitignore.

SYNAPSE_AUTH_TOKEN=your_personal_access_token_here
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ htmlcov/
# OS
.DS_Store

# Credentials — never commit
.env
.env.*
!.env.example

# Local Claude Code config
.claude/settings.local.json

Expand Down
38 changes: 38 additions & 0 deletions src/htan/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ def main():
if command == "init":
from htan.init import cli_main
cli_main(rest)
elif command == "etl":
_dispatch_etl(rest)
elif command == "query":
_dispatch_query(rest)
elif command == "download":
_dispatch_download(rest)
elif command == "upload":
_dispatch_upload(rest)
elif command == "pubs":
from htan.pubs import cli_main
cli_main(rest)
Expand All @@ -57,6 +61,22 @@ def main():
sys.exit(1)


def _dispatch_etl(args):
if not args:
print("Usage: htan etl {omop} ...", file=sys.stderr)
sys.exit(1)

subcommand = args[0]
rest = args[1:]

if subcommand == "omop":
from htan.etl.omop import cli_main
cli_main(rest)
else:
print(f"Unknown etl subcommand: {subcommand}. Use 'omop'.", file=sys.stderr)
sys.exit(1)


def _dispatch_query(args):
if not args:
print("Usage: htan query {portal,bq} ...", file=sys.stderr)
Expand Down Expand Up @@ -95,6 +115,22 @@ def _dispatch_download(args):
sys.exit(1)


def _dispatch_upload(args):
if not args:
print("Usage: htan upload {synapse} ...", file=sys.stderr)
sys.exit(1)

backend = args[0]
rest = args[1:]

if backend == "synapse":
from htan.upload.synapse import cli_main
cli_main(rest)
else:
print(f"Unknown upload backend: {backend}. Use 'synapse'.", file=sys.stderr)
sys.exit(1)


def _dispatch_config(args):
import json
from htan.config import check_setup
Expand Down Expand Up @@ -123,9 +159,11 @@ def _print_usage():

Commands:
init Interactive setup wizard (configure credentials)
etl omop ... ETL lung cancer data to OMOP CDM in DuckDB
query portal ... Query HTAN portal ClickHouse database
query bq ... Query HTAN metadata in ISB-CGC BigQuery
download synapse .. Download open-access files from Synapse
upload synapse ... Upload files to Synapse (single, bulk, with annotations)
download gen3 ... Download controlled-access files from Gen3/CRDC
pubs ... Search HTAN publications on PubMed
model ... Query HTAN data model (components, attributes, valid values)
Expand Down
1 change: 1 addition & 0 deletions src/htan/upload/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Upload HTAN data files to Synapse."""
Loading