Skip to content

Commit

Permalink
Adds a test for RaSP (which will get skipped in the action, unfortuna…
Browse files Browse the repository at this point in the history
…tely)
  • Loading branch information
miguelgondu committed Oct 30, 2023
1 parent 3aa48a9 commit f871534
Show file tree
Hide file tree
Showing 6 changed files with 2,702 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def saturation_mutagenesis_for_protein_at_position(


if __name__ == "__main__":
wildtype_pdb_paths_for_rasp = list((THIS_DIR / "two_proteins").glob("*.pdb"))
wildtype_pdb_paths_for_rasp = [
THIS_DIR / "two_proteins" / "3ned.pdb",
THIS_DIR / "two_proteins" / "2vae.pdb",
]

_, f_rasp, x0, y0, _ = objective_factory.create(
name="rasp",
Expand Down Expand Up @@ -74,4 +77,5 @@ def saturation_mutagenesis_for_protein_at_position(
]
)

print(df.head())
print(df.head(20))
print(df.values[:20, 1])
13 changes: 13 additions & 0 deletions src/poli/core/util/proteins/rasp/inner_rasp/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2022 - University of Copenhagen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
24 changes: 19 additions & 5 deletions src/poli/core/util/proteins/rasp/rasp_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
so you will only need internet access once.
[1] TODO: add.
[2] TODO: add.
RaSP's source code was provided with an Apache 2.0 license. Modifications
from the source have been duly noted. Most of the source code can be found
at ./inner_rasp.
"""

from typing import List
Expand Down Expand Up @@ -60,8 +65,15 @@


class RaspInterface:
def __init__(self, working_dir: Path, verbose: bool = False) -> None:
def __init__(
self,
working_dir: Path,
verbose: bool = False,
verify_integrity_of_download: bool = True,
) -> None:
self.working_dir = working_dir
self.verbose = verbose
self.verify_integrity_of_download = verify_integrity_of_download

# Making the appropriate folders:
(self.working_dir / "raw").mkdir(parents=True, exist_ok=True)
Expand All @@ -81,7 +93,9 @@ def __init__(self, working_dir: Path, verbose: bool = False) -> None:
# Downloading the cavity and downstream models.
# TODO: should we be doing this eagerly? Or should
# we wait to download and install it until we need it?
self.download_cavity_and_downstream_models(verbose=verbose)
self.download_cavity_and_downstream_models(
verbose=verbose, verify_integrity_of_download=verify_integrity_of_download
)

def get_and_compile_reduce(self):
"""
Expand Down Expand Up @@ -190,7 +204,7 @@ def predict(
return df_total

def download_cavity_and_downstream_models(
self, verbose: bool = False, strict: bool = True
self, verbose: bool = False, verify_integrity_of_download: bool = True
):
"""
This function downloads the cavity and downstream models
Expand Down Expand Up @@ -250,7 +264,7 @@ def download_cavity_and_downstream_models(
downloaded_md5_checksum
!= precomputed_model_md5_checksums[cavity_model_path]
):
if strict:
if verify_integrity_of_download:
raise RuntimeError(
"The downloaded cavity model does not match the expected md5 checksum. "
"This could be due to a corrupted download, or a malicious attack. "
Expand Down Expand Up @@ -285,7 +299,7 @@ def download_cavity_and_downstream_models(
downloaded_md5_checksum
!= precomputed_model_md5_checksums[path_.parent.name]
):
if strict:
if verify_integrity_of_download:
raise RuntimeError(
f"The downloaded downstream model {path_.parent.name} does not match the expected md5 checksum. "
"This could be due to a corrupted download, or a malicious attack. "
Expand Down
Loading

0 comments on commit f871534

Please sign in to comment.