Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenFold
Commits
8a76cc15
Commit
8a76cc15
authored
Mar 06, 2023
by
Jose Duarte
Browse files
WIP towards writing relaxed structure as modelcif
parent
be58750c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
10 deletions
+13
-10
openfold/np/relax/amber_minimize.py
openfold/np/relax/amber_minimize.py
+0
-3
openfold/np/relax/relax.py
openfold/np/relax/relax.py
+3
-1
openfold/utils/script_utils.py
openfold/utils/script_utils.py
+8
-4
run_pretrained_openfold.py
run_pretrained_openfold.py
+1
-1
thread_sequence.py
thread_sequence.py
+1
-1
No files found.
openfold/np/relax/amber_minimize.py
View file @
8a76cc15
...
@@ -524,9 +524,6 @@ def run_pipeline(
...
@@ -524,9 +524,6 @@ def run_pipeline(
_check_residues_are_well_defined
(
prot
)
_check_residues_are_well_defined
(
prot
)
pdb_string
=
clean_protein
(
prot
,
checks
=
checks
)
pdb_string
=
clean_protein
(
prot
,
checks
=
checks
)
# We keep the input around to restore metadata deleted by the relaxer
input_prot
=
prot
exclude_residues
=
exclude_residues
or
[]
exclude_residues
=
exclude_residues
or
[]
exclude_residues
=
set
(
exclude_residues
)
exclude_residues
=
set
(
exclude_residues
)
violations
=
np
.
inf
violations
=
np
.
inf
...
...
openfold/np/relax/relax.py
View file @
8a76cc15
...
@@ -57,7 +57,7 @@ class AmberRelaxation(object):
...
@@ -57,7 +57,7 @@ class AmberRelaxation(object):
self
.
_use_gpu
=
use_gpu
self
.
_use_gpu
=
use_gpu
def
process
(
def
process
(
self
,
*
,
prot
:
protein
.
Protein
self
,
*
,
prot
:
protein
.
Protein
,
cif_output
:
bool
)
->
Tuple
[
str
,
Dict
[
str
,
Any
],
np
.
ndarray
]:
)
->
Tuple
[
str
,
Dict
[
str
,
Any
],
np
.
ndarray
]:
"""Runs Amber relax on a prediction, adds hydrogens, returns PDB string."""
"""Runs Amber relax on a prediction, adds hydrogens, returns PDB string."""
out
=
amber_minimize
.
run_pipeline
(
out
=
amber_minimize
.
run_pipeline
(
...
@@ -78,6 +78,8 @@ class AmberRelaxation(object):
...
@@ -78,6 +78,8 @@ class AmberRelaxation(object):
"attempts"
:
out
[
"min_attempts"
],
"attempts"
:
out
[
"min_attempts"
],
"rmsd"
:
rmsd
,
"rmsd"
:
rmsd
,
}
}
# TODO write all this as ModelCIF if param is true. Should be simply proteint.to_modelcif(prot)
# and then add the other pieces, except that clean_protein() does quite some additional stuff...
pdb_str
=
amber_minimize
.
clean_protein
(
prot
)
pdb_str
=
amber_minimize
.
clean_protein
(
prot
)
min_pdb
=
utils
.
overwrite_pdb_coordinates
(
pdb_str
,
min_pos
)
min_pdb
=
utils
.
overwrite_pdb_coordinates
(
pdb_str
,
min_pos
)
min_pdb
=
utils
.
overwrite_b_factors
(
min_pdb
,
prot
.
b_factors
)
min_pdb
=
utils
.
overwrite_b_factors
(
min_pdb
,
prot
.
b_factors
)
...
...
openfold/utils/script_utils.py
View file @
8a76cc15
...
@@ -228,7 +228,7 @@ def prep_output(out, batch, feature_dict, feature_processor, config_preset, mult
...
@@ -228,7 +228,7 @@ def prep_output(out, batch, feature_dict, feature_processor, config_preset, mult
return
unrelaxed_protein
return
unrelaxed_protein
def
relax_protein
(
config
,
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
):
def
relax_protein
(
config
,
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
,
cif_output
):
amber_relaxer
=
relax
.
AmberRelaxation
(
amber_relaxer
=
relax
.
AmberRelaxation
(
use_gpu
=
(
model_device
!=
"cpu"
),
use_gpu
=
(
model_device
!=
"cpu"
),
**
config
.
relax
,
**
config
.
relax
,
...
@@ -239,7 +239,8 @@ def relax_protein(config, model_device, unrelaxed_protein, output_directory, out
...
@@ -239,7 +239,8 @@ def relax_protein(config, model_device, unrelaxed_protein, output_directory, out
if
"cuda"
in
model_device
:
if
"cuda"
in
model_device
:
device_no
=
model_device
.
split
(
":"
)[
-
1
]
device_no
=
model_device
.
split
(
":"
)[
-
1
]
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
device_no
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
device_no
relaxed_pdb_str
,
_
,
_
=
amber_relaxer
.
process
(
prot
=
unrelaxed_protein
)
# the struct_str will contain either a PDB-format or a ModelCIF format string
struct_str
,
_
,
_
=
amber_relaxer
.
process
(
prot
=
unrelaxed_protein
,
cif_output
=
cif_output
)
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
visible_devices
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
visible_devices
relaxation_time
=
time
.
perf_counter
()
-
t
relaxation_time
=
time
.
perf_counter
()
-
t
...
@@ -247,10 +248,13 @@ def relax_protein(config, model_device, unrelaxed_protein, output_directory, out
...
@@ -247,10 +248,13 @@ def relax_protein(config, model_device, unrelaxed_protein, output_directory, out
update_timings
({
"relaxation"
:
relaxation_time
},
os
.
path
.
join
(
output_directory
,
"timings.json"
))
update_timings
({
"relaxation"
:
relaxation_time
},
os
.
path
.
join
(
output_directory
,
"timings.json"
))
# Save the relaxed PDB.
# Save the relaxed PDB.
suffix
=
"_relaxed.pdb"
if
cif_output
:
suffix
=
"_relaxed.cif"
relaxed_output_path
=
os
.
path
.
join
(
relaxed_output_path
=
os
.
path
.
join
(
output_directory
,
f
'
{
output_name
}
_relaxed.pdb
'
output_directory
,
f
'
{
output_name
}
{
suffix
}
'
)
)
with
open
(
relaxed_output_path
,
'w'
)
as
fp
:
with
open
(
relaxed_output_path
,
'w'
)
as
fp
:
fp
.
write
(
relaxed_pdb
_str
)
fp
.
write
(
struct
_str
)
logger
.
info
(
f
"Relaxed output written to
{
relaxed_output_path
}
..."
)
logger
.
info
(
f
"Relaxed output written to
{
relaxed_output_path
}
..."
)
\ No newline at end of file
run_pretrained_openfold.py
View file @
8a76cc15
...
@@ -288,7 +288,7 @@ def main(args):
...
@@ -288,7 +288,7 @@ def main(args):
if
not
args
.
skip_relaxation
:
if
not
args
.
skip_relaxation
:
# Relax the prediction.
# Relax the prediction.
logger
.
info
(
f
"Running relaxation on
{
unrelaxed_output_path
}
..."
)
logger
.
info
(
f
"Running relaxation on
{
unrelaxed_output_path
}
..."
)
relax_protein
(
config
,
args
.
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
)
relax_protein
(
config
,
args
.
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
,
args
.
cif_output
)
if
args
.
save_outputs
:
if
args
.
save_outputs
:
output_dict_path
=
os
.
path
.
join
(
output_dict_path
=
os
.
path
.
join
(
...
...
thread_sequence.py
View file @
8a76cc15
...
@@ -106,7 +106,7 @@ def main(args):
...
@@ -106,7 +106,7 @@ def main(args):
logger
.
info
(
f
"Output written to
{
unrelaxed_output_path
}
..."
)
logger
.
info
(
f
"Output written to
{
unrelaxed_output_path
}
..."
)
logger
.
info
(
f
"Running relaxation on
{
unrelaxed_output_path
}
..."
)
logger
.
info
(
f
"Running relaxation on
{
unrelaxed_output_path
}
..."
)
relax_protein
(
config
,
args
.
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
)
relax_protein
(
config
,
args
.
model_device
,
unrelaxed_protein
,
output_directory
,
output_name
,
False
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment