Skip to content

Commit 020718b

Browse files
committed
Add ProteinMPNN integration with assets and tests
- Implement ProteinMPNN native spec and path handling - Improve working dir error messages and UTF-8 checks
1 parent 8ddba5c commit 020718b

File tree

7 files changed

+104
-20
lines changed

7 files changed

+104
-20
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,4 @@ jobs:
9090
9191
- name: Run Native tests
9292
run: |
93-
cargo install cargo-nextest --locked
9493
cargo nextest run -F native-tests,high-memory-tests

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ See [App Usage Examples](#app-usage-examples) for how to run each of these tools
2929
| `score` ||| |
3030
| `pyrosetta` ||| |
3131
| `rfdiffusion` ||||
32-
| `proteinmpnn` ||| |
32+
| `proteinmpnn` ||| |
3333
| `proteinmpnn-script` ||| |
3434
| `ligandmpnn` ||| |
3535
| `foundry` ||||
@@ -331,16 +331,3 @@ rc -v run rosetta score -in:file:s structure.pdb
331331
```
332332

333333
This will show detailed information including the exact command being executed and where it's being logged.
334-
335-
## Requirements
336-
337-
- One of the supported container engines (Docker, Singularity, or Apptainer)
338-
- Appropriate container images for the applications you want to run
339-
340-
## License
341-
342-
See LICENSE file for details.
343-
344-
## Author
345-
346-
Sergey Lyskov

assets/pixi/proteinmpnn.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[workspace]
2+
name = "proteinmpnn"
3+
version = "0.0.1"
4+
description = "Pixi environment for https://github.com/dauparas/ProteinMPNN"
5+
platforms = ["linux-64"]
6+
channels = ["conda-forge"]
7+
8+
[dependencies]
9+
python = "3.11.*"
10+
pip = "*"
11+
git = "*"
12+
wget = "*"
13+
ca-certificates = "*"
14+
15+
# # Optional but nice for debugging
16+
# mc = "*"
17+
18+
numpy = "*"
19+
biopython = "*"
20+
pandas = "*"
21+
tqdm = "*"
22+
23+
[pypi-options]
24+
index-url = "https://pypi.org/simple"
25+
extra-index-urls = ["https://download.pytorch.org/whl/cu121"]
26+
27+
[pypi-dependencies]
28+
torch = "*"
29+
torchvision = "*"
30+
torchaudio = "*"
31+
32+
[tasks]
33+
#setup = { depends-on = ["install"] }
34+
setup = { depends-on = ["clone"] }
35+
36+
[tasks.clone]
37+
cmd = "rm -rf proteinmpnn-repo-clone && git clone https://github.com/dauparas/ProteinMPNN.git proteinmpnn-repo-clone"
38+
39+
# Run ProteinMPNN with arbitrary args:
40+
[tasks.execute]
41+
args = ["args"]
42+
cmd = "python protein_mpnn_run.py {{args}}"
43+
cwd = "proteinmpnn-repo-clone"
44+
45+
[activation]
46+
env = { PYTHONWARNINGS = "ignore::FutureWarning" }

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl App {
191191
App::Rosetta => todo!("not implemented"), // rosetta::native_spec(app_args),
192192
App::PyRosetta => todo!("not implemented"), // pyrosetta::native_spec(app_args),
193193
App::Rfdiffusion => rfdiffusion::native_spec(app_args, working_dir),
194-
App::Proteinmpnn => todo!("not implemented"), // proteinmpnn::native_spec(app_args),
194+
App::Proteinmpnn => proteinmpnn::native_spec(app_args, working_dir),
195195
App::ProteinmpnnScript => todo!("not implemented"), // proteinmpnn_script::native_spec(app_args),
196196
App::Ligandmpnn => todo!("not implemented"), // ligandmpnn::native_spec(app_args),
197197
App::Foundry => foundry::native_spec(app_args, working_dir),

src/app/proteinmpnn.rs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
use crate::app::ContainerRunSpec;
1+
use camino::{Utf8Path, Utf8PathBuf};
2+
3+
use crate::{
4+
app::{ContainerRunSpec, NativeRunSpec},
5+
util::include_asset,
6+
};
27

38
pub fn container_spec(app_args: Vec<String>) -> ContainerRunSpec {
49
ContainerRunSpec::with_prefixed_args(
@@ -8,3 +13,47 @@ pub fn container_spec(app_args: Vec<String>) -> ContainerRunSpec {
813
)
914
.working_dir("/w")
1015
}
16+
17+
fn map_input_and_output_options(mut app_args: Vec<String>, working_dir: &Utf8Path) -> Vec<String> {
18+
const OPTIONS: [&str; 2] = ["--pdb_path", "--out_folder"];
19+
const OUTPUT_OPTION: &str = OPTIONS[1];
20+
21+
let mut output_option_present = false;
22+
23+
fn make_absolute(working_dir: &Utf8Path, path_str: &str) -> Utf8PathBuf {
24+
let path = Utf8PathBuf::from(path_str);
25+
if path.is_absolute() {
26+
path
27+
} else {
28+
working_dir.join(path)
29+
}
30+
}
31+
32+
for i in 1..app_args.len() {
33+
for option in OPTIONS {
34+
if app_args[i - 1] == option {
35+
app_args[i] = make_absolute(working_dir, &app_args[i]).into();
36+
if option == OUTPUT_OPTION {
37+
output_option_present = true;
38+
}
39+
break;
40+
}
41+
}
42+
}
43+
44+
if !output_option_present {
45+
app_args.extend([OUTPUT_OPTION.into(), working_dir.to_string()]);
46+
}
47+
app_args
48+
}
49+
50+
pub fn native_spec(app_args: Vec<String>, working_dir: &Utf8Path) -> super::NativeRunSpec {
51+
let app_args = map_input_and_output_options(app_args, working_dir);
52+
53+
let app_args = app_args
54+
.into_iter()
55+
.map(|arg| shell_escape::escape(arg.into()).into())
56+
.collect::<Vec<_>>();
57+
58+
NativeRunSpec::new(include_asset!("pixi/proteinmpnn.toml"), app_args)
59+
}

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ fn main() -> Result<()> {
148148
.clone()
149149
.unwrap_or_else(|| Utf8PathBuf::from("."))
150150
.canonicalize()
151-
.unwrap();
152-
let working_dir = Utf8PathBuf::try_from(working_dir).unwrap();
151+
.unwrap_or_else(|_| {
152+
panic!("{}", "Specified working directory does not exist".red())
153+
});
154+
let working_dir = Utf8PathBuf::try_from(working_dir)
155+
.unwrap_or_else(|_| panic!("{}", "Working dir path contains invalid UTF-8".red()));
153156

154157
run::run(app, app_args.clone(), container_engine, working_dir)
155158
}

tests/proteinmpnn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use assert_fs::TempDir;
33

44
mod common;
55

6-
common::engine_tests!(proteinmpnn);
6+
common::engine_tests!(proteinmpnn; engines(docker, apptainer, singularity, none));
77

88
fn proteinmpnn(engine: &str) {
99
use assert_fs::assert::PathAssert;

0 commit comments

Comments
 (0)