R and sra toolkit – odd system() behavior ( R, System )

Problem :
( Scroll to solution )

In order to extract some fastq data from NCBI’s sequence read archive I’ve downloaded and installed the sra toolkit for Windows. In order to test if it is setup correctly, I opened cmd, navigated to the directory and typed in the command fasterq-dump –split-files SRR7647019. It downloads the file SRR7647019.sra as expected and splits it into fastq files.

Then I’ve tried the same command in RStudio, wrapping the system() command around it: system(fasterq-dump –split-files SRR7647019). However, R always returns

An error occured: unrecognized tool FASTER~2.EXE
If this continues to happen, please contact the SRA Toolkit at trace.ncbi.nlm.nih.gov/Traces/sra/

as well as the number 75 (probably an error code).

Any idea why I’m not able to run fasterq-dump.exe from R? How could it be solved?

Thanks a lot for suggestions in advance!

Sometimes it helps to call the terminal shell explicitly to bypass the environmental variables which might get overwritten by RStudio:

system("cmd.exe /k fasterq-dump --split-files SRR7647019")

Read more here: Source link