Skip to content

Commit e91a63c

Browse files
Merge pull request #2 from bio-hpc/essence-dock
Essence dock V1.1
2 parents 97b8904 + 143ce11 commit e91a63c

File tree

6 files changed

+791
-360
lines changed

6 files changed

+791
-360
lines changed

MetaScreener/extra_metascreener/results/ESSENCE-Dock.sh

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,29 @@ PURPLE='\033[00;35m'
1212
CYAN='\033[00;36m'
1313

1414
ms_path=${PWD/metascreener*/}/metascreener
15-
simg="singularity exec --bind=${PWD} $ms_path/singularity/metascreener.simg"
15+
simg="singularity exec --bind=${PWD} $ms_path/singularity/ESSENCE-Dock.simg"
1616
extra_metascreener="$ms_path/MetaScreener/extra_metascreener"
1717

18+
if [ ! -f "$ms_path/singularity/ESSENCE-Dock.simg" ]; then
19+
echo "The required ESSENCE-Dock Singularity image doesn't seem to be present. Would you like to download it automatically? "
20+
echo "(Y/y) Download Singularity image automatically"
21+
echo "(N/n) Exit"
22+
read -r answer
23+
while [ "${answer,,}" != "y" ] && [ "${answer,,}" != "yes" ] && [ "${answer,,}" != "n" ] && [ "${answer,,}" != "no" ]; do
24+
echo "Would you like to download the Singularity image automatically?"
25+
echo "(Y/y) Download Singularity image automatically"
26+
echo "(N/n) Exit"
27+
read -r answer
28+
done
29+
if [ "${answer,,}" = "y" ] || [ "${answer,,}" = "yes" ]; then
30+
wget --no-check-certificate -r "https://drive.usercontent.google.com/download?id=1yN63r8sl26VMZJtdrAG4e_JQFFlb1eE8&confirm=t" -O ${ms_path}/singularity/ESSENCE-Dock.simg
31+
echo "The Singularity image has been downloaded"
32+
else
33+
echo "Exiting.. Please install the Singularity image and try again"
34+
exit
35+
fi
36+
fi
37+
1838
printHelp(){
1939
printf "${GREEN} %6s ${CYAN}%5s ${NONE}%-s \n" "-$1 )" "[ $2 ]" "$3"
2040
}
@@ -32,6 +52,8 @@ function help()
3252
printHelp "np | no-postprocessing | raw" "O" "Skip post-processing of the best results, so no PSE or PLIP interactions are generated. Post-processing is performed by default"
3353
printHelp "n | nc" "O" "Amount of compounds to include in the final PyMol Session. Default is 50"
3454
printHelp "cl | cluster" "O" "String with options to launch in the cluster. Important: Always accompany this flag with an argument! For example: \"-p standard --time 12:00:00 ...\""
55+
printHelp "c | cpus" "O" "Number of CPUs to use"
56+
printHelp "t | timeout" "O" "Max time spent processing per compound"
3557
printHelp "s | silent" "O" "Silent Mode: Don't show the progression of the ESSENCE-Dock consensus calculations. Only works without the -cl flag: silent mode disabled by default"
3658
printHelp "ns | nosilent" "O" "No Silent Mode: Show the progression of the ESSENCE-Dock consensus calculations. Only works with the -cl flag: silent mode enabled by default"
3759
printHelp "sc | skip-cleanup" "O" "Skip the cleanup: intermediate files will not be removed"
@@ -53,7 +75,8 @@ skipcleanup=false
5375
cluster_opt=sequential
5476
input_dirs=0
5577
debug=false
56-
78+
CPUS=1
79+
timeoutLimit=3
5780
# Parameters
5881
while (( $# ))
5982
do
@@ -86,7 +109,9 @@ while (( $# ))
86109
--SKIP-CLEANUP | -SKIP-CLEANUP | -SC) skipcleanup=true;;
87110
--NOSILENT | -NOSILENT | -NS) CLsilent=false;;
88111
--NO-POSTPROCESSING | -NO-POSTPROCESSING | -RAW | -NP) noPostProcessing=true;;
89-
--CLUSTER | -CLUSTER| -CL) cluster_opt=$2;;
112+
--CLUSTER | -CLUSTER | -CL) cluster_opt=$2;;
113+
--CPUS | -CPU | -C) CPUS=$2;;
114+
--TIMEOUT | -TIMEOUT | -T) timeoutLimit=$2;;
90115
--HELP | -HELP | -H) help
91116
esac
92117
fi
@@ -122,16 +147,16 @@ else
122147
fi
123148

124149
if [ -d $out ];then
125-
while [ "$input" != "Y" ] && [ "$input" != "y" ] && [ "$input" != "N" ] && [ "$input" != "n" ] ; do
126-
echo "CreateFile: The directory ${folder_experiment} already exists. To continue you must delete this directory. Do you want to delete it? "
150+
while [ "${input,,}" != "y" ] && [ "${input,,}" != "yes" ] && [ "${input,,}" != "n" ] && [ "${input,,}" != "no" ]; do
151+
echo "The output directory ${out} already exists. To continue you must delete this directory. Do you want to delete it? "
127152
echo "(Y/y) Delete folder"
128153
echo "(N/n) Exit"
129154
read input
130155
done
131-
if [ "$input" == "Y" ] || [ "$input" == "y" ];then
156+
if [ "${input,,}" == "y" ] || [ "${input,,}" == "yes" ];then
132157
rm -r ${out}
133158
mkdir ${out}
134-
elif [ "$input" == "n" ] || [ "$input" == "N" ];then
159+
elif [ "${input,,}" == "n" ] || [ "${input,,}" == "no" ];then
135160
exit
136161
fi
137162
else
@@ -143,7 +168,7 @@ cross="${simg} python ${extra_metascreener}/results/cross/ESSENCE-Dock_cross.py
143168

144169
# Execute the commands
145170
if [[ "$cluster_opt" == "sequential" ]];then
146-
join="${simg} python3 ${extra_metascreener}/results/join/ESSENCE-Dock_Consensus.py -o ${out} -r ${receptor} -dd ${DiffDockPath} -f ${lst} -s ${silent} -n ${numberOfCompounds} -raw ${noPostProcessing}"
171+
join="${simg} python ${extra_metascreener}/results/join/ESSENCE-Dock_Consensus.py -o ${out} -r ${receptor} -dd ${DiffDockPath} -f ${lst} -s ${silent} -n ${numberOfCompounds} -raw ${noPostProcessing} -c ${CPUS} -t ${timeoutLimit}"
147172
echo "Preparing docking runs for ESSENCE-Dock Consensus.."
148173
if $debug; then
149174
echo -e "\e[0;34m[DEBUG] Full Command:\n${cross}\e[0m"
@@ -176,7 +201,7 @@ if [[ "$cluster_opt" == "sequential" ]];then
176201
fi
177202

178203
else
179-
join="${simg} python3 ${extra_metascreener}/results/join/ESSENCE-Dock_Consensus.py -o ${out} -r ${receptor} -dd ${DiffDockPath} -f ${lst} -s ${CLsilent} -n ${numberOfCompounds} -raw ${noPostProcessing}"
204+
join="${simg} python ${extra_metascreener}/results/join/ESSENCE-Dock_Consensus.py -o ${out} -r ${receptor} -dd ${DiffDockPath} -f ${lst} -s ${CLsilent} -n ${numberOfCompounds} -raw ${noPostProcessing} -c ${CPUS} -t ${timeoutLimit}"
180205
receptorName="${receptor##*/}"
181206
mkdir "$out/job_data/"
182207
name_job="${out}/job_data/ESSENCE-Dock_Consensus_${receptorName%.*}.sh"

MetaScreener/extra_metascreener/results/cross/ESSENCE-Dock_cross.py

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,83 +9,85 @@
99

1010
import argparse
1111
import os
12-
from collections import OrderedDict
1312
import time
13+
from collections import OrderedDict
1414

1515
parser = argparse.ArgumentParser()
16-
parser.add_argument('folder', type=str, nargs='+', help='Folders to process')
17-
parser.add_argument('-o', '--output', default='', type=str, help='name of output file')
16+
parser.add_argument("folder", type=str, nargs="+", help="Folders to process")
17+
parser.add_argument("-o", "--output", default="", type=str, help="name of output file")
1818

1919
args = parser.parse_args()
2020

2121
all_molecules = set()
2222

23+
2324
def read_energies(input_dir):
24-
dct = {}
25-
with open(input_dir + "/Results_scoring.csv") as csv:
26-
lines = csv.readlines()
27-
for i, line in enumerate(lines[1:]):
28-
lineSplit = line.strip().split(';')
29-
compound = lineSplit[4]
30-
if compound not in all_molecules:
31-
all_molecules.add(compound)
32-
energy = float(lineSplit[0])
33-
path = str(lineSplit[-1])
34-
dct[compound] = [str(i+1), energy, path]
35-
return dct
36-
37-
directories = ''
25+
dct = {}
26+
with open(input_dir + "/Results_scoring.csv") as csv:
27+
lines = csv.readlines()
28+
for i, line in enumerate(lines[1:]):
29+
lineSplit = line.strip().split(";")
30+
compound = lineSplit[4]
31+
if compound not in all_molecules:
32+
all_molecules.add(compound)
33+
energy = float(lineSplit[0])
34+
path = str(lineSplit[-1])
35+
dct[compound] = [str(i + 1), energy, path]
36+
return dct
37+
38+
39+
directories = ""
3840
all = OrderedDict()
39-
first_sw = ''
40-
name_out = ''
41+
first_sw = ""
42+
name_out = ""
4143
ORDER = False
4244

4345
start = time.time()
4446
args.folder.sort()
4547

4648
for dir in args.folder:
47-
index = dir.find('VS_')
48-
directories += '{} '.format(dir)
49-
sw = dir.split("VS_")[-1].split("_")[0]
50-
if (sw not in name_out):
51-
name_out += '{}_'.format(sw)
52-
53-
energies = read_energies(dir)
54-
if len(energies) > 0:
55-
if sw in all.keys():
56-
all[sw].update(energies)
57-
else:
58-
all[sw] = energies
59-
if first_sw == "":
60-
first_sw = sw
49+
index = dir.find("VS_")
50+
directories += "{} ".format(dir)
51+
sw = dir.split("VS_")[-1].split("_")[0]
52+
if sw not in name_out:
53+
name_out += "{}_".format(sw)
54+
55+
energies = read_energies(dir)
56+
if len(energies) > 0:
57+
if sw in all.keys():
58+
all[sw].update(energies)
59+
else:
60+
all[sw] = energies
61+
if first_sw == "":
62+
first_sw = sw
6163

6264
file_out = args.output
6365

6466
header = " Rank ".join(all.keys()) + " Rank Molecule"
6567
header = ",".join(all.keys())
6668

67-
#print("Writing preprocessed results to " + str(file_out))
68-
69-
f_out = open(file_out, 'w')
70-
f_out.write('{}\n'.format(header))
71-
rank = 1;
69+
f_out = open(file_out, "w")
70+
f_out.write("{}\n".format(header))
71+
rank = 1
7272

7373
if len(all) == 0:
74-
print("No results have been found")
75-
exit()
74+
print("No results have been found")
75+
exit()
7676

7777
for molecule in all_molecules:
78-
outputLine = ""
79-
for sw in all.keys():
80-
if all[sw].has_key(molecule):
81-
result = all[sw][molecule]
82-
outputLine += '{} {} {} '.format(result[0], result[1], result[2])
83-
else:
84-
outputLine += "-- -- -- "
85-
outputLine += " " + molecule + "\n"
86-
f_out.write(outputLine)
87-
rank += 1
78+
outputLine = ""
79+
for sw in all.keys():
80+
if molecule in all[sw]:
81+
result = all[sw][molecule]
82+
outputLine += "{} {} {} ".format(result[0], result[1], result[2])
83+
else:
84+
outputLine += "-- -- -- "
85+
outputLine += " " + molecule + "\n"
86+
f_out.write(outputLine)
87+
rank += 1
8888
f_out.close()
8989

90-
print("Time to preprocess the individual docking calculations: %ss" % (round(time.time() - start, 2)))
91-
90+
print(
91+
"Time to preprocess the individual docking calculations: %ss"
92+
% (round(time.time() - start, 2))
93+
)

0 commit comments

Comments
 (0)