From 40354d26edf492dc3cc01f9888bb41bdb4a3003e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 11:45:34 +0000 Subject: [PATCH 1/3] Initial plan From c59549c3e9c314e795c278953f084d37a01889b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 11:50:11 +0000 Subject: [PATCH 2/3] Fix ensemblVEP.Rmd: handle Ensembl REST API failures gracefully The vignette was calling vep_by_region() -> post_Hs_region() during package build, which makes a live POST to the Ensembl REST API. When the API returned HTTP 500, the vignette build failed hard. Fix: wrap the API call in tryCatch, set a vep_avail flag, and gate all API-dependent chunks on eval=vep_avail. When the API is unavailable, the chunks are skipped and the build succeeds; when available, the vignette runs in full. Also add vep_avail <- FALSE default to setup chunk so the flag is always defined before any chunk references it. --- vignettes/ensemblVEP.Rmd | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/vignettes/ensemblVEP.Rmd b/vignettes/ensemblVEP.Rmd index 35bb5df..3f4f010 100644 --- a/vignettes/ensemblVEP.Rmd +++ b/vignettes/ensemblVEP.Rmd @@ -20,6 +20,7 @@ library(BiocStyle) library(VariantAnnotation) library(jsonlite) library(httr) +vep_avail <- FALSE ``` # Introduction @@ -53,8 +54,15 @@ We'll base our query on 100 positions in the chr22 VCF. ```{r lksnv} dr = which(width(rowRanges(r22))!=1) r22s = r22[-dr] -res = vep_by_region(r22[1:100], snv_only=FALSE, chk_max=FALSE) -jans = toJSON(content(res)) +res = tryCatch( + vep_by_region(r22[1:100], snv_only=FALSE, chk_max=FALSE), + error = function(e) { + message("Ensembl VEP REST API not available: ", conditionMessage(e)) + NULL + } +) +vep_avail = !is.null(res) +if (vep_avail) jans = toJSON(content(res)) ``` There are various ways to work with the result of this query to the API. @@ -63,26 +71,26 @@ to dig in and understand aspects of the API behavior. First, the top-level concepts produced for each variant can be retrieved using -```{r doj1, message=FALSE} +```{r doj1, eval=vep_avail, message=FALSE} library(rjsoncons) names(jsonlite::fromJSON(jmespath(jans, "[*]"))) ``` Annotation of the most severe consequence known will typically be of interest: -```{r doj2} +```{r doj2, eval=vep_avail} table(jsonlite::fromJSON(jmespath(jans, "[*].most_severe_consequence"))) ``` There is variability in the structure of data returned for each query. -```{r doj3} +```{r doj3, eval=vep_avail} head(fromJSON(jmespath(jans, "[*].regulatory_feature_consequences"))) ``` Furthermore, the content of the motif feature consequences field seems very peculiar. -```{r lktaaaa} +```{r lktaaaa, eval=vep_avail} table(unlist(fromJSON(jmespath(jans, "[*].motif_feature_consequences")))) ``` @@ -92,7 +100,7 @@ We'll consider the following approach to converting the API response to a GenomicRanges GRanges instance. Eventually this may become part of the package. -```{r lkmakeg, message=FALSE} +```{r lkmakeg, eval=vep_avail, message=FALSE} library(GenomicRanges) .make_GRanges = function( vep_response ) { stopifnot(inherits(vep_response, "response")) # httr @@ -112,7 +120,7 @@ Now information about variants can be retrieved with range operations. Deep annotation requires nested structure of the metadata columns. -```{r lkmc} +```{r lkmc, eval=vep_avail} mcols(tstg)[1, "transcript_consequences"] ``` From ca78c39e663658e63893d08fe767982b0cdba08b Mon Sep 17 00:00:00 2001 From: Sean Davis Date: Wed, 25 Nov 2026 22:46:57 -0500 Subject: [PATCH 3/3] Show a note in ensemblVEP vignette when the REST API is unreachable When vep_by_region() fails, the dependent chunks are skipped but the rendered vignette gave readers no indication why. Add an asis chunk, evaluated only when vep_avail is FALSE, explaining that the code below was not run. Co-Authored-By: Claude --- vignettes/ensemblVEP.Rmd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vignettes/ensemblVEP.Rmd b/vignettes/ensemblVEP.Rmd index 3f4f010..564cef3 100644 --- a/vignettes/ensemblVEP.Rmd +++ b/vignettes/ensemblVEP.Rmd @@ -65,6 +65,12 @@ vep_avail = !is.null(res) if (vep_avail) jans = toJSON(content(res)) ``` +```{r vepnote, eval=!vep_avail, echo=FALSE, results="asis"} +cat("**Note:** the Ensembl REST API at https://rest.ensembl.org", + "could not be reached when this vignette was built, so the code", + "below is shown but was not run.\n") +``` + There are various ways to work with the result of this query to the API. We'll use the `r CRANpkg('rjsoncons')` JSON processing infrastructure to dig in and understand aspects of the API behavior.