I am trying to combine some rules. The rule1 creates in automatics {sample}_unmapped.bam
file taking information from library_params.txt
file, which I cannot specify as output as program outputs it itself, but which I need to use in the rule2. Is there a way for program to attend the rule1 to finish and then run rule2 using the output from rule1? Because the error it is giving me now is: {sample}_unmapped.bam file is missing
.
rule rule1:
input:
basecalls_dir="/RUN1/Data/Intensities/BaseCalls/",
barcodes_dir=directory("barcodes"),
library_params="library_params.txt",
metrics_file="metrics_output.txt"
output:
log="barcodes.log"
shell:
"""
java -Djava.io.tmpdir=/path/to/tmp -Xmx2g -jar picard.jar IlluminaBasecallsToSam BASECALLS_DIR={input.basecalls_dir} BARCODES_DIR={input.barcodes_dir} LANE=1 READ_STRUCTURE=151T8B9M8B151T RUN_BARCODE=run1 LIBRARY_PARAMS={input.library_params} MOLECULAR_INDEX_TAG=RX ADAPTERs_TO_CHECK=INDEXED READ_GROUP_ID=BO NUM_PROCESSORS=2 IGNORE_UNEXPECTED_BARCODES=true > {output.log}
"""
rule rule2:
input:
log="barcodes.log",
infile="{sample}_unmapped.bam"
params:
ref="ref.fasta"
output:
outfile="{sample}.mapped.bam"
shell:
"""
java -Djava.io.tmpdir=/path/to/tmp -Xmx2g -jar picard.jar SamToFastq I={input.infile} F=/dev/stdout INTERLEAVE=true | bwa mem -p -t 7 {params.ref} /dev/stdin | java -Djava.io.tmpdir=/path/to/tmp -Xmx4g -jar picard.jar MergeBamAlignment UNMAPPED={input.infile} ALIGNED=/dev/stdin O={output.outfile} R={params.ref} SORT_ORDER=coordinate MAX_GAPS=-1 ORIENTATIONS=FR
In rule2
I would move infile="{sample}_unmapped.bam"
from the input directive to the params directive. And of course you would change the shell script from I={input.infile}
to I={params.infile}
.
rule2
will still wait for rule1
to complete because you give barcodes.log
as input to rule2
.