-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract_lcscience_inserts.sh
executable file
·108 lines (84 loc) · 2.11 KB
/
extract_lcscience_inserts.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# extract_lcscience_inserts.sh
#
#
# Created by Bruno Costa on 21/05/2105
# Copyright 2015 ITQB / UNL. All rights reserved.
#
# Call: extract_lcscience_inserts.sh [LIB_FIRST] [LIB_LAST] [TEMPLATE]
#Name inputs
#LIB=$1
set -e
LIB_FIRST=$1
LIB_LAST=$2
TEMPLATE=$3
#Gets the script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
#Get config settings
. $DIR/"config/workdirs.cfg"
#Setting up log dir
mkdir -p $workdir"/log/"
log_file=$workdir"/log/"$(date +"%y%m%d:%H%M%S")":PPID$PPID:fastq_to_fasta_LC:$1-$2.log"
echo $(date +"%y/%m/%d-%H:%M:%S")" - "$(basename ${log_file})
exec 2>&1 > ${log_file}
SCRIPT_DIR=$DIR"/scripts/"
START_TIME=$(date +%s.%N)
#Chosses run mode based on input arguments
if [[ -z $2 || -z $3 ]]; then
EXTRACT_LIB=$LCSCIENCE_LIB
LIB=$LIB_FIRST
${SCRIPT_DIR}extract_lcscience.sh ${DIR} ${LIB} ${EXTRACT_LIB}
${SCRIPT_DIR}fq_to_fa_exe.sh ${workdir} ${LIB}
${SCRIPT_DIR}trim-lcscience.sh ${DIR} ${LIB}
else
#Running various threads
NPROC=0
cycle=$(eval echo {${LIB_FIRST}..${LIB_LAST}})
for i in $cycle
do
LIB_NOW=$i
LIB=$(printf "%02d\n" $LIB_NOW)
EXTRACT_LIB=$(ls ${INSERTS_DIR}/*${TEMPLATE}${LIB}*)
NPROC=$(($NPROC+1))
${SCRIPT_DIR}extract_lcscience.sh ${DIR} ${LIB_NOW} ${EXTRACT_LIB} &
if [ "$NPROC" -ge "$THREADS" ]; then
wait
NPROC=0
fi
done
wait
NPROC=0
for i in $cycle
do
#Running multiple threads of fq_to_fa_exe.sh
NPROC=$(($NPROC+1))
LIB_NOW=$i
${SCRIPT_DIR}fq_to_fa_exe.sh ${workdir} ${LIB_NOW} &
if [ "$NPROC" -ge "$THREADS" ]; then
wait
NPROC=0
fi
done
wait
NPROC=0
for i in $cycle
do
#Paralell threading trim-lcschience.sh
NPROC=$(($NPROC+1))
LIB_NOW=$i
${SCRIPT_DIR}trim-lcscience.sh ${DIR} ${LIB_NOW} &
if [ "$NPROC" -ge "$THREADS" ]; then
wait
NPROC=0
fi
done
wait
fi
END_TIME=$(date +%s.%N)
DIFF=$(echo "$END_TIME - $START_TIME" | bc)
echo "alignment finished in "${DIFF}" secs"
echo "Extracted all libraries"
ok_log=${log_file/.log/:OK.log}
echo $ok_log
mv $log_file $ok_log
exit 0