kstagaman / sharpton-lab-dada2-pipeline

1 stars 0 forks source link

symlink_fastqs.R fails if absolute path name contains a space #1

Open sielerjm opened 2 years ago

sielerjm commented 2 years ago

Background:

I'm running this script locally and ran into an issue where the absolute path name to my fastq files contains a space and consequently causes the symlink_fastqs.R to fail when parsing the path name to run commands on the command line using system().

Error Message

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `ln -s /Users/michaelsieler/Dropbox/Mac (2)/Documents/Sharpton_Lab/Projects_Repository/Rules_of_Life/RoL_HeaterTrial2021/Data/Raw/Rerun/lane1-s230-index--GATCTACG-TAGTGTAG-TS030_RoL_RTF301_S230_R2_001.fastq.gz RTF301--R2.fastq.gz'
RTF301--R1.fastq.gz and RTF301--R2.fastq.gz are empty (link to/Users/michaelsieler/Dropbox/Mac (2)/Documents/Sharpton_Lab/Projects_Repository/Rules_of_Life/RoL_HeaterTrial2021/Data/Raw/Rerun/lane1-s230-index--GATCTACG-TAGTGTAG-TS030_RoL_RTF301_S230_R1_001.fastq.gz and /Users/michaelsieler/Dropbox/Mac (2)/Documents/Sharpton_Lab/Projects_Repository/Rules_of_Life/RoL_HeaterTrial2021/Data/Raw/Rerun/lane1-s230-index--GATCTACG-TAGTGTAG-TS030_RoL_RTF301_S230_R2_001.fastq.gz, respectively)

Error

The line of code where this error occurs is at line 117 in the symlink_fastqs.R function.

cmd1 <- paste("ln -s", read1.file, lnName.r1)

Proposed solution

Change: cmd1 <- paste("ln -s", read1.file, lnName.r1) to: cmd1 <- paste("ln -s", paste0("'", read1.file, "'"), lnName.r1)

Adding paste0("'", read1.file, "'") wraps single quotes around the absolute path names.

Lines needing changed

sielerjm commented 2 years ago

Similar error in dada2_finish.R at line 415.

Error

### Building phylogenetic tree...

sh: -c: line 0: syntax error near unexpected token `2'
sh: -c: line 0: `export OMP_NUM_THREADS=9; /Users/michaelsieler/Dropbox/Mac (2)/Documents/Sharpton_Lab/Bioinformatics_files/Symlinks/FastTree -nt -nosupport -quote -gtr -gamma -log dada2_1.26.0_2022-11-15_output/fasttree.log dada2_1.26.0_2022-11-15_output/asv_and_guide_seqs.align > dada2_1.26.0_2022-11-15_output/asv_and_guide_seqs.nwk'

Currently:

fasttree.path, " -nt -nosupport -quote -gtr -gamma -log ",

Proposed change:

paste0("'", fasttree.path, "'"), " -nt -nosupport -quote -gtr -gamma -log ",