forked from draskot/Vini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_receptor_structures
executable file
·207 lines (193 loc) · 12.4 KB
/
create_receptor_structures
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
ORGANISM=`cat $WORKDIR/ORGANISM` #getting the organism type from the main script
CANCER_TYPE=`cat $WORKDIR/cancer_type` #getting the cancer type from the main script
CANCER_PATHWAY=$ORGANISM$CANCER_TYPE #setting the cancer pathway
UNIPROT_ID_LIST="_uniprot_entries.txt"
prediction_model=`cat $WORKDIR/prediction_model`
MAX_NODES=`cat $WORKDIR/nodes` #maximum number of compute nodes Vini can use concurrently
job_submit=`cat $WORKDIR/job_submit`
outdir=$vini_dir/database/genes/pdb_files #where the predicted structures are placed
prediction_model=`cat $WORKDIR/prediction_model`
if [ $prediction_model == A ]
then
partition=`cat $WORKDIR/AlphaFold_partition` #Define AlphaFold parameters
if [ $partition == cpu ]
then
cpus=`cat $WORKDIR/AlphaFold_cpus`
else
cpus=`cat $WORKDIR/AlphaFold_gpus`
fi
mem=`cat $WORKDIR/AlphaFold_mem`
base=`cat $WORKDIR/AlphaFold_base`
model=monomer
fi
NULL=0
ONES=1
two=2
#http://mmb.irbbarcelona.org/gitlab/DBW/PDBBrowser/raw/d80ad01c7569f5cfaac3a247f6e086d63db815cc/PDBData/cmpd_res.idx
#The database of all RCSB structure names
rm -f $vini_dir/database/KEGG_cancer_pathways/${CANCER_PATHWAY}/${CANCER_PATHWAY}${UNIPROT_ID_LIST}
> $WORKDIR/failed_pubchem_structures
echo "finalizing receptor file, please wait..."
> $WORKDIR/receptors_contracted
noentries=`wc -l < $WORKDIR/receptors_expanded`
echo "number of entries in pathway is" $noentries
entry=1
while read -r line
do
KEGG_entry_id=`echo $line | awk '{print $1}'` #get KEGG entry ID (number) and KEGG gene name (hsa:xxxx)
# note one KEGG entry may have several genes!
KEGG_gene_name=`echo $line | awk '{print $2}'`
if [[ ${KEGG_gene_name:0:1} == "C" ]] #checking if KEGG entry is the compound
then
wget -O $WORKDIR/tmp -q http://rest.kegg.jp/conv/pubchem/${KEGG_gene_name}
pubchem_id=`head -1 $WORKDIR/tmp | awk '{print $2}'`
echo -n "KEGG entry" $entry "is a compound with Pubchem ID" $pubchem_id "Checking if in repo..."
if [ -e $vini_dir/database/genes/pdb_files/${pubchem_id}.pdb ]
then
echo " yes. Adding" $pubchem_id "to" $WORKDIR/receptors_contracted "with E flag."
echo $KEGG_entry_id $KEGG_gene_name $pubchem_id "E" >> $WORKDIR/receptors_contracted
else
echo -n "no. Trying to obtain the structure from Pubchem..."
echo ${pubchem_id}
sh download_substance_structure ${pubchem_id}
if [ -e $vini_dir/database/genes/pdb_files/${pubchem_id}.pdb ]
then
echo "success. Adding" $pubchem_id "to" $WORKDIR/receptors_contracted "list with E flag."
else
echo " failed. Adding" $pubchem_id "to" $WORKDIR/receptors_contracted "with F flag."
echo $KEGG_entry_id $KEGG_gene_name $pubchem_id "F" >> $WORKDIR/receptors_contracted
echo "KEGG ID:" $KEGG_entry_id " " "Pubchem ID:" $pubchem_id >> $WORKDIR/failed_pubchem_structures
fi
fi
else #KEGG entry is protein
wget -O $WORKDIR/tmp -q http://rest.kegg.jp/conv/uniprot/${KEGG_gene_name}
uniprot_id=`head -1 $WORKDIR/tmp | awk '{print $2}'`
uniprot_id=`echo $uniprot_id | sed 's/\://g'` ; uniprot_id=`echo $uniprot_id | sed 's/\up//g'`
if [ -z "$uniprot_id" ]
then
echo "Uniprot ID for" $KEGG_gene_name "does not exists. Continuing to work with COSMIC gene name."
COSMIC_gene_name=`grep $KEGG_gene_name nouniprotid` #fetch the gene name from nouniprotid file
COSMIC_gene_name=`echo $COSMIC_gene_name | awk '{print $2}'`
if [ ! -e $vini_dir/database/genes/pdb_files/${COSMIC_gene_name}.pdb ]
then
echo "KEGG gene name:" $KEGG_gene_name "COSMIC gene name:" $COSMIC_gene_name >> $WORKDIR/missing_genes
else
echo $uniprot "structure found in repo, continuing."
fi
else
echo $uniprot_id >> $vini_dir/database/KEGG_cancer_pathways/${CANCER_PATHWAY}/${CANCER_PATHWAY}${UNIPROT_ID_LIST}
uline=`grep $uniprot_id $vini_dir/database/uniprot_db` #Check if pdb structure is available
echo -n "KEGG entry" $entry "is a gene encoding protein" $uniprot_id
nowords=`echo $uline | wc -w`
if [ $nowords -eq $two ]
then
echo -n " without structure. Checking if in repo..."
if [ -e $vini_dir/database/genes/pdb_files/${uniprot_id}.pdb ]
then
echo "yes. Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "with P flag."
echo $KEGG_entry_id $KEGG_gene_name $uniprot_id "P" >> $WORKDIR/receptors_contracted
else
echo "no."
if [ ! -e $vini_dir/database/genes/fasta_files/${uniprot_id}.fasta ]
then
wget -O $vini_dir/database/genes/fasta_files/${uniprot_id}.fasta --no-check-certificate -q https://www.uniprot.org/uniprot/${uniprot_id}.fasta #get fasta sequence
fi
fasta_file=$vini_dir/database/genes/fasta_files/${uniprot_id}.fasta
if [ ${prediction_model} == A ]
then
echo "cpus ${cpus} mem ${mem} partition ${partition} base ${base} model ${model} fasta_file ${fasta_file} "
sh $vini_dir/predict_with_AlphaFold ${cpus} ${mem} ${partition} ${base} ${model} ${fasta_file}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with W flag."
echo $KEGG_entry_id $KEGG_gene_name ${uniprot_id} "W" >> $WORKDIR/receptors_contracted
else
echo "Trying to find" $uniprot_id "structure in SWISS-MODEL repository."
grep ${uniprot_id} $vini_dir/database/SWISS-MODEL_Repository/INDEX > $WORKDIR/swiss_repo_entry
lineno=`wc -l < $WORKDIR/swiss_repo_entry`
if [ -s $WORKDIR/swiss_repo_entry ]
then
wget -O ${uniprot_id}.pdb --no-check-certificate -q https://swissmodel.expasy.org/repository/uniprot/${uniprot_id}.pdb
grep "^ATOM" ${uniprot_id}.pdb > $vini_dir/database/genes/pdb_files/${uniprot_id}.pdb
else
echo "Predicting" $uniprot_id "structure with SWISS-MODEL, please wait..."
sh $vini_dir/predict_protein_structure_with_swiss_model ${fasta_file} ${outdir}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with P flag."
echo $KEGG_entry_id $KEGG_gene_name ${uniprot_id} "P" >> $WORKDIR/receptors_contracted
fi
fi
fi
else
if [ -e $vini_dir/database/genes/pdb_files/${uniprot_id}.pdb ]
then
echo -n " with structure. Checking if in repo..."
echo " yes. Adding" $uniprot_id "to" $WORKDIR/receptors_contracted "with E flag."
echo ${KEGG_entry_id} ${KEGG_gene_name} ${uniprot_id} "E" >> $WORKDIR/receptors_contracted
else
echo "no. Analyzing available RCSB structures, may take a while... "
rm -f $WORKDIR/completeness_list
sh create_completeness_list ${uniprot_id}
noentries=`wc -l < $WORKDIR/completeness_list`
if [ $noentries -ne $NULL ]
then
sh $vini_dir/prepare_protein_with_chimera ${uniprot_id}
chim_status=`cat $WORKDIR/chim_status`
if [ $chim_status -eq $ONES ] #check for success
then
echo "success. Adding ${uniprot_id} to $WORKDIR/receptors_contracted list with E flag."
echo ${KEGG_entry_id} ${KEGG_gene_name} ${uniprot_id} "E" >> $WORKDIR/receptors_contracted
else
echo "Chimera failed. Will try to predict the structure."
if [ ! -e $vini_dir/database/genes/fasta_files/${uniprot_id}.fasta ]
then
wget -O ${uniprot_id}.fasta --no-check-certificate -q https://www.uniprot.org/uniprot/${uniprot_id}.fasta #get & prep sequence
fi
fasta_file=$vini_dir/database/genes/fasta_files/${uniprot_id}.fasta
if [ ${prediction_model} == A ]
then
sh $vini_dir/predict_with_AlphaFold ${cpus} ${mem} ${partition} ${base} ${model} ${fasta_file}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with W flag."
echo $KEGG_entry_id $KEGG_gene_name $uniprot_id "W" >> $WORKDIR/receptors_contracted
else
echo "Trying to find" $uniprot_id "structure in SWISS-MODEL repository."
grep ${uniprot_id} $vini_dir/database/SWISS-MODEL_Repository/INDEX > $WORKDIR/swiss_repo_entry
lineno=`wc -l < $WORKDIR/swiss_repo_entry`
if [ -s $WORKDIR/swiss_repo_entry ]
then
wget -O ${uniprot_id}.pdb --no-check-certificate -q https://swissmodel.expasy.org/repository/uniprot/${uniprot_id}.pdb
grep "^ATOM" ${uniprot_id}.pdb > $vini_dir/database/genes/pdb_files/${uniprot_id}.pdb
else
echo "Predicting" $uniprot_id "structure with SWISS-MODEL, please wait..."
sh $vini_dir/predict_protein_structure_with_swiss_model ${fasta_file} ${outdir}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with P flag."
echo $KEGG_entry_id $KEGG_gene_name $uniprot_id "P" >> $WORKDIR/receptors_contracted
fi
fi
fi
else
echo "no RCSB single model found."
if [ ! -e $vini_dir/database/genes/fasta_files/${uniprot_id}.fasta ]
then
wget -O $vini_dir/database/genes/fasta_files/${uniprot_id}.fasta --no-check-certificate -q https://www.uniprot.org/uniprot/${uniprot_id}.fasta #get & prep sequence
fi
fasta_file=$vini_dir/database/genes/fasta_files/${uniprot_id}.fasta
if [ ${prediction_model} == A ]
then
sh $vini_dir/predict_with_AlphaFold ${cpus} ${mem} ${partition} ${base} ${model} ${fasta_file}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with W flag."
echo ${KEGG_entry_id} ${KEGG_gene_name} ${uniprot_id} "W" >> $WORKDIR/receptors_contracted
else
echo "Predicting" $uniprot_id "structure with SWISS-MODEL, please wait..."
sh $vini_dir/predict_protein_structure_with_swiss_model ${fasta_file} ${outdir}
echo "Adding" ${uniprot_id} "to" $WORKDIR/receptors_contracted "list with P flag."
echo $KEGG_entry_id $KEGG_gene_name $uniprot_id "P" >> $WORKDIR/receptors_contracted
fi
fi
fi
fi
fi
fi
let "entry++"
done < $WORKDIR/receptors_expanded
awk '!seen[$0]++' $vini_dir/database/KEGG_cancer_pathways/$CANCER_PATHWAY/$CANCER_PATHWAY${UNIPROT_ID_LIST} > $WORKDIR/tmp #remove duplicate lines
grep "\S" $WORKDIR/tmp > $vini_dir/database/KEGG_cancer_pathways/$CANCER_PATHWAY/$CANCER_PATHWAY$UNIPROT_ID_LIST #remove empty lines
cp $vini_dir/database/KEGG_cancer_pathways/$CANCER_PATHWAY/$CANCER_PATHWAY${UNIPROT_ID_LIST} $vini_dir/genes/Uniprot_ID_list
rm $WORKDIR/tmp