Skip to content

Instantly share code, notes, and snippets.

@mtw
Last active December 28, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtw/7456798 to your computer and use it in GitHub Desktop.
Save mtw/7456798 to your computer and use it in GitHub Desktop.
Wrapper script for paired-end cutadapt
#!/bin/bash
cutadapt=`which cutadapt`
fastqc=`which fastqc`
origdir=".."
results="."
fastqcdir="${results}/FastQC"
adapter5="CTACACTCTTTCCCTACACGACGCTCTTCCGATCT"
adapter3="GATCGGAAGAGCACACGTCTGAACTCCAGTCAC"
inprefix="C"
outprefix="D"
samples=2
replicates=3
if ! [ -d "$results" ];
then
mkdir -p $results
fi
if ! [ -d "$fastqcdir" ];
then
mkdir -p $fastqcdir
fi
for s in $(seq 1 $samples)
do
for r in $(seq 1 $replicates)
do
sample=${inprefix}${s}_R${r}
outsample=${outprefix}${s}_R${r}
echo "processing $sample"
rd1="${origdir}/${sample}_1.fastq"
rd2="${origdir}/${sample}_2.fastq"
outrd1="${results}/${outsample}_1.fastq"
outrd2="${results}/${outsample}_2.fastq"
echo "infiles $rd1 && $rd2"
echo "outfiles $outrd1 && $outrd2"
if ! [ -f "$rd1" ];
then
echo "ERROR: $rd1 not available"
fi
if ! [ -f "$rd2" ];
then
echo "ERROR: $rd2 not available"
fi
set -x
# run cutadapt in paired-end mode
$cutadapt -q 30 -m 25 -g $adapter5 -a $adapter3 --paired-output tmp.2.fastq -o tmp.1.fastq $rd1 $rd2 1> cutadapt_${sample}.run1.out 2> cutadapt_${sample}.run1.err
$cutadapt -q 30 -m 25 -g $adapter5 -a $adapter3 --paired-output $outrd1 -o $outrd2 tmp.2.fastq tmp.1.fastq 1> cutadapt_${sample}.run2.out 2> cutadapt_${sample}.run2.err
# remove temp files
rm tmp.1.fastq tmp.2.fastq
# run FastQC
$fastqc --quiet --noextract -o $fastqcdir -t 16 $outrd1
$fastqc --quiet --noextract -o $fastqcdir -t 16 $outrd2
# gzip output
gzip $outrd1 &
gzip $outrd2 &
set +x
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment