-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSEQUEL_STEP_01.sh
executable file
·82 lines (56 loc) · 6.68 KB
/
SEQUEL_STEP_01.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
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
# CHECK IMPORTED VARIABLES
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
SCRIPT_Name="$(basename $0)"
if [[ -z "${SPIPE_dpath:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_dpath\" not set!\n" ; exit 1 ; fi
if [[ -z "${SPIPE_srbam:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_srbam\" not set!\n" ; exit 2 ; fi
if [[ -z "${SPIPE_scbam:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_scbam\" not set!\n" ; exit 3 ; fi
if [[ -z "${SPIPE_smrtc+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_smrtc\" not set!\n" ; exit 4 ; fi
if [[ -z "${SPIPE_ext:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_ext\" not set!\n" ; exit 5 ; fi
if [[ -z "${SPIPE_step:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SPIPE_step\" not set!\n" ; exit 6 ; fi
if [[ -z "${SEQUEL_extract:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SEQUEL_extract\" not set!\n" ; exit 7 ; fi
if [[ -z "${SEQUEL_SAMTOOLS:+x}" ]] ; then echo -e "\n[${SCRIPT_Name}]:\t\"SEQUEL_SAMTOOLS\" not set!\n" ; exit 8 ; fi
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
# INITIALISE VARIABLES
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
SEQL_block="${SPIPE_dpath}/${SPIPE_step}.RUNNING.${SPIPE_smrtc}" # This file acts as a kind of "road block": while it exists the next step cannot start!
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
# RUN
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
echo "Starting '${SPIPE_step}' ..." > "${SEQL_block}"
# 1) Extract data from "scraps" BAM
#..........................................................................................................................................................................................................................................#
########################################################################################################################################################################################
# Line-wrapped command :
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
# "${SEQUEL_SAMTOOLS}" view "${SPIPE_scbam}"
# | awk -v rtype="scraps" -f "${SEQUEL_extract}"
# > "${SPIPE_ext}/EXT.${SPIPE_smrtc}.sc.txt"
#
########################################################################################################################################################################################
"${SEQUEL_SAMTOOLS}" view "${SPIPE_scbam}" | awk -v rtype="scraps" -f "${SEQUEL_extract}" > "${SPIPE_ext}/EXT.${SPIPE_smrtc}.sc.txt"
SEQL_status=("${PIPESTATUS[@]}")
if [[ "${SEQL_status[0]}" -ne 0 ]] ; then echo -e "\n[${SCRIPT_Name}]:\t'samtools' terminated with exit code \"${SEQL_status[0]}\"!\n" ; exit 9 ; fi
if [[ "${SEQL_status[1]}" -ne 0 ]] ; then echo -e "\n[${SCRIPT_Name}]:\t'SEQUEL_extract.awk' terminated with exit code \"${SEQL_status[1]}\"!\n" ; exit 10 ; fi
#..........................................................................................................................................................................................................................................#
# 2) Extract data from "subreads" BAM
#..........................................................................................................................................................................................................................................#
########################################################################################################################################################################################
# Line-wrapped command :
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
# "${SEQUEL_SAMTOOLS}" view "${SPIPE_srbam}"
# | awk -v rtype="subreads" -f "${SEQUEL_extract}"
# > "${SPIPE_ext}/EXT.${SPIPE_smrtc}.sr.txt"
#
########################################################################################################################################################################################
"${SEQUEL_SAMTOOLS}" view "${SPIPE_srbam}" | awk -v rtype="subreads" -f "${SEQUEL_extract}" > "${SPIPE_ext}/EXT.${SPIPE_smrtc}.sr.txt"
SEQL_status=("${PIPESTATUS[@]}")
if [[ "${SEQL_status[0]}" -ne 0 ]] ; then echo -e "\n[${SCRIPT_Name}]:\t'samtools' terminated with exit code \"${SEQL_status[0]}\"!\n" ; exit 11 ; fi
if [[ "${SEQL_status[1]}" -ne 0 ]] ; then echo -e "\n[${SCRIPT_Name}]:\t'SEQUEL_extract.awk' terminated with exit code \"${SEQL_status[1]}\"!\n" ; exit 12 ; fi
#..........................................................................................................................................................................................................................................#
rm "${SEQL_block}"
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#