wzthu / Rbowtie2

Bioconductor package: an R wrapper for Bowtie2 and AdapterRemoval
https://www.bioconductor.org/packages/release/bioc/html/Rbowtie2.html
3 stars 5 forks source link

`Rbowtie2::bowtie2_samtools`: print to console during processing #3

Open bschilder opened 2 years ago

bschilder commented 2 years ago

Hi there, thanks for the great tool!

I'm incorporating Rbowtie2::bowtie2_samtools into my epigenomics pipeline, and I noticed the messages while running it:

arguments 'show.output.on.console', 'minimized' and 'invisible' are for Windows only

This means that for non-Windows user, they won't see any of the bowtie2 output until everything is done processing (which can be a very long time). This make is difficult for users to assess whether the program is working or there has been some error and it's just hanging there.

Looked into the internal code and found that this is because .callBinary is using system(..., internal=TRUE).

I'm wondering if there's a way to both capture the output and print it to the user during processing. For instance, perhaps you could take advantage of the fact that bowtie2 is running in the command line and pipe its output to a text file. Here's an example of how we've done this in the past:

bowtie2 \
--local \ 
--very-sensitive \
--no-mixed \
--no-discordant \
--phred33 \
-I 10 \
-X 700 \
-p ${cores} \
-x ${ref} \
-1 ${datadir}/data_trimmed/${sample_name}_val_1.fq.gz \
-2 ${datadir}/data_trimmed/${sample_name}_val_2.fq.gz \
-S ${outdir}/${sample_name}_trimmed_bowtie2.sam &> ${outdir}/bowtie2_summary/${sample_name}_trimmed_bowtie2.txt

The CRAN package sys may or may not be helpful here too.

bschilder commented 2 years ago

Also, it could be helpful to let users specify whether they want the process to run in the background, so that they can continue using their R session while bowtie2 is running (which could take many hours). e.g via sys::exec_background()

wzthu commented 2 years ago

Thank you for your suggestions. We will try sys package to capture the output this week. Once it is done, I will let you know.