Entering edit mode
4.9 years ago
whelenakanya
•
0
rule sortBAM_bbb:
input:
inBAM = '{PATH}/{sample}.bam'
output:
outBAM = '{PATH}/{sample}.biobambam.sorted.bam'
params:
sortby = config['sortby_bbb'],
log:
log_samtools = config['logs']['bamUtil'] + '{PATH}/sortBAM_bbb_{sample}.' + strftime("%Y-%m-%d.%H-%M-%S", localtime()) + '.samtools.log',
log_bamsort = config['logs']['bamUtil'] + '{PATH}/sortBAM_bbb_{sample}.' + strftime("%Y-%m-%d.%H-%M-%S", localtime()) + '.bamsort.log'
shell:
'samtools view -b {input.inBAM} &> {log.log_samtools} | bamsort SO={params.sortby} tmpfile={output.outBAM}[:-4].tmp > {output.outBAM} &> {log.log_bamsort}'
I am wondering why this piece of code returns this error:
SyntaxError:
Not all output, log and benchmark files of rule sortBAM_bbb contain the same wildcards. This is crucial though, in order to avoid that two or more jobs write to the same file.
I tried the following code and it works, I just don't want the log files to be buried under many directories (the initial PATH wildcard is about 3-4 directories deep).
rule sortBAM_bbb:
input:
inBAM = '{sample}.bam'
output:
outBAM = '{sample}.biobambam.sorted.bam'
params:
sortby = config['sortby_bbb'],
log:
log_samtools = config['logs']['bamUtil'] + '/sortBAM_bbb/{sample}.' + strftime("%Y-%m-%d.%H-%M-%S", localtime())
+ '.samtools.log',
log_bamsort = config['logs']['bamUtil'] + '/sortBAM_bbb/{sample}.' + strftime("%Y-%m-%d.%H-%M-%S", localtime())
+ '.bamsort.log'
shell:
'samtools view -b {input.inBAM} &> {log.log_samtools} | bamsort SO={params.sortby} tmpfile={output.outBAM}[:-4].tmp > {output.outBAM} &> {log.log_bamsort}'