Skip to content

Commit

Permalink
tmp fix for nontranslated clrs
Browse files Browse the repository at this point in the history
  • Loading branch information
smijeva committed Apr 29, 2024
1 parent f01066f commit cba7a33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static-z3 = ["z3/static-link-z3"]
pyo3 = { version = "0.20.0", features = ["abi3-py37", "extension-module"] }
biodivine-lib-param-bn = { version="0.5.9", features=["solver-z3"] }
biodivine-lib-bdd = "0.5.11"
biodivine-pbn-control = { git = "https://github.com/sybila/biodivine-pbn-control", rev = "9eadfda" }
biodivine-pbn-control = { git = "https://github.com/sybila/biodivine-pbn-control", rev = "61c630f" }
biodivine-hctl-model-checker = "0.2.2"
rand = "0.8.5"
macros = { path = "macros" }
Expand Down
23 changes: 19 additions & 4 deletions src/bindings/pbn_control/_impl_phenotype_control_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use pyo3::types::PyDict;
use biodivine_pbn_control::control::ControlMap;
use crate::bindings::pbn_control::py_dict_to_rust_hashmap;
use crate::bindings::pbn_control::rust_hashmap_to_py_dict;
use biodivine_lib_param_bn::symbolic_async_graph::GraphColors;
use std::collections::HashMap;


impl From<PhenotypeControlMap> for PyPhenotypeControlMap {
Expand Down Expand Up @@ -68,11 +70,24 @@ impl PyPhenotypeControlMap {

/// Obtain a set of colours for which the given perturbation works
pub fn perturbation_working_colors(&self, perturbation: &PyDict) -> PyGraphColors {
// TEMPORARY WORKAROUND - The translation does not work properly yet in RUST -> go trough full result
let p = py_dict_to_rust_hashmap(perturbation);
let all = self.as_native().working_perturbations(0.01, false, true);
let results: Vec<&(HashMap<String, bool>, GraphColors)> = all.iter().filter(|m| (m.0 == p && p == m.0)).collect();

self.as_native()
.perturbation_working_colors(&p)
.clone()
.into()
if results.len() > 1 {
panic!("Multiple results matching to perturbation {:?} were found in the full result {:?}", perturbation, all)
} else if results.len() == 1 {
return results[0].1.clone().into()
} else {
return self.as_colored_vertices().minus(&self.as_colored_vertices()).colors().into()
}

// let p = py_dict_to_rust_hashmap(perturbation);
//
// self.as_native()
// .perturbation_working_colors(&p)
// .clone()
// .into()
}
}

0 comments on commit cba7a33

Please sign in to comment.