forked from abrusell/Tartagenia
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hg19_g.custom_annotation_part.dev
215 lines (163 loc) · 19.2 KB
/
hg19_g.custom_annotation_part.dev
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
reference=/pico/work/IscrC_FoRWArDS_1/db/reference/ucsc.hg19.fasta
dbSNP_file=/pico/work/IscrC_FoRWArDS_1/db/snp/dbsnp_147_hg19.vcf.gz
#silva=/home/andrea.ciolfi/alignment_tools/silva-1.1.1/
#ExAC=/pico/work/IscrC_FoRWArDS_1/db/snp/ExAC.r0.3.sites.vep.mod.vcf.gz
dbscSNV=/pico/work/IscrC_FoRWArDS_1/db/dbNSFP3.0/dbscSNV1.1.txt.gz
# per l'hg19, nonostante quanto scritto nella documentazione, dbNSFP3 non va bene, si perde sempre delle annotazioni per alcune posizioni
# dbNSFP=/pico/work/IscrC_FoRWArDS_1/db/dbNSFP3.2/dbNSFP3.2a.hg19.sorted.txt.gz
dbNSFP=/pico/work/IscrC_FoRWArDS_1/db/dbNSFP2.9/dbNSFP2.9.txt.gz
CpG_islands=/pico/work/IscrC_FoRWArDS_1/db/UCSC_tables/CpG_islands_UCSC.bed
repeatMasker=/pico/work/IscrC_FoRWArDS_1/db/UCSC_tables/repeatMasker_UCSC.bed
segmentDups=/pico/work/IscrC_FoRWArDS_1/db/UCSC_tables/segmentDups_UCSC.bed
TandemRep=/pico/work/IscrC_FoRWArDS_1/db/UCSC_tables/simpleTandemRep_UCSC.bed
SNPEFF_HOME=/pico/home/userexternal/aciolfi0/snpEff4.3/
ACMG=/pico/home/userexternal/abrusell/ACMG_RefGene.txt
DDG2P=/pico/home/userexternal/abrusell/DDG2P_RefGene.txt
Mendeliome=/pico/home/userexternal/abrusell/Mendeliome_RefGene.txt
Intervar=/pico/work/IscrC_FoRWArDS_1/NGS_tools/InterVar/Intervar.py
if [ $phasing == "y" ]
then
flag=_phased
else
flag=
fi
# Lancio Intervar, lo devo lanciare nella dir del config.ini, altrimenti non funziona
cp /pico/work/IscrC_FoRWArDS_1/NGS_tools/InterVar/config.ini $outdir
cd $outdir
$Intervar -b hg19 -i $vcfinput -o $outdir$ID >$outdir$ID"_custAnnot_log" 2>&1 &
# con SnpSift annotate riempo il campo ID con il dbSNP e la frequenza (CAF)
java -Xmx64g -jar $SNPEFF_HOME"SnpSift.jar" annotate -info CAF $dbSNP_file $vcfinput > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.dbSNP.vcf" 2>> $outdir$ID"_ANNOT_log"
# annoto con le annotazioni custom mediante snpEff
# attenzione SnpEff oltre alle CUSTOM annotations UCSC aggiunge anche l'effetto!!!
# tolgo l'opzione -o gatk, in questo caso, così ho l'annotazione di snpEff completa
# qui aggiungiamo l'annotazione nel formato snpEff completo ANN=(*), in modo
# che poi possiamo avere anche gli effetti secondari
# includo splice site nella finestra standard +-2 nt
# NB le annotazioni custom non vengono aggiunte nel formato -o GATK se ci sono
# più effetti diversi sulla stessa variante
java -Xmx64G -jar $SNPEFF_HOME"snpEff.jar" -v hg19 -i vcf -noStats -t -c $SNPEFF_HOME"snpEff.config" -interval $CpG_islands -interval $repeatMasker -interval $segmentDups -interval $TandemRep $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.dbSNP.vcf" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf" 2>> $outdir$ID"_ANNOT_log"
# aggiungo i campi custom snpEff nell'header per attenersi strettamente allo standard vcf
#python /pico/work/IscrC_FoRWArDS_1/NGS_tools/customSnpEffVcfFixer.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf"
# rinomino l'output con l'header fixed
#mv $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_fix.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf"
# sostituisco resource.CAF con dbSNP147.GMAF nel vcf finale
sed -i 's/=CAF,/=dbSNP147\.GMAF,/g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf"
sed -i 's/;CAF=/;dbSNP147\.GMAF=/g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf"
# estraggo il genename e vari effetti dal campo ANN=(*) di snpEFF perché quando ci sono più effetti (es. SPLICE_SITE+INTRON) manca il campo SNPEFF_GENE_NAME
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/genenameEffFromSnpEff_4.2.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf" 2>> $outdir$ID"_ANNOT_log"
# rinomino l'output con il nome file precedente
mv $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.genenameEff.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf"
# Annotazione di snpEff con dbNSFP, con -f seleziono i campi da inserire
# sostituisco il vecchio comando che usavamo con dbNSFP3.2
# java -Xmx64g -jar /pico/home/userexternal/abrusell/snpEff/SnpSift.jar dbnsfp -db $dbNSFP -f Ancestral_allele,Ensembl_geneid,Ensembl_transcriptid,aapos,SIFT_pred,Polyphen2_HDIV_pred,Polyphen2_HVAR_pred,fathmm-MKL_coding_pred,MetaSVM_pred,MetaLR_pred,Reliability_index,MetaSVM_score,DANN_score,DANN_rankscore,CADD_phred,Eigen-raw,Eigen-raw_rankscore,Eigen-PC-raw_rankscore,integrated_fitCons_score,integrated_confidence_value,GERP++_RS,1000Gp3_AC,1000Gp3_AF,TWINSUK_AC,TWINSUK_AF,ALSPAC_AC,ALSPAC_AF,ESP6500_AA_AC,ESP6500_AA_AF,ESP6500_EA_AC,ESP6500_EA_AF,ExAC_AC,ExAC_AF,ExAC_Adj_AC,ExAC_Adj_AF,ExAC_AFR_AC,ExAC_AFR_AF,ExAC_AMR_AC,ExAC_AMR_AF,ExAC_EAS_AC,ExAC_EAS_AF,ExAC_FIN_AC,ExAC_FIN_AF,ExAC_NFE_AC,ExAC_NFE_AF,ExAC_SAS_AC,ExAC_SAS_AF,clinvar_rs,clinvar_clnsig,clinvar_trait,Interpro_domain $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP3.vcf" 2>> $outdir$ID"_ANNOT_log"
java -Xmx64g -jar $SNPEFF_HOME"SnpSift.jar" dbnsfp -db $dbNSFP -f Ancestral_allele,Ensembl_geneid,Ensembl_transcriptid,aapos,SIFT_pred,Polyphen2_HDIV_pred,Polyphen2_HVAR_pred,FATHMM_pred,MetaSVM_pred,MetaLR_pred,Reliability_index,MetaSVM_score,GERP++_RS,ESP6500_AA_AF,ESP6500_EA_AF,ExAC_AC,ExAC_AF,ExAC_Adj_AC,ExAC_Adj_AF,ExAC_AFR_AC,ExAC_AFR_AF,ExAC_AMR_AC,ExAC_AMR_AF,ExAC_EAS_AC,ExAC_EAS_AF,ExAC_FIN_AC,ExAC_FIN_AF,ExAC_NFE_AC,ExAC_NFE_AF,ExAC_SAS_AC,ExAC_SAS_AF,clinvar_rs,clinvar_clnsig,clinvar_trait,Interpro_domain $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot.vcf" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" 2>> $outdir$ID"_ANNOT_log"
# annoto anche gli INDELS con le frequenze di ExAC: devo usare WGSA perche' dbNSFP annota solo gli SNP
# prima devo lasciare solo l'ultima riga dell'header, altrimenti WGSA non funziona
grep ^#CHROM $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" > $outdir$ID"_WGSA_header"
grep -v ^# $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" > $outdir$ID"_WGSA_body"
cat $outdir$ID"_WGSA_header" $outdir$ID"_WGSA_body" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_WGSAfix.vcf"
java -cp /gss/gss_work/DRES_FoRWArDS/WGSA/resources/javaclass/ add_hg19_ExACgz_commandline2 $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_WGSAfix.vcf" true 1 2 4 5 indel "/gss/gss_work/DRES_FoRWArDS/WGSA/resources/ExACr0.3/" 2>> $outdir$ID"_ANNOT_log"
# annoto l'output di WGSA nel vcf
# NB nell'header i campi aggiunti da WGSA sono sempre chiamati tipo dbSNFP_ExAC_Adj_AF, anche non sono aggiunti da dbNSFP
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/exac_wgsa_annotator.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_WGSAfix.vcf.addExAC" 2>> $outdir$ID"_ANNOT_log"
mv $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_exac.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf"
rm -f $outdir$ID"_WGSA_header" $outdir$ID"_WGSA_body" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_WGSAfix.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2_WGSAfix.vcf.addExAC"
# Annotazione di snpEff con dbscSNV, con -f seleziono i campi da inserire:
# al momento non funziona, con l'hg38
#java -Xmx64g -jar /pico/home/userexternal/abrusell/snpEff/SnpSift.jar dbnsfp -db $dbscSNV -f RefSeq_id_c.change_p.change,Ensembl_id_c.change_p.change,RefSeq_functional_consequence,Ensembl_functional_consequence,ada_score,rf_score $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP3_ss.vcf" 2>> $outdir$ID"_ANNOT_log"
# Annotazione del vcf con i dati dbNSFP3.2_gene di dati omim, pathways etc
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/dbNSFP3_geneAnnotator.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1 || { echo "dbNSFP3_geneAnnotator.py failed!"; exit 1; }
sed -i 's/\,;/;/g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# Eliminiamo "Note=" dal campo Disease_description.
sed -i 's/Note=//g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# Sostitutisco gli spazi con "_" nel vcf per rispettare lo standard vcf
sed -i 's/ /_/g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# annotazione del VCF con i dati di miRBASE
#/pico/work/IscrC_FoRWArDS_1/NGS_tools/run_annomir /pico/work/IscrC_FoRWArDS_1/db/mirbase/hsa_hg19_v20_mod.gff3 $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1
# annoto gli indels con il CADD score (v.1.3)
# prima lo facevamo solo sugli INDELs, ora lo facciamo su tutte le varianti del vcf, completezza
#### estraggo solo gli INDELs dal vcf
####vcftools --vcf $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP3.dbNSFP_gene.vcf" --keep-only-indels --recode --out $outdir$ID"_raw_only_indels"
#### lo script del CADD funziona solo se il vcf non ha "chr" come inizio riga ed e' gzippato
####sed -i 's/^chr//g' $outdir$ID"_raw_only_indels.recode.vcf"
####gzip $outdir$ID"_raw_only_indels.recode.vcf"
# lo script del CADD funziona solo se il vcf non ha "chr" come inizio riga ed e' gzippato
sed 's/^chr//g' $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" | gzip > $outdir$ID"_tmp2CADD.vcf.gz"
# carico i moduli necessari per il CADD scoring
module load python/2.7.8
module load autoload bx-python
module load autoload pysam
# ottengo i CADD scores
/gss/gss_work/DRES_FoRWArDS/CADD_v1.3/bin/score.sh $outdir$ID"_tmp2CADD.vcf.gz" $outdir$ID"_raw_SNP_indels.CADD_scored.tsv.gz"
# aggiungo i CADD degli INDELs al campo INFO del nostro file vcf
/pico/work/IscrC_FoRWArDS_1/NGS_tools/addCadd2vcf.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" $outdir$ID"_raw_SNP_indels.CADD_scored.tsv.gz"
rm -f $outdir$ID"_tmp2CADD.vcf.gz"
if [ -s $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered.g_spidex_output.txt" ]; then
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/spidex_annotator.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered.g_spidex_output.txt" >> $outdir$ID"_custAnnot_log" 2>&1
spid=_spidex
else
spid=
fi
#Annoto l'esistenza del gene nella liste ACMG, DDG2P, Mendeliome
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $ACMG $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid".vcf" ACMG >> $outdir$ID"_custAnnot_log" 2>&1
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $DDG2P $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG.vcf" DDG2P >> $outdir$ID"_custAnnot_log" 2>&1
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $Mendeliome $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P.vcf" Mendel >> $outdir$ID"_custAnnot_log" 2>&1
#annoto fenotipo HGMD (spizzi00)
java -Xmx64g -jar /pico/home/userexternal/abrusell/snpEff/SnpSift.jar annotate -info PHEN /pico/work/IscrC_FoRWArDS_1/db/HGMD_PRO_latest_hg19.vcf.gz $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel.vcf" > $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel_HGMD.vcf" 2>> $outdir$ID"_ANNOT_log"
mv $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel_HGMD.vcf" $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel.vcf"
# Annoto l'interpretazione clinica di Intervar
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/intervar_annotator.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel.vcf" $outdir$ID".hg19_multianno.txt.intervar" 1>> $outdir$ID"_custAnnot_log" 2>&1
# annoto ricorrenza del singolo vcf
/pico/work/IscrC_FoRWArDS_1/NGS_tools/run_varDBannotator $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel_intervar.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1
# comprimo tutti i vcf di output
gzip -f $outdir$ID"_raw"*".vcf"
if [ $somatic == "y" ]; then
# con SnpSift annotate riempo il campo ID con il dbSNP e la frequenza (CAF)
java -Xmx64g -jar /pico/home/userexternal/abrusell/snpEff/SnpSift.jar annotate -info CAF $dbSNP_file $outdir$ID"_muTect2_raw_snps-indels.vcf" > $outdir$ID"_muTect2_raw_snps-indels"$flag".g.dbSNP.vcf" 2>> $outdir$ID"_ANNOT_log"
# annoto con le annotazioni custom mediante snpEff
java -Xmx64G -jar $SNPEFF_HOME"snpEff.jar" -v hg19 -i vcf -noStats -t -c $SNPEFF_HOME"snpEff.config" -interval $CpG_islands -interval $repeatMasker -interval $segmentDups -interval $TandemRep $outdir$ID"_muTect2_raw_snps-indels"$flag".g.dbSNP.vcf" > $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.vcf" 2>> $outdir$ID"_ANNOT_log"
# sostituisco resource.CAF con dbSNP147.GMAF nel vcf finale
sed -i 's/;CAF=/;dbSNP147\.GMAF=/g' $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.vcf"
# estraggo il genename e vari effetti dal campo ANN=(*) di snpEFF perché quando ci sono più effetti (es. SPLICE_SITE+INTRON) manca il campo SNPEFF_GENE_NAME
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/genenameEffFromSnpEff_4.2.py $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.vcf" 2>> $outdir$ID"_ANNOT_log"
# rinomino l'output con il nome file precedente
mv $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.genenameEff.vcf" $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.vcf"
# Annotazione di snpEff con dbNSFP, con -f seleziono i campi da inserire
java -Xmx64g -jar $SNPEFF_HOME"SnpSift.jar" dbnsfp -db $dbNSFP -f Ancestral_allele,Ensembl_geneid,Ensembl_transcriptid,aapos,SIFT_pred,Polyphen2_HDIV_pred,Polyphen2_HVAR_pred,FATHMM_pred,MetaSVM_pred,MetaLR_pred,Reliability_index,MetaSVM_score,GERP++_RS,ESP6500_AA_AF,ESP6500_EA_AF,ExAC_AC,ExAC_AF,ExAC_Adj_AC,ExAC_Adj_AF,ExAC_AFR_AC,ExAC_AFR_AF,ExAC_AMR_AC,ExAC_AMR_AF,ExAC_EAS_AC,ExAC_EAS_AF,ExAC_FIN_AC,ExAC_FIN_AF,ExAC_NFE_AC,ExAC_NFE_AF,ExAC_SAS_AC,ExAC_SAS_AF,clinvar_rs,clinvar_clnsig,clinvar_trait,Interpro_domain $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot.vcf" > $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" 2>> $outdir$ID"_ANNOT_log"
# Annotazione del vcf con i dati dbNSFP3.2_gene di dati omim, pathways etc
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/dbNSFP3_geneAnnotator.py $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1 || { echo "dbNSFP3_geneAnnotator.py failed!"; exit 1; }
sed -i 's/\,;/;/g' $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# Eliminiamo "Note=" dal campo Disease_description.
sed -i 's/Note=//g' $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# Sostitutisco gli spazi con "_" nel vcf per rispettare lo standard vcf
sed -i 's/ /_/g' $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf"
# annotazione del VCF con i dati di miRBASE
#/pico/work/IscrC_FoRWArDS_1/NGS_tools/run_annomir /pico/work/IscrC_FoRWArDS_1/db/mirbase/hsa_hg19_v20_mod.gff3 $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1
# lo script del CADD funziona solo se il vcf non ha "chr" come inizio riga ed e' gzippato
sed 's/^chr//g' $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" | gzip > $outdir$ID"_mt2_tmp2CADD.vcf.gz"
zgrep ^# $outdir$ID"_mt2_tmp2CADD.vcf.gz" > $outdir$ID"_mt2_tmp2CADD.header"
zgrep -v ^# $outdir$ID"_mt2_tmp2CADD.vcf.gz" > $outdir$ID"_mt2_tmp2CADD.body"
for i in {1..22} X Y; do grep ^$i" " $outdir$ID"_mt2_tmp2CADD.body" > $outdir$ID"_mt2_tmp2CADD.body."$i; done
for i in {1..22} X Y; do cat $outdir$ID"_mt2_tmp2CADD.header" $outdir$ID"_mt2_tmp2CADD.body."$i | gzip > $outdir$ID"_mt2_tmp2CADD."$i".vcf.gz"; done
for i in {1..22} X Y; do
/gss/gss_work/DRES_FoRWArDS/CADD_v1.3/bin/score.sh $outdir$ID"_mt2_tmp2CADD."$i".vcf.gz" $outdir$ID"_raw_SNP_indels.CADD_scored"$i".tsv.gz"
zgrep -v ^# $outdir$ID"_raw_SNP_indels.CADD_scored"$i".tsv.gz" >> $outdir$ID"_raw_SNP_indels.CADD_scored.tsv"
done
for i in {1..22} X Y; do rm $outdir$ID"_mt2_tmp2CADD.body."$i $outdir$ID"_mt2_tmp2CADD."$i".vcf.gz" $outdir$ID"_raw_SNP_indels.CADD_scored"$i".tsv.gz"; done
# aggiungo i CADD degli INDELs al campo INFO del nostro file vcf
/pico/work/IscrC_FoRWArDS_1/NGS_tools/addCadd2vcf.py $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene.vcf" $outdir$ID"_raw_SNP_indels.CADD_scored.tsv"
if [ -s $outdir$ID"_muTect2_raw_snps-indels_spidex_output.txt" ]; then
python /pico/work/IscrC_FoRWArDS_1/NGS_tools/spidex_annotator.py $outdir$ID"_raw_snps-indels_HapCall_genotype_filtered"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd.vcf" $outdir$ID"_muTect2_raw_snps-indels_spidex_output.txt" >> $outdir$ID"_custAnnot_log" 2>&1
spid=_spidex
else
spid=
fi
#Annoto l'esistenza del gene nella liste ACMG, DDG2P, Mendeliome
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $ACMG $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid".vcf" ACMG
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $DDG2P $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG.vcf" DDG2P
/pico/work/IscrC_FoRWArDS_1/NGS_tools/ExistingGenesAnnotator.py $Mendeliome $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P.vcf" Mendel
# annoto ricorrenza del singolo vcf
/pico/work/IscrC_FoRWArDS_1/NGS_tools/run_varDBannotator $outdir$ID"_muTect2_raw_snps-indels"$flag".g.SnpEff_UCSCAnnot_dbNSFP2.dbNSFP3_gene_cadd"$spid"_ACMG_DDG2P_Mendel.vcf" 1>> $outdir$ID"_custAnnot_log" 2>&1
# comprimo tutti i vcf di output
gzip -f $outdir$ID"_muTect2_raw"*".vcf"
fi