-
Notifications
You must be signed in to change notification settings - Fork 8
/
trimming.sh
executable file
·86 lines (80 loc) · 2.24 KB
/
trimming.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Testing version of trimming sequencing data
# Zhou (Ark) Fang [email protected]
# e.g. ./trimming.sh -i ./RNAseq_files -s -a1 ADATPER_FWD -a2 ADATPER_REV
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i|--inPath)
inPath="$2"
shift # past argument
shift # past value
;;
-s|--singleEnd)
singleEnd=true
shift # past argument
;;
-a1|--adapter1)
adapter1="$2"
shift # past argument
shift # past value
;;
-a2|--adapter2)
adapter2="$2"
shift # past argument
shift # past value
;;
--default)
DEFAULT=true
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# echo FILE EXTENSION = "${EXTENSION}"
if [ $DEFAULT = true ]; then
inPath=./RNAseq_files #intermidiate input file path for trimming
singleEnd=false #by default, subject to change
adapter1=ADATPER_FWD
adapter2=ADATPER_REV
fi
if [ "$singleEnd" = true ] ; then
echo 'Single-end sequencing file used'
for f in $inPath/*.fastq.gz; do
fileName=$(echo ${f})
if [[ $fileName != *"trimmed"* ]]; then
echo $fileName
echo "Processing $fileName file"
suffix=".fastq.gz"
outfileName=${fileName%$suffix}
outfileName+="_trimmed.fastq.gz"
echo $outfileName
cutadapt -a $adapter1 -m 20 -o $outfileName $fileName &
fi
done
wait
else
echo 'Pair-end sequencing files used'
for f in $inPath/*1.fastq.gz; do
fileName1=$(echo ${f})
if [[ $fileName != *"trimmed"* ]]; then
suffix="1.fastq.gz"
fileName2=${fileName1%$suffix}
fileName2+="2.fastq.gz"
echo "Processing $fileName1 and $fileName2 files..."
outfileName1=${fileName1%$suffix}
outfileName2=${fileName1%$suffix}
outfileName1+="1_trimmed.fastq.gz"
outfileName2+="2_trimmed.fastq.gz"
cutadapt -a $adapter1 -A $adapter2 -m 20 -o $outfileName1 $outfileName2 $fileName1 $fileName2 &
fi
done
wait
fi
echo "Sequencing trimming completed."