|
| 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