Biostrings: read*StringSet() functions leave open file handles
2
0
Entering edit mode
@gerhard-thallinger-1552
Last seen 5 weeks ago
Austria

When a file is read with any of the read*StringSet() functions, file handles are not closed. This prevents further operations on the file (e.g. deletion).

library(Biostrings)

fsource <- system.file(package="Biostrings", "extdata", "someORF.fa")
fdest <- basename(fsource)
file.copy(fsource, fdest, overwrite=TRUE)
# [1] TRUE
fseq <- readDNAStringSet(fdest)
file.remove(fdest)
# [1] FALSE
# Warning message:
# In file.remove(fdest) :
#   cannot remove file 'someORF.fa', reason 'Permission denied'

Checking for open file handles results in the following:

Rgui.exe           pid: 23312  type: File           384: C:\Users\xxx\Documents\someORF.fa
Rgui.exe           pid: 23312  type: File           38C: C:\Users\xxx\Documents\someORF.fa

Through invoking gc(), the open file handles are closed and the file can be deleted.

gc()
#          used  (Mb) gc trigger  (Mb) max used  (Mb)
# Ncells 2522803 134.8    5198228 277.7  2730967 145.9
# Vcells 4427580  33.8   10146329  77.5  6352280  48.5
file.remove(fdest)
# [1] TRUE

It would be helpful if this could be corrected in the upcoming Bioconductor release.


Environment:


R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

locale:
[1] LC_COLLATE=English_Austria.utf8  LC_CTYPE=English_Austria.utf8   
[3] LC_MONETARY=English_Austria.utf8 LC_NUMERIC=C                    
[5] LC_TIME=English_Austria.utf8    

time zone: Europe/Vienna
tzcode source: internal

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Biostrings_2.70.2   GenomeInfoDb_1.38.6 XVector_0.42.0      IRanges_2.36.0     
[5] S4Vectors_0.40.2    BiocGenerics_0.48.1

loaded via a namespace (and not attached):
[1] zlibbioc_1.48.0         compiler_4.3.3          tools_4.3.3            
[4] GenomeInfoDbData_1.2.11 RCurl_1.98-1.14         crayon_1.5.2           
[7] bitops_1.0-7
Biostrings • 422 views
ADD COMMENT
0
Entering edit mode

Confirmed on windows. Not observed on my linux instance. In other words, the removal succeeds on linux.

1
Entering edit mode
@herve-pages-1542
Last seen 2 days ago
Seattle, WA, United States

Thanks for the report.

This should be addressed in Biostrings 2.70.3 (BioC 3.18) and Biostrings 2.71.4 (BioC devel). See here and here.

Both versions should become available to BioC 3.18 and BioC devel users via BiocManage::install() in the next 24 hours or so.

Note that I don't have an easy way to test this on Windows at the moment. Don't hesitate to let me know how that works for you. Thanks again.

Best,

H.

ADD COMMENT
0
Entering edit mode

Thanks, Hervé, for addressing this issue so quickly.

However, still only Biostrings 2.70.2 seems to be available.

Best,

Gerhard

ADD REPLY
0
Entering edit mode

Should be available now: https://bioconductor.org/packages/3.18/Biostrings

(I forgot that we build/check release only every other day.)

ADD REPLY
0
Entering edit mode
@gerhard-thallinger-1552
Last seen 5 weeks ago
Austria

Note that I don't have an easy way to test this on Windows at the moment. Don't hesitate to let me know how that works for you.

I upgraded to Biostrings 2.70.3; the file handles are now closed and file.remove() succeeds.

Thanks again,

Gerhard

ADD COMMENT

Login before adding your answer.

Traffic: 514 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6