jorainer / ensembldb

This is the ensembldb development repository.
https://jorainer.github.io/ensembldb
33 stars 10 forks source link

Suppressing unwanted warnings during `ensDbFromGtf()` call #113

Closed mjsteinbaugh closed 3 years ago

mjsteinbaugh commented 3 years ago

Hi, I'm writing a wrapper for ensDbFromGtf in my AcidGenomes package (see makeEnsDbFromGFF code for details).

I'm having trouble suppressing some unwanted connection messages:

library(ensembldb)
gtf <- paste0(
    "ftp://ftp.ensembl.org/pub/release-102/gtf/",
    "homo_sapiens/Homo_sapiens.GRCh38.102.gtf.gz"
)
suppressWarnings({
    suppressMessages({
        sqlite <- ensDbFromGtf(gtf = gtf, outfile = tempfile())
        edb <- EnsDb(x = sqlite)
        file.remove(sqlite)
    })
})

## Ghosts in the machine we should fix:
## Warning: call dbDisconnect() when finished working with a connection
## Warning in UseMethod("seq") :
##   closing unused connection 3 (ftp://ftp.ensembl.org/pub/release-102/mysql/)

genes <- genes(edb)
length(genes)
## [1] 60675

transcripts <- transcripts(edb)
length(transcripts)
## [1] 232024

Any tips for improving this and removing the unwanted warnings?

Best, Mike

jorainer commented 3 years ago

The ## Warning: call dbDisconnect() when finished working with a connection warning is strange as I make sure to close all connections with on.exis(dbDisconnect(con)). Also, I can not reproduce this warning locally on my computer.

For the second one, that seems to come from curl.

What puzzles me is that you can't suppress these even with suppressWarnings and suppressMessages. Seems to be some low level functionality then (e.g. in C++/C code of the curl package)?

I will have a closer look at the code in ensembldb to see if I can do something there...

mjsteinbaugh commented 3 years ago

Weird right? I've seen this call dbDisconnect() warning pop up intermittely with AnnotationHub before (see https://github.com/Bioconductor/AnnotationHub/issues/1), and it seems to be persisting in the latest release of Bioconductor. I don't think this is due to any of the underlying code in ensembldb.

mjsteinbaugh commented 3 years ago

Seems like this is safe to close too. Thanks!