Custom scripts for 16S rRNA sequence analysis

merge_paired_fastq.sh

#!/bin/bash
#
# modified from 'Merge_Reads_Script.sh' available from:
# https://github.com/edamame-course/Amplicon_Analysis/blob/master/resources/Merged_Reads_Script.sh
#

out=merged_dir

if [ ! -d merged_reads ]; then
    echo Creating ${out} directory...
    mkdir ${out}
fi

for f in *F_sub.*
do

    if [ ! -e ${f} ]; then
        echo Can\'t find 'F_sub' reads!
        echo You have to set fwd/rev read indicators in this script!
        exit
    fi

    r=$(sed -e "s/F_sub/R_sub/" <<< "$f")
    file=$(cut -d_ -f1 <<< "$f")
    echo Processing ${f} and ${r} '===>' ${out}/${file}_merged.fastx
    join_paired_ends.py -f ${f} -r ${r} -o ${file}/
    mv ${file}/fastqjoin.join.fastq ${out}/${file}_merged.fastq
    convert_fastaqual_fastq.py -c fastq_to_fastaqual -f ${out}/${file}_merged.fastq -o ${out}/${file}
    mv ${out}/${file}/${file}_merged.fna ${out}/${file}_merged.fasta
    rm -r ${out}/${file}
    rm -r ${file}/
done