Dear colleague,
I am developing an R package for which I want to provide error handling when warning/error messages are produced by Rsamtools. Specifically, I would like to test whether there any truncated files in a list of BAM files. When using the following command:
indexBam(bamFile)
I will get the following message:
[bam_header_read] EOF marker is absent. The input is probably truncated.
I have tried to capture this event in R, but this fails using tryCatch (no warning or error is raised), and also sink() or capture.output() does not capture this event (likely because the message is created by the C core underlying Rsamtools).
My question is how I could detect that this message is printed, and thus that there are truncated BAM files present.
Thank you very much for your help,
Thomas
My sessionInfo() is below:
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] Rsamtools_1.12.4 Biostrings_2.28.0 GenomicRanges_1.12.5
[4] IRanges_1.18.3 BiocGenerics_0.6.0
loaded via a namespace (and not attached):
[1] bitops_1.0-6 stats4_3.1.1 tools_3.1.1 zlibbioc_1.6.0
Hi Martin,
Thanks for your comments; they partly solved the problem. I will continue the discussion via the bioc-devel mailing list.
Thomas