Question: MACS2: Albeit outdir definition, my output goes to folder of input
0
gravatar for gdeniz
2.5 years ago by
gdeniz0
San Francisco
gdeniz0 wrote:

Hi, I seem to have a problem getting my output in the right location. Using the following call..

workdir="$1"
files=($(awk '{print $1}' $2 ))
infile="$workdir"/bam/${files[$SGE_TASK_ID]}.sorted.dedup.bam 
macs2 predictd -i $infile -f BAM -g mm -m 5 50 --outdir "$workdir"/macs2/qc --rfile ${$infile%.sorted.dedup.bam}_model.r

..my input goes to $workdir/bam

Any suggestions? Thanks!

chip-seq macs2 • 643 views
ADD COMMENTlink written 2.5 years ago by gdeniz0
2
gravatar for Ram
2.5 years ago by
Ram32k
Baylor College of Medicine, Houston, TX
Ram32k wrote:

Your quoting is off by a bit. Here is some cleaned up code:

workdir="$1"
files=($(awk '{print $1}' $2 ))
infile="${workdir}/bam/${files[$SGE_TASK_ID]}.sorted.dedup.bam"
macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r

The double quotes should work with the parameter expansion quotes ({}), not isolate the variable to an extent that it renders the context meaningless. EDIT: Your style of quoting is not wrong, it's just different. Sorry!

ADD COMMENTlink modified 2.5 years ago • written 2.5 years ago by Ram32k

Thanks for your suggestions, always happy to improve my quoting. Unfortunately, this didn't seem to solve the issue:

INFO  @ Tue, 04 Sep 2018 08:41:05: # Generate R script for model : /mnt/iscsi_speed/bam/SRR1202461_model.r

Any other ideas? Do you think it is a quoting issue?

ADD REPLYlink written 2.5 years ago by gdeniz0

Can you verify that the command looks OK? Change the last line to

echo "macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir \"${workdir}/macs2/qc\" --rfile ${$infile%.sorted.dedup.bam}_model.r"

Also, it would help if you could give an example of how you invoke the script, with actual parameters.

ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by Ram32k

I get the following error:

/opt/sge625/sge/default/spool/go-node-38/job_scripts/114466: line 17: macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r: bad substitution

Here an attempt to clarify my parameters:

workdir="/mnt/iscsi_speed"
samples="${workdir}/samplesheet.txt"  #tab-separated text file with file basename in first column
files=($(awk '{print $1}' $samples ))
infile="${workdir}/bam/${files[0]}.sorted.dedup.bam"
macs2 predictd -i ${infile} -f BAM -g mm -m 5 50 --outdir "${workdir}/macs2/qc" --rfile ${$infile%.sorted.dedup.bam}_model.r
ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by gdeniz0
1

Should've spotted this early on: change ${$infile%.sorted.dedup.bam} to ${infile%.sorted.dedup.bam}

ADD REPLYlink written 2.5 years ago by Ram32k

Here is the echo'd output:

macs2 predictd -i /mnt/iscsi_speed/blelloch/deniz/buecker2014/naive/bam/SRR1202453.sorted.dedup.bam -f BAM -g mm -m 5 50 --outdir "/mnt/iscsi_speed/macs2/qc" --rfile /mnt/iscsi_speed/bam/SRR1202453_model.r
ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by gdeniz0

That echo call made me realize what is wrong:

the $infile variable seems to overwrite the output dir because it contains an absolute path. Changing the call option to:

--rfile $(basename ${infile%.sorted.dedup.bam}_model.r)

solves the problem.

Thanks for pointing me towards the answer!

ADD REPLYlink written 2.5 years ago by gdeniz0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2425 users visited in the last hour
_