GWW / scsnv

scSNV Mapping tool for 10X Single Cell Data
MIT License
22 stars 4 forks source link

Barcode files not generated when using variable as folder name #33

Closed DLuong79 closed 6 months ago

DLuong79 commented 6 months ago

I'm handling a large number of samples at once, so it's more efficient for me to assign the folder paths as a variable and run those in a loop. Example:

samples=(/data/sample1 /data/sample2 /data/sample3)
for sample in "${samples[@]}"; do
    scsnv count -o  "$sample"/barcode -k scsnv/data/737K-august-2016.txt -l V2 "$sample"/fastq

While the count function can detect the fastq's, it's not generating the barcode file necessary for the next step. Is there are special syntax I need to use so that the command can recognize "$sample"/barcode as a valid output path?

GWW commented 6 months ago

It may be the quotes you are using in the command. I have used similar shell scripts in the past without issue:

scsnv count -o  ${sample}/barcode -k scsnv/data/737K-august-2016.txt -l V2 ${sample}/fastq
DLuong79 commented 6 months ago

I figured out what was going on. I have to use double quotes in the code because the folder path I'm specifying has spaces in them (e.g. sample="Path to/sample 1"), so I can't use curly braces. When running the code with the actual directory name instead of a variable name, I'd use \ to replace the spaces (e.g. -o Path\ to/sample\ 1/barcode). However, I was defining the variable using double-quotes and the escape backslashes (sample="Path\ to/sample\ 1"), causing the value to include the escape backslashes instead of treating them as normal spaces. Once I took out the escape slashes, everything worked as normal.