Skip to content

Commit

Permalink
Let submitter parse input file name patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Sep 11, 2022
1 parent 4a8aa71 commit 553b8ac
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions Adapting_new_script_for_computing_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,32 @@ usage() {

submit() {
mkdir -p $log_dir
for id in $(cd $fastq_dir && ls *.fastq | rev | cut -c 9- | rev | uniq); do
"${MXQSUB[@]}" --stdout "$log_dir/$id.out" "$0" --execute "$id"
shopt -s nullglob

# input files "blabla_R_1.fastq" , "blabla_R_2.fastq"
#
# --> id "blabla_R" ( "_R" included for historical reasons )
# --> f1 "blabla_R_1.fastq"
# --> f2 "blabla_R_2.fastq"
#
for f1 in $fastq_dir/*_R_1.fastq; do
id=$(basename ${f1%%_1.fastq})00
f1=${id}_1.fastq
f2=${id}_2.fastq
if [ ! -e $fastq_dir/$f2 ]; then
echo "no _2.fastq file for $f1"
continue
fi
"${MXQSUB[@]}" --stdout "$log_dir/$id.out" "$0" --execute "$id" "$f1" "$f2"
done
}

execute() {
set -xe

id="$1"
f1="$2"
f2="$3"

cd $MXQ_JOB_TMPDIR

Expand All @@ -54,16 +71,16 @@ execute() {

: Running FastQC on $id

/project/RNAseq_Mdl_data/Konrad/FastQC/fastqc fastq/${id}_1.fastq --outdir fastqc
/project/RNAseq_Mdl_data/Konrad/FastQC/fastqc fastq/${id}_2.fastq --outdir fastqc
/project/RNAseq_Mdl_data/Konrad/FastQC/fastqc fastq/$f1 --outdir fastqc
/project/RNAseq_Mdl_data/Konrad/FastQC/fastqc fastq/$f2 --outdir fastqc

: Trimming $id with trim_galore

prun python3 trim_galore --paired --nextera -j $THREADS fastq/${id}_1.fastq fastq/${id}_2.fastq >> $id.trimmingStats.txt 2>&1
prun python3 trim_galore --paired --nextera -j $THREADS fastq/$f1.fastq fastq/$f2.fastq >> $id.trimmingStats.txt 2>&1

: Mapping $id with bowtie2

bowtie2 --very-sensitive-local --no-mixed -p $THREADS --no-discordant --phred33 -I 10 -X 2000 -x $ebwt -1 ${id}_1_val_1.fq -2 ${id}_2_val_2.fq \
bowtie2 --very-sensitive-local --no-mixed -p $THREADS --no-discordant --phred33 -I 10 -X 2000 -x $ebwt -1 ${f1}_val_1.fq -2 ${f2}_val_2.fq \
-S $id.sam >> $id\.mappingStats.txt 2>&1

: Creating BAM files for $id and filtering for paired and mapped reads
Expand Down Expand Up @@ -125,8 +142,8 @@ cp dedup_peaks/* $work_dir/dedup_peaks

if [ $# = 1 -a "$1" = --submit ]; then
submit
elif [ $# = 2 -a "$1" = --execute ]; then
execute "$2"
elif [ $# = 4 -a "$1" = --execute ]; then
execute "$2" "$3" "$4"
else
usage
fi

0 comments on commit 553b8ac

Please sign in to comment.