forked from cguccione/human_host_filtration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_fastp.sh
35 lines (28 loc) · 967 Bytes
/
filter_fastp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash -l
# author: Lucas Patel ([email protected])
# date: 12/22/23
# description: Script to run fastp on R1/R2 or interleaved FASTQ inputs as part of a full host filtration pipeline.
set -e
set -o pipefail
config_fn=$3
source $config_fn
conda activate $CONDA_ENV_NAME
strip_extensions() {
local file_name="$1"
local stripped_name="${file_name%.fastq.gz}"
stripped_name="${stripped_name%.fastq}"
echo "$stripped_name"
}
process_fastp() {
local r1=$1
local r2=$2
local base_name=$(strip_extensions "$r1")
local fastp_options="-l 100 -w ${THREADS} --adapter_fasta ${ADAPTERS} --html /dev/null --json /dev/null --stdout -i ${r1}" # --interleaved_in"
if [[ -n "${r2}" && -f "${r2}" ]]; then
fastp_options+=" -I ${r2}"
fi
mkdir -p ${OUT}/fastp
echo "fastp ${fastp_options} > ${OUT}/fastp/$(basename "$base_name").FASTP.fastq"
fastp ${fastp_options} > "${OUT}/fastp/$(basename "$base_name").FASTP.fastq"
}
process_fastp "$1" "$2"