bwa mem -t 8 GRCh38Decoy/Sequence/BWAIndex/genome.fa \
FastQ/sample1_R1.fastq.gz FastQ/sample1_R2.fastq.gz \
| samtools view -S -bo Mappings/sample1.bam -
samtools sort - o Mappings/sample1_sort.bam Mappings/sample1.bam
for sample in $@
do
bwa_mem -t 8 GRCh38Decoy/Sequence/BWAIndex/genome.fa \
FastQ/${sample}_R1.fastq.gz FastQ/${sample}_R2.fastq.gz \
| samtools view -S -bo Mappings/${sample}.bam
samtools sort - o Mappings/${sample}_sort.bam Mappings/${sample}.bam
done
cat SampleList.txt | xargs -n 1 qsub MappingPipeline.sh
for sample in $@
do
if [ ! -f $BASEDIR/Mappings/${sample}.bam ]
then
bwa_mem -t 8 GRCh38Decoy/Sequence/BWAIndex/genome.fa \
FastQ/${sample}_R1.fastq.gz FastQ/${sample}_R2.fastq.gz \
| samtools view -S -bo Mappings/${sample}.bam
if [ ! -f Mappings/${sample}_sort.bam ]
then
samtools sort - o Mappings/${sample}_sort.bam Mappings/${sample}.bam
fi
done
for sample in $@
do
if test FastQ/${sample}_R1.fastq.gz -nt $BASEDIR/Mappings/${sample}.bam \
|| test FastQ/${sample}_R2.fastq.gz -nt $BASEDIR/Mappings/${sample}.bam
then
bwa_mem -t 8 GRCh38Decoy/Sequence/BWAIndex/genome.fa \
FastQ/${sample}_R1.fastq.gz FastQ/${sample}_R2.fastq.gz \
| samtools view -S -bo Mappings/${sample}.bam
fi
if test Mappings/${sample}.bam -nt Mappings/${sample}_sort.bam
then
samtools sort - o Mappings/${sample}_sort.bam Mappings/${sample}.bam
fi
done
for sample in $@
do
if test FastQ/${sample}_R1.fastq.gz -nt $BASEDIR/Mappings/${sample}.bam \
|| test FastQ/${sample}_R2.fastq.gz -nt $BASEDIR/Mappings/${sample}.bam
then
bwa_mem -t 8 GRCh38Decoy/Sequence/BWAIndex/genome.fa \
FastQ/${sample}_R1.fastq.gz FastQ/${sample}_R2.fastq.gz \
| samtools view -S -bo Mappings/${sample}.bam
if [ $? -eq 0 ]
then
echo "Finished bwa_mem for $sample"
else
echo "bwa_mem failed for $sample"
exit 1
fi
fi
if test Mappings/{sample}.bam -nt Mappings/{sample}_sort.bam
then
samtools sort - o Mappings/{sample}_sort.bam Mappings/{sample}.bam
if [ $? -eq 0 ]
then
echo "Finished samtools sort for $sample"
else
echo "samtools sort failed for $sample"
exit 1
fi
fi
done
or use set -e
to exit script after a command fails (see here)
What about:
find FastQ -name *.fastq.gz | sort | xargs -n 2 qsub MappingPipeline.sh
all
) which requires all of your desired outputs as inputinclude
statements to import python codescript
command to execute a python script, giving it access to variables defined in the Snakefileinclude
statements to import rules from other Snakefilessnakemake -np
snakemake -n --dag | dot -Tsvg > dag.svg
snakemake -R RULENAME
snakemake -n -R `snakemake --list-input-changes`
$ snakemake -n -R `snakemake --list-params-changes`
snakemake --use-conda --cluster-config cluster_config.yaml --cluster "qsub -pe smp {cluster.num_cores} -l h_vmem={cluster.maxvmem}" -j 20
Workflow Management by Heath O’Brien is licensed under a Creative Commons Attribution 4.0 International License.