-
Notifications
You must be signed in to change notification settings - Fork 1
/
AmpliCoNE-build.sh
218 lines (193 loc) · 7.53 KB
/
AmpliCoNE-build.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
set -e
usage(){ echo "Usage: $0 -c chrY|Y -i <REF.fasta> -m <REF-MAPPABILITY.bed> -r <REF-REPMASK.out> -t <REF-TRF.bed> -g <Gene_Definition.tab> -o chrY_annotation.tab
-c chromosome name as in reference (Y or chrY): ${chromosome}
-i reference file (download from UCSC Genome Browser)
-m GEM-MAPPABILITY output in bed format
-r RepeatMasker output (download from UCSC Genome Browser)
-t TandemRepeatFinder output (download from UCSC Genome Browser)
-g geneDefinition
-o output file name
"
1>&2; exit 1; }
while getopts c:i:m:r:t:g:o: option
do
case "${option}"
in
c) chromosome=${OPTARG};;
i) reference=${OPTARG};;
m) mappability=${OPTARG};;
r) repeatmasker=${OPTARG};;
t) tandemRepeatFinder=${OPTARG};;
g) geneDefinition=${OPTARG};;
o) output=${OPTARG};;
esac
done
if [ -z "${chromosome}" ] || [ -z "${reference}" ] || [ -z "${mappability}" ] || [ -z "${repeatmasker}" ] || [ -z "${tandemRepeatFinder}" ] || [ -z "${geneDefinition}" ] || [ -z "${output}" ]; then
usage()
fi
echo "INPUT:
chromosome: ${chromosome}
reference: ${reference}
mappability: ${mappability}
repeatmasker: ${repeatmasker}
tandemRepeatFinder: ${tandemRepeatFinder}
geneDefinition: ${geneDefinition}
output: ${output}"
#check if the software exists
hash bowtie2 2>/dev/null || { echo "I require bwa in path but it's not installed. Aborting."; exit 1; }
#check if the python scripts are available
if [ ! -f "bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py" ]; then
echo "ERROR: bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py not found!"
exit 1;
fi
if [ ! -f "bin/parse_Ychr_Mappability.py" ]; then
echo "ERROR: bin/analyzeRepeats.py not found!"
exit 1;
fi
if [ ! -f "bin/parse_Ychr_RepeatMasker.py" ]; then
echo "ERROR: bin/parse_Ychr_RepeatMasker.py not found!"
exit 1;
fi
if [ ! -f "bin/parse_Ychr_TRF.py" ]; then
echo "ERROR: bin/parse_Ychr_TRF.py not found!"
exit 1;
fi
if [ ! -f "bin/parse_geneFamily_informativeSites.py" ]; then
echo "ERROR: bin/parse_geneFamily_informativeSites.py not found!"
exit 1;
fi
if [ ! -f "bin/generate_summary_annotationFile.py" ]; then
echo "ERROR: bin/generate_summary_annotationFile.py not found!"
exit 1;
fi
echo "\n\nChecking if input files exist"
if [ ! -f ${reference} ]; then
echo "ERROR: Reference file :${reference} not found!"
exit 1;
fi
if [ ! -f ${mappability} ]; then
echo "ERROR: Mappability output file :${mappability} not found!"
exit 1;
fi
if [ ! -f ${repeatmasker} ]; then
echo "ERROR: RepeatMasker output file :${repeatmasker} not found!"
exit 1;
fi
if [ ! -f ${tandemRepeatFinder} ]; then
echo "ERROR: TandemRepeatFinder output file :${tandemRepeatFinder} not found!"
exit 1;
fi
if [ ! -f ${geneDefinition} ]; then
echo "ERROR: GeneDefinition file :${geneDefinition} not found!"
exit 1;
fi
#########################################Pipeline starts here
#USE THIS PARAMETERS TO DEBUG AND RUN FROM A PARTICULAR STEP
STEP=0
LEVEL='GC_READS'
case $LEVEL in
"GC_READS")
STEP=1;;
"MAPPABILITY")
STEP=2;;
"RM")
STEP=3;;
"TRF")
STEP=4;;
"BOWTIE2")
STEP=5;;
"INFO")
STEP=6;;
"SUMMARY")
STEP=7;;
*);;
esac
if [ $STEP -le 1 ]
then
if [ -f ${reference} ]; then
echo "\nGenerating GCcontent and Reads for downstrean analysis."
echo "python bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py -r ${reference} -c ${chromosome}"
python bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py -r ${reference} -c ${chromosome}
fi
if [ ! -f ${chromosome}_GC_Content.txt ]; then
echo "ERROR: ${chromosome}_GC_Content.txt file was not generated by bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py. Check input files for this step."
exit 1;
fi
if [ ! -f ${chromosome}_length.txt ]; then
echo "ERROR: ${chromosome}_length.txt file was not generated by bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py. Check input files for this step."
exit 1;
fi
if [ ! -f Sliding_window101bp_Reference_reads.fasta ]; then
echo "ERROR: Sliding_window101bp_Reference_reads.fasta file was not generated by bin/calculate_Ychr_GCpercent_and_generate101bp_reads.py. Check input files for this step."
exit 1;
fi
fi
if [ -f ${chromosome}_length.txt ]; then
echo "\nObtaining chromosome length."
chr_len=$(cat "${chromosome}_length.txt")
fi
if [ $STEP -le 2 ]
then
if [ -f ${mappability} ]; then
echo "\nParsing Mappability scores"
echo "python bin/parse_Ychr_Mappability.py -i ${mappability} -c ${chromosome} -l ${chr_len}"
python bin/parse_Ychr_Mappability.py -i ${mappability} -c ${chromosome} -l ${chr_len}
fi
if [ ! -f ${chromosome}_MAPPABILITY_bypos.txt ]; then
echo "ERROR: ${chromosome}_MAPPABILITY_bypos.txt file was not generated by bin/parse_Ychr_Mappability.py. Check input files for this step."
exit 1;
fi
fi
if [ $STEP -le 3 ]
then
if [ -f ${repeatmasker} ]; then
echo "\nParsing repeat masker output"
echo "python bin/parse_Ychr_RepeatMasker.py -i ${repeatmasker} -c ${chromosome} -l ${chr_len}"
python bin/parse_Ychr_RepeatMasker.py -i ${repeatmasker} -c ${chromosome} -l ${chr_len}
fi
if [ ! -f ${chromosome}_REPEAT_MASKED.txt ]; then
echo "ERROR: ${chromosome}_REPEAT_MASKED.txt file was not generated by bin/parse_Ychr_RepeatMasker.py. Check input files for this step."
exit 1;
fi
fi
if [ $STEP -le 4 ]
then
if [ -f ${tandemRepeatFinder} ]; then
echo "\nParsing TandemRepeatFinder output"
echo "python bin/parse_Ychr_TRF.py -i ${tandemRepeatFinder} -c ${chromosome} -l ${chr_len}"
python bin/parse_Ychr_TRF.py -i ${tandemRepeatFinder} -c ${chromosome} -l ${chr_len}
fi
if [ ! -f ${chromosome}_TANDAMREPEAT_MASKED.txt ]; then
echo "ERROR: ${chromosome}_TANDAMREPEAT_MASKED.txt file was not generated by bin/parse_Ychr_TRF.py. Check input files for this step."
exit 1;
fi
fi
if [ $STEP -le 5 ]
then
if [ -f Sliding_window101bp_Reference_reads.fasta ]; then
echo "\nGenerating Bowtie2 index and aligning reads"
bowtie2-build ${reference} bowtie2_index
bowtie2 -k 15 --threads 5 -x bowtie2_index -f Sliding_window101bp_Reference_reads.fasta -S Ychr_101bp_bowtie2_k15.sam
fi
fi
if [ $STEP -le 6 ]
then
if [ -f Ychr_101bp_bowtie2_k15.sam ]; then
echo "\nParse gene family specific informative sites"
echo "python bin/parse_geneFamily_informativeSites.py -s Ychr_101bp_bowtie2_k15.sam -g ${geneDefinition} -c ${chromosome} -l ${chr_len}"
python bin/parse_geneFamily_informativeSites.py -s Ychr_101bp_bowtie2_k15.sam -g ${geneDefinition} -c ${chromosome} -l ${chr_len}
fi
if [ ! -f ${chromosome}_Informative_101bp_hg38.tab ]; then
echo "ERROR: ${chromosome}_Informative_101bp_hg38.tab file was not generated by bin/parse_geneFamily_informativeSites.py. Check input files for this step."
exit 1;
fi
fi
if [ $STEP -le 7 ]
then
echo "\nReading all the parameters. Filtering repeat sites, sites with 0 GCpercent and 0 Mappability score."
echo "python bin/generate_summary_annotationFile.py -g ${chromosome}_GC_Content.txt -m ${chromosome}_MAPPABILITY_bypos.txt -r ${chromosome}_REPEAT_MASKED.txt -t ${chromosome}_TANDAMREPEAT_MASKED.txt -i ${chromosome}_Informative_101bp_hg38.tab -o ${output} -l ${chr_len}\n"
python bin/generate_summary_annotationFile.py -g ${chromosome}_GC_Content.txt -m ${chromosome}_MAPPABILITY_bypos.txt -r ${chromosome}_REPEAT_MASKED.txt -t ${chromosome}_TANDAMREPEAT_MASKED.txt -i ${chromosome}_Informative_101bp_hg38.tab -o ${output} -l ${chr_len}
echo "\nGenerated output."
echo "\nCan delete intermediate files."
fi