Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Evry-Paris-Saclay
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2024 Competition
Software Tools
Evry-Paris-Saclay
Commits
b47dd6c7
Commit
b47dd6c7
authored
5 months ago
by
Victor ROBERT LAMBRECHT
Browse files
Options
Downloads
Patches
Plain Diff
evaluate_results can now also print the SCORE (dG)
parent
1c5ba003
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eval/docking.py
+26
-37
26 additions, 37 deletions
eval/docking.py
evaluate_results.py
+9
-8
9 additions, 8 deletions
evaluate_results.py
with
35 additions
and
45 deletions
eval/docking.py
+
26
−
37
View file @
b47dd6c7
import
os
from
vina
import
Vina
from
eval
.chemutils
import
kd
from
src
.chemutils
import
kd
import
time
def
docking
(
receptor_file
:
str
,
ligand_file
:
str
,
center
:
"
tuple[float, float, float]
"
=
(
0
,
0
,
0
),
box_size
:
"
tuple[float, float, float]
"
=
(
20
,
20
,
20
),
n_dockings
:
int
=
64
,
n_poses
:
int
=
32
,
score
=
False
,
write
=
False
)
->
"
list[float] | float
"
:
def
docking
(
receptor_file
:
str
,
ligand_file
:
str
,
center
:
"
tuple[float, float, float]
"
=
(
0
,
0
,
0
),
box_size
:
"
tuple[float, float, float]
"
=
(
20
,
20
,
20
),
n_dockings
:
int
=
32
,
n_poses
:
int
=
20
)
->
"
dict[str, list[float]]
"
:
"""
Docking simulation function : returns ...
@param receptor_file: protein (pdbqt file)
...
...
@@ -20,47 +17,39 @@ def docking(
@param center: docking window center
@param box_size: docking window size
@param n_dockings: number of docking simulations
@param n_poses: number of pose attempts per simulation
@param score (bool): wether or not the output should be a single score
@param write (bool): wether or not the poses should be saved to a file
@return (list[float] | float): a list of scores or a single score
@param n_poses: number of pose attempts per simulation
@return: dockings (pdbqt files), delta_G
"""
receptor_name
=
os
.
path
.
splitext
(
receptor_file
)[
-
1
].
split
(
'
.
'
)[
0
]
ligand_name
=
os
.
path
.
splitext
(
ligand_file
)[
-
1
].
split
(
'
.
'
)[
0
]
# initialise
s
vina
v
=
Vina
(
sf_name
=
'
vina
'
,
verbosity
=
1
)
#
On
initialise vina
v
=
Vina
(
sf_name
=
'
vina
'
,
verbosity
=
0
)
v
.
set_receptor
(
receptor_file
)
v
.
set_ligand_from_file
(
ligand_file
)
#
set th
e docking
frame
v
.
compute_vina_maps
(
center
=
center
,
box_size
=
box_size
)
#
On pose la box d
e docking
v
.
compute_vina_maps
(
center
=
center
,
box_size
=
box_size
)
#
s
core
s
the current pose
#
S
core the current pose
energy
=
v
.
score
()
print
(
'
Score before minimization: %.3f (kcal/mol)
'
%
energy
[
0
])
#
print('Score before minimization: %.3f (kcal/mol)' % energy[0])
#
m
inimize
s
locally the current pose
#
M
inimize
d
locally the current pose
energy_minimized
=
v
.
optimize
()
print
(
'
Score after minimization : %.3f (kcal/mol)
'
%
energy_minimized
[
0
])
#
print('Score after minimization : %.3f (kcal/mol)' % energy_minimized[0])
# v.write_pose(f'{ligand_name}_minimized.pdbqt', overwrite=True)
#
d
ock
s
the ligand
#
D
ock the ligand
v
.
dock
(
exhaustiveness
=
n_dockings
,
n_poses
=
20
)
v
.
write_poses
(
f
'
results/docked/
{
ligand_name
}
_docked_
{
time
.
time
()
}
.pdbqt
'
,
n_poses
=
n_poses
)
if
write
:
v
.
write_poses
(
f
'
results/docked/
{
ligand_name
}
_docked_
{
time
.
time
()
}
.pdbqt
'
,
n_poses
=
n_poses
)
results
=
v
.
energies
(
n_poses
=
n_poses
)
output
=
None
# single hi-score or the list of all poses energies
if
not
score
:
results
=
v
.
energies
(
n_poses
=
n_poses
)
output
=
[
energies
[
0
]
for
energies
in
results
]
else
:
output
=
v
.
energies
(
n_poses
=
1
)[
0
][
0
]
return
output
return
{
"
poses
"
:
v
.
poses
(
coordinates_only
=
True
),
"
Kd
"
:
[
kd
(
energies
[
0
])
for
energies
in
results
],
"
dG
"
:
[
energies
[
0
]
for
energies
in
results
],
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
evaluate_results.py
+
9
−
8
View file @
b47dd6c7
...
...
@@ -18,14 +18,15 @@ def get_energy(receptor_path, ligand_path):
receptor_path_preped
=
prepare
(
receptor_path
)
ligand_path_preped
=
prepare
(
ligand_path
)
try
:
energy
=
docking
(
receptor_path_preped
,
dic
=
docking
(
receptor_path_preped
,
ligand_path_preped
,
center
=
docking_box
[
"
center
"
],
box_size
=
docking_box
[
"
size
"
],
n_dockings
=
40
,
n_poses
=
20
)[
"
Kd
"
]
n_poses
=
20
)
energy
,
dG
=
dic
[
"
Kd
"
],
dic
[
"
dG
"
]
print
(
"
Kd:
"
,
energy
)
return
energy
return
energy
,
dG
except
Exception
as
e
:
print
(
f
"
[!]Error:
{
e
}
.
"
)
print
(
"
------
"
)
...
...
@@ -33,9 +34,9 @@ def get_energy(receptor_path, ligand_path):
output_path
=
"
./summary.tsv
"
res_path
=
"
./
data/PG_re
s/
"
res_path
=
"
./
results/mutant
s/
"
DATA
=
[[
"
ID
"
,
"
KD
"
,
"
NUM_MUTATIONS
"
]]
DATA
=
[[
"
ID
"
,
"
SCORE
"
,
"
KD
"
,
"
NUM_MUTATIONS
"
]]
for
mol
in
os
.
listdir
(
res_path
):
if
mol
.
endswith
(
"
.sdf
"
):
...
...
@@ -46,15 +47,15 @@ for mol in os.listdir(res_path):
if
rec
.
startswith
(
prefix
)
and
rec
.
endswith
(
"
.pdb
"
):
# We have a receptor that starts with the prefix of the molecule
print
(
"
Doing:
"
,
rec
,
"
with ligand:
"
,
mol
)
energy
=
get_energy
(
os
.
path
.
join
(
res_path
,
rec
),
energy
,
dG
=
get_energy
(
os
.
path
.
join
(
res_path
,
rec
),
os
.
path
.
join
(
res_path
,
mol
))
numbers
=
""
.
join
([
s
for
s
in
rec
.
split
()
if
s
.
isdigit
()])
print
(
"
Numbers:
"
,
numbers
)
num_mutations
=
get_num_mutations
(
os
.
path
.
join
(
res_path
,
rec
),
os
.
path
.
join
(
res_path
,
numbers
+
"
_whole.pdb
"
))
DATA
.
append
([
rec
,
energy
,
num_mutations
])
DATA
.
append
([
rec
,
dG
,
energy
,
num_mutations
])
if
int
(
numbers
)
>=
3
:
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment