Skip to content

fix: allow readVcf() to accept a connection (textConnection, url, etc.) (#28)#111

Open
jmg421 wants to merge 3 commits into
Bioconductor:develfrom
jmg421:fix/28-readVcf-connection
Open

fix: allow readVcf() to accept a connection (textConnection, url, etc.) (#28)#111
jmg421 wants to merge 3 commits into
Bioconductor:develfrom
jmg421:fix/28-readVcf-connection

Conversation

@jmg421

@jmg421 jmg421 commented Jul 7, 2026

Copy link
Copy Markdown

Problem

Users who hold VCF content in memory (e.g. fetched from a database blob, downloaded via url(), or stored as a character vector) had to write to a temp file before calling readVcf(). This round-trip added unnecessary I/O latency, especially for large VCFs (#28).

Fix

  • R/AllClasses.R — call setOldClass() for the four common S3 connection subclasses (textConnection, rawConnection, url, file) so that S4 dispatch resolves the "connection" signature before any setMethod() calls.
  • R/methods-readVcf.R — add two new setMethod(readVcf, c(file="connection", ...)) dispatches. The implementation reads all lines from the connection into a temp .vcf file (which Rsamtools requires), calls the existing readVcf,character method, and cleans up. The caller's connection is left open or closed depending on whether it was already open before the call.
  • man/readVcf-methods.Rd — document the new dispatch, update the file argument description, add \alias entries, and include a short usage example.

Usage

lines <- readLines("my.vcf")
con   <- textConnection(lines)
vcf   <- readVcf(con, "hg19")   # no temp file needed by the caller

Closes #28

vjcitn and others added 3 commits July 17, 2026 21:15
Convert \itemize blocks that used \item{label}{desc} syntax to \describe,
and replace empty \item{}{} labels in \describe blocks with the function
signature from the body, resolving all checkRd warnings in isSNV-methods,
PolyPhenDb-class, readVcf-methods, SIFTDb-class, summarizeVariants-methods,
VariantType-class, VCF-class, VcfFile-class, VCFHeader-class, VRanges-class,
and VRangesList-class Rd files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jmg421
jmg421 force-pushed the fix/28-readVcf-connection branch from 3c9d21b to c3aabb3 Compare July 18, 2026 03:01
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.

Can I read in a VCF "file" as a character string?

2 participants