Small bug in function 'countskip.FASTA.entries' from package 'altcdfenvs'
1
0
Entering edit mode
@norman-pavelka-1214
Last seen 10.3 years ago
Dear Laurent Gautier, First of all, let me express my gratitudine and compliments for the very important package you contributed and I apologize for this long message (that I am CCing to the BioC list). I'm currently using 'altcdfenvs' to re-map probe sequences from Affy MOE430 2.0 arrays and I noticed a small but reproducible bug in the function 'countskip.FASTA.entries'. When I follow the vignette step-by-step, no errors show up in my session: library(altcdfenvs) fasta.filename <- "Mus_musculus.NCBIM34.nov.cdna.fa" con <- file(fasta.filename, open = "r") n <- countskip.FASTA.entries(con) close(con) cat(n,"entries read\n") Of course, I can cut and paste the same chunk of code into a brand new R function and save the file: test.countskip.FASTA.entries <- function(fasta.filename) { library(altcdfenvs) con <- file(fasta.filename, open = "r") n <- countskip.FASTA.entries(con) close(con) cat(n,"entries read\n") } And, of course, I can source the function from the new file and again I have no errors, if I run: test.countskip.FASTA.entries("Mus_musculus.NCBIM34.nov.cdna.fa") But _magically_, if I close the R session, reload R and source the file containing my function, I get the following error: > test.countskip.FASTA.entries("Mus_musculus.NCBIM34.nov.cdna.fa") Loading required package: Biobase Loading required package: tools Welcome to Bioconductor Vignettes contain introductory material. To view, simply type 'openVignette()' or start with 'help(Biobase)'. For details on reading vignettes, see the openVignette help page. Loading required package: affy Loading required package: matchprobes Loading required package: makecdfenv Error in readLines(con, n = 1) : object "con" not found Why? When I inspected the source of function 'countskip.FASTA.entries', I noticed that the argument defining the connection to the file containing the FASTA entries was missing. The function was therefore using the 'con' object found in the global environment, rather than the one passed as an argument. But when R was reloaded, the 'con' object disappeared and the error showed up. In other words, the vignette code chunk worked fine for me just by chance! ;-) I thus changed the function in the following way: ### My personal modification of function 'countskip.FASTA.entries' ### to allow a file connection to be passed to the function my.countskip.FASTA.entries <- function (con, linebreaks = 3000) { i <- as.integer(0) fs <- read.FASTA.entry(con) while (!identical(fs$header, character(0)) && !identical(fs$sequence, NULL)) { i <- i + 1 fs <- read.FASTA.entry(con) } return(i) } ### End of my modified function When I now modify my test function to use 'my.countskip.FASTA.entries' instead of 'countskip.FASTA.entries', I have no errors regardless whether I'm working in a fresh or older R session... In addition, now I'm allowed to have more than one file connection around and specify the one I would like to pass to 'my.countskip.FASTA.entries'... BTW, what is the argument 'linebreaks' good for? It seems not to be used inside the function... Hope this feed-back was worth reporting! Thank you again and best wishes, Norman > sessionInfo() R version 2.2.0, 2005-10-06, powerpc-apple-darwin7.9.0 attached base packages: [1] "tools" "methods" "stats" "graphics" "grDevices" "utils" [7] "datasets" "base" other attached packages: altcdfenvs makecdfenv matchprobes affy Biobase "1.4.0" "1.8.0" "1.2.1" "1.8.1" "1.8.0" Norman Pavelka Department of Biotechnology and Bioscience University of Milano-Bicocca Piazza della Scienza, 2 20126 Milan, Italy Phone: +39 02 6448 3556 Fax: +39 02 6448 3552
probe affy makecdfenv matchprobes altcdfenvs probe affy makecdfenv matchprobes altcdfenvs • 1.1k views
ADD COMMENT
0
Entering edit mode
@lgautieralternorg-747
Last seen 10.3 years ago
> Dear Laurent Gautier, > > First of all, let me express my gratitudine and compliments for the > very important package you contributed and I apologize for this long > message (that I am CCing to the BioC list). > > I'm currently using 'altcdfenvs' to re-map probe sequences from Affy > MOE430 2.0 arrays and I noticed a small but reproducible bug in the > function 'countskip.FASTA.entries'. > <snip> > Why? > > When I inspected the source of function 'countskip.FASTA.entries', I > noticed that the argument defining the connection to the file > containing the FASTA entries was missing. The function was therefore > using the 'con' object found in the global environment, rather than the > one passed as an argument. But when R was reloaded, the 'con' object > disappeared and the error showed up. In other words, the vignette code > chunk worked fine for me just by chance! ;-) ?! I thought I fixed that some time ago !! Well, it seems I did not. But anyway, congratulations for tracking that sneaky one down ! > I thus changed the function in the following way: > > ### My personal modification of function 'countskip.FASTA.entries' > ### to allow a file connection to be passed to the function > my.countskip.FASTA.entries <- function (con, linebreaks = 3000) { > i <- as.integer(0) > fs <- read.FASTA.entry(con) > while (!identical(fs$header, character(0)) && !identical(fs$sequence, > NULL)) { > i <- i + 1 > fs <- read.FASTA.entry(con) > } > return(i) > } > ### End of my modified function > > When I now modify my test function to use 'my.countskip.FASTA.entries' > instead of 'countskip.FASTA.entries', I have no errors regardless > whether I'm working in a fresh or older R session... In addition, now > I'm allowed to have more than one file connection around and specify > the one I would like to pass to 'my.countskip.FASTA.entries'... > > BTW, what is the argument 'linebreaks' good for? It seems not to be > used inside the function... hoho... one more glitch... "linebreaks" should be passed to "read.FASTA.entry". > Hope this feed-back was worth reporting! It surely was worth reporting it. Thanks for this. Fixes should be in the repository during the week-end. Best, Laurent > Thank you again and best wishes, > Norman > > > sessionInfo() > R version 2.2.0, 2005-10-06, powerpc-apple-darwin7.9.0 > > attached base packages: > [1] "tools" "methods" "stats" "graphics" "grDevices" "utils" > [7] "datasets" "base" > > other attached packages: > altcdfenvs makecdfenv matchprobes affy Biobase > "1.4.0" "1.8.0" "1.2.1" "1.8.1" "1.8.0" > > Norman Pavelka > Department of Biotechnology and Bioscience > University of Milano-Bicocca > Piazza della Scienza, 2 > 20126 Milan, Italy > > Phone: +39 02 6448 3556 > Fax: +39 02 6448 3552 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor >
ADD COMMENT

Login before adding your answer.

Traffic: 915 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