Select Git revision
bowtie2_mapping.rules
bowtie2_mapping.rules 2.92 KiB
#########################################################################
# RNAsig: an automated pipeline to detect RNA signatures on viruses #
# #
# Authors: Rachel Legendre #
# Copyright (c) 2020-2021 Institut Pasteur (Paris). #
# #
# This file is part of RNAsig workflow. #
# #
# RNAsig is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# RNAsig is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details . #
# #
# You should have received a copy of the GNU General Public License #
# along with RNAsig (LICENSE). #
# If not, see <https://www.gnu.org/licenses/>. #
#########################################################################
rule bowtie2_mapping:
input:
fastq = __bowtie2_mapping__input,
index = __bowtie2_mapping__index_done
output:
sort = __bowtie2_mapping__sort,
bam = temp(__bowtie2_mapping__bam)
singularity:
"rnasig.img"
log:
err = __bowtie2_mapping__logs_err,
out = __bowtie2_mapping__logs_out
params:
prefix_index = __bowtie2_mapping__prefix_index,
options = __bowtie2_mapping__options,
prefix = temp(__bowtie2_mapping__sortprefix)
threads:
config["bowtie2_mapping"]["threads"]
shell:
"""
set +o pipefail
tmp="{input.fastq}"
infiles=($tmp)
cmd="bowtie2 -p {threads} {params.options} -x {params.prefix_index}"
# paired end or single end
if [[ ${{#infiles[@]}} -eq 2 ]]
then
bowtie_input="-1 ${{infiles[0]}} -2 ${{infiles[1]}}"
else
bowtie_input="-U ${{infiles[0]}} "
fi
cmd+=" ${{bowtie_input}}"
# sam to bam
cmd+=" | samtools view -Sbh - > {output.bam}"
# logs
cmd="(${{cmd}}) > {log.out} 2> {log.err}"
# sort result
cmd+=" && samtools sort -o {output.bam} {params.prefix} > {output.sort} "
cmd+=" && samtools index {output.sort}"
#run command
eval "${{cmd}}"
"""