Skip to content

Support URL inputs in taffy view -r and the Python API#85

Merged
glennhickey merged 1 commit into
mainfrom
url
May 28, 2026
Merged

Support URL inputs in taffy view -r and the Python API#85
glennhickey merged 1 commit into
mainfrom
url

Conversation

@glennhickey
Copy link
Copy Markdown
Contributor

Use htslib to support inputs over http. Seems to work pretty well thugh applied only to indexed taffy view (-r) queries for now.

These work by downloading the entire .tai, loading it into memory, then reading only the selected range from the remote alignment file.

Some things I need to check before merging: cactus integration (inc static build) and if it works on Mac.

Routes URL inputs (http://, https://, s3://, ...) through htslib's
URL-aware bgzf_open, so a region query against a remote MAF/TAF only
fetches the .tai plus the BGZF blocks the iterator actually needs.

- LI_construct_from_path: thin wrapper over bgzf_open, used in lieu of
  fopen+LI_construct when the input is a URL
- remote_io.{h,c}: URL detector + .tai slurp helper that writes the
  fetched bytes to a tmpfile (so downstream LI_construct(FILE*) can
  fileno() it)
- taf_view.c: detects URL inputs, requires -r, falls through to the
  shared cleanup path
- Python: AlignmentReader and TafIndex accept URL strings; URL-backed
  readers skip the per-FILE* close that would otherwise corrupt
- Clear error message when htslib was built without libcurl, with a
  pointer to ./configure --enable-libcurl
- README note documenting the htslib-with-libcurl requirement

Verified against a 184 GB MAF on S3: a 500 bp slice returns the right
content in ~8 s, dominated by the 5.9 MB index fetch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@glennhickey glennhickey merged commit 62c97bc into main May 28, 2026
@glennhickey glennhickey deleted the url branch May 28, 2026 16:56
glennhickey added a commit that referenced this pull request May 28, 2026
Pulls in #85 (URL inputs), #86 (BlockReader / direct-MAF readers),
#87 (faster MAF/TAF emitter+parser via byte-level LW_put* API), and
#88 (-T/--threads bgzf_mt across all commands).

Conflicts resolved:
  * Makefile -- union of build deps (kept tui.o + ONElib.o from unitaf,
    added block_reader.o + remote_io.o from main).
  * taf_index.c -- short-flag clash: main's -T = --threads collided with
    unitaf's -T = --tmpDir.  Renamed --tmpDir to -d to keep -T/--threads
    consistent across every command; --tmpDir long form is unchanged so
    only short-flag callers break.
  * taf_view.c -- combined #include "tui.h" + "remote_io.h"; gated the
    .tui auto-detect on !input_is_url (no remote-.tui resolver yet);
    routed the non-tui else branch through tai_path_for /
    open_tai_for_reading so URL inputs work there.
  * taffy/impl/line_iterator.{h,c} -- header auto-merged (LI_get_position
    from unitaf + LW_put* buffer fields from main).  .c kept both the
    LI_get_position definition and LW_BUF_TARGET.
  * taffy/impl/maf.c -- both branches hand-rolled the MAF "s" parser.
    Kept unitaf's body (uses the digit-only maf_parse_u64, ~13% CPU win
    over strtoll, plus defensive `continue` on malformed lines instead
    of assertion) and dropped main's now-unused maf_parse_s_line helper.
    Switched maf_write_block2 to main's LW_put* API (64 KB coalescing
    via the shared writer) and dropped the file-local maf_lw_putn /
    maf_i64_str helpers + the bgzf.h include they pulled in.
  * taffy/impl/taf.c -- auto-merged.

Tests: C unit suite 32/32, pytest tai+tui 983/983 pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant