Skip to content

Commit 769faa0

Browse files
committed
Add PyRosetta support in executor and CLI
1 parent cbce0ad commit 769faa0

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

src/executor.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ pub fn run(
115115
None,
116116
),
117117

118+
App::PyRosetta => (
119+
Image("rosettacommons/rosetta:serial".into()),
120+
{
121+
app_args.insert(0, "python".into());
122+
app_args
123+
},
124+
None,
125+
),
126+
118127
App::Rfdiffusion => (
119128
Image("rosettacommons/rfdiffusion".into()),
120129
{

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Args {
2525
}
2626

2727
#[derive(ValueEnum, Clone, Copy, Debug, strum::Display)]
28-
#[strum(serialize_all = "kebab-case")] // "lowercase"
28+
#[strum(serialize_all = "lowercase")] // "kebab-case"
2929
enum ContainerEngine {
3030
Docker,
3131
Singularity,
@@ -69,14 +69,18 @@ enum Commands {
6969
}
7070

7171
#[derive(ValueEnum, Clone, Copy, Debug, strum::Display)]
72-
#[strum(serialize_all = "kebab-case")] // "lowercase"
72+
#[clap(rename_all = "lowercase")]
73+
#[strum(serialize_all = "lowercase")] // "kebab-case"
7374
enum App {
7475
/// Run the Rosetta score command
7576
Score,
7677

7778
/// Run the Rosetta protocol
7879
Rosetta,
7980

81+
/// Start python in env where PyRosetta is installed and execute script
82+
PyRosetta,
83+
8084
/// Run the RFdiffusion command https://github.com/RosettaCommons/RFdiffusion
8185
Rfdiffusion,
8286
}

tests/pyrosetta.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
mod common;
2+
3+
use assert_cmd::{assert::OutputAssertExt, cargo::cargo_bin_cmd};
4+
use assert_fs::TempDir;
5+
use predicates::prelude::*;
6+
7+
common::engine_tests!(pyrosetta);
8+
9+
fn pyrosetta(engine: &str) {
10+
use assert_fs::assert::PathAssert;
11+
use std::fs;
12+
13+
let root = std::path::PathBuf::from("target/score").join(engine);
14+
std::fs::create_dir_all(&root).expect("create engine testing dir");
15+
let work_dir = TempDir::new_in(root).expect("create temp dir");
16+
17+
let pdb_id = "1brs";
18+
let pdb_file = pdb_id.to_string() + ".pdb";
19+
20+
let pdb_path = work_dir.path().join(&pdb_file);
21+
std::fs::write(
22+
pdb_path,
23+
reqwest::blocking::get(format!("https://files.rcsb.org/download/{pdb_file}"))
24+
.unwrap()
25+
.bytes()
26+
.unwrap(),
27+
)
28+
.unwrap();
29+
30+
let cmd = cargo_bin_cmd!()
31+
.args([
32+
"run",
33+
"--container-engine",
34+
engine,
35+
"-w",
36+
work_dir.path().to_str().unwrap(),
37+
"pyrosetta", "-c",
38+
"import pyrosetta; pyrosetta.init(); pose=pyrosetta.pose_from_pdb('1brs.pdb'); print('1brs.pdb structure SCORE:', pyrosetta.get_score_function()(pose) )",
39+
])
40+
.unwrap();
41+
cmd.assert().success();
42+
43+
use assert_fs::prelude::PathChild;
44+
45+
let log_file_name = work_dir.child(".0000.rc.log");
46+
47+
log_file_name.assert(predicates::path::exists());
48+
49+
let log = fs::read_to_string(&log_file_name).unwrap();
50+
51+
for s in [
52+
"PyRosetta-4",
53+
"Created in JHU by Sergey Lyskov and PyRosetta Team",
54+
"core.init: Checking for fconfig files in pwd and ./rosetta/flags",
55+
"1brs.pdb structure SCORE: 255",
56+
] {
57+
assert!(predicates::str::contains(s).eval(&log));
58+
}
59+
60+
// std::thread::sleep(std::time::Duration::from_secs(60));
61+
}

0 commit comments

Comments
 (0)