Struct biodivine_sketchbook::sketchbook::_sketch::Sketch
source · pub struct Sketch {
pub model: ModelState,
pub observations: ObservationManager,
pub properties: PropertyManager,
pub annotation: String,
}
Expand description
Object encompassing all of the individual modules of the Boolean network sketch.
Most of the actual functionality is implemented by the modules themselves, Sketch
currently only distributes events and handles situations when cooperation between
modules is needed.
Fields§
§model: ModelState
§observations: ObservationManager
§properties: PropertyManager
§annotation: String
Implementations§
source§impl Sketch
impl Sketch
Utilities to perform consistency checks.
sourcepub fn assert_consistency(&self) -> Result<(), String>
pub fn assert_consistency(&self) -> Result<(), String>
Assert that the sketch is consistent, return error otherwise. See Self::run_consistency_check for details on which criteria are checked.
sourcepub fn run_consistency_check(&self) -> (bool, String)
pub fn run_consistency_check(&self) -> (bool, String)
General check that all components of the sketch are consistent together.
Note that most of the general consistency (syntax of formulas, check validity and uniqueness of IDs, ..) is enforced automatically when editing the sketch. However, some more complex details are left to be checked (either explicitely or automatically before the inference is started).
This should include:
- check that model is not empty
- check that dataset variables are valid network variables
- check that various template properties reference valid variables and data
- check that HCTL formulas only use valid variables as atomic propositions
- check that FOL formulas only use valid function symbols
sourcefn check_model(&self) -> (bool, String)
fn check_model(&self) -> (bool, String)
Part of the consistency check responsible for the ‘model’ component. Returns bool (whether a model is consistent) and formated message with issues.
sourcefn check_datasets(&self) -> (bool, String)
fn check_datasets(&self) -> (bool, String)
Part of the consistency check responsible for the ‘observations’ (datasets) component. Returns bool (whether a datasets are consistent) and formated message with issues.
sourcefn check_static(&self) -> (bool, String)
fn check_static(&self) -> (bool, String)
Part of the consistency check responsible for the ‘static properties’ component. Returns bool (whether a static properties are consistent) and formated message with issues.
sourcefn check_dynamic(&self) -> (bool, String)
fn check_dynamic(&self) -> (bool, String)
Part of the consistency check responsible for the ‘dynamic properties’ component. Returns bool (whether a dynamic properties are consistent) and formated message with issues.
sourcefn assert_static_prop_valid(&self, prop: &StatProperty) -> Result<(), String>
fn assert_static_prop_valid(&self, prop: &StatProperty) -> Result<(), String>
Check if all fields of the static property are filled and have valid values. If not, return appropriate message.
sourcefn assert_dynamic_prop_valid(&self, prop: &DynProperty) -> Result<(), String>
fn assert_dynamic_prop_valid(&self, prop: &DynProperty) -> Result<(), String>
Check if all fields of the dynamic property are filled and have valid values. If not, return appropriate message.
sourcefn assert_var_valid(&self, var_id: &VarId) -> Result<(), String>
fn assert_var_valid(&self, var_id: &VarId) -> Result<(), String>
Check that variable is valid in a model. If not, return error with a proper message.
sourcefn assert_fn_valid(&self, fn_id: &UninterpretedFnId) -> Result<(), String>
fn assert_fn_valid(&self, fn_id: &UninterpretedFnId) -> Result<(), String>
Check that function is valid in a model. If not, return error with a proper message.
sourcefn assert_index_valid(
&self,
index: usize,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
fn assert_index_valid( &self, index: usize, fn_id: &UninterpretedFnId, ) -> Result<(), String>
Check that input index of uninterpreted function is in range (smaller than the arity). If not, return error with a proper message.
sourcefn assert_context_valid_or_none(
&self,
context: Option<&String>,
) -> Result<(), String>
fn assert_context_valid_or_none( &self, context: Option<&String>, ) -> Result<(), String>
Check that context formula is valid. If not, return error with a proper message.
The context can also be None, which is valid.
sourcefn assert_dataset_valid(&self, dataset_id: &DatasetId) -> Result<(), String>
fn assert_dataset_valid(&self, dataset_id: &DatasetId) -> Result<(), String>
Check that dataset is valid. If not, return error with a proper message.
sourcefn assert_obs_valid_or_none(
&self,
dataset_id: &DatasetId,
obs_id: Option<&ObservationId>,
) -> Result<(), String>
fn assert_obs_valid_or_none( &self, dataset_id: &DatasetId, obs_id: Option<&ObservationId>, ) -> Result<(), String>
Check whether observation is valid in a dataset. If not, return error with a proper message. If observation is None, that is also fine.
source§impl Sketch
impl Sketch
sourcepub fn to_custom_json(&self) -> String
pub fn to_custom_json(&self) -> String
Convert the sketch instance into a custom (pretty) JSON string.
See SketchData::to_pretty_json_str for details on the actual conversion to JSON.
sourcepub fn export_to_custom_json(&self, filepath: &str) -> Result<(), String>
pub fn export_to_custom_json(&self, filepath: &str) -> Result<(), String>
Export the sketch instance into a custom JSON model format.
See SketchData::to_pretty_json_str for details on the actual conversion to JSON.
source§impl Sketch
impl Sketch
sourcepub fn to_aeon(&self) -> String
pub fn to_aeon(&self) -> String
Convert the sketch instance into a customized version of AEON model format.
This format includes the standard AEON format for PSBN and layout. This format is compatible with other biodivine tools, but might not cover all parts of the sketch.
Apart from that, most remaining details of the sketch are given via model annotations.
Currently the annotations are given simpy as
#!entity_type: ID: #json_string
#
These entities can be variables, functions, static/dynamic properties, and datasets.
sourcepub fn export_to_aeon(&self, filepath: &str) -> Result<(), String>
pub fn export_to_aeon(&self, filepath: &str) -> Result<(), String>
Export the sketch instance into a customized version of AEON model format.
See Sketch::to_aeon for details on the actual conversion.
source§impl Sketch
impl Sketch
sourcepub fn from_aeon(aeon_str: &str) -> Result<Sketch, String>
pub fn from_aeon(aeon_str: &str) -> Result<Sketch, String>
Create sketch instance from a customized version of AEON model format. The original part of the AEON format (compatible with other biodivine tools) includes:
- variable IDs
- regulations (and corresponding automatically generated static properties)
- update functions and function symbols
- layout information
The custom extension covers most remaining parts of the sketch via model annotations.
Currently the annotations are given simpy as
#!entity_type: ID: #json_string
#
These annotations either cover additional information (complementing variables and
functions), or completely new components like static/dynamic properties and datasets.
We allow a special case for writing HCTL and FOL properties, compatible with the
original BN sketches prototype format:
#!static_property: ID: #fol_formula_string
#
#!dynamic_property: ID: #hctl_formula_string
#
sourcepub fn from_sbml(sbml_str: &str) -> Result<Sketch, String>
pub fn from_sbml(sbml_str: &str) -> Result<Sketch, String>
Create sketch instance from a SBML model format. This variant includes:
- variables
- regulations (and corresponding automatically generated static properties)
- update functions and function symbols
- layout information
sourcepub fn from_boolean_network(bn: &BooleanNetwork) -> Result<Sketch, String>
pub fn from_boolean_network(bn: &BooleanNetwork) -> Result<Sketch, String>
Create sketch instance from a BooleanNetwork instance of lib-param-bn
.
This includes processing:
- variables
- regulations (and corresponding automatically generated static properties)
- update functions and function symbols
sourcefn extract_aeon_layout_info(aeon_str: &str) -> Vec<(String, f32, f32)>
fn extract_aeon_layout_info(aeon_str: &str) -> Vec<(String, f32, f32)>
Extract positions of nodes from the aeon model string. Positions are expect as lines in forllowing format: #position:NODE_ID:X,Y
This funtction returns a list of triplets <node_id, x, y>.
sourcefn extract_entities(
annotations: &ModelAnnotation,
entity_type: &str,
) -> Result<Vec<(String, String)>, String>
fn extract_entities( annotations: &ModelAnnotation, entity_type: &str, ) -> Result<Vec<(String, String)>, String>
Extract list of named entities (tuples with id/content) from an .aeon
model
annotation object.
The entities are expected to appear as:
#!entity_type: ID: #CONTENT
#
So, for example:
#!variable:ANT:#{"id":"ANT","name":"ANT","annotation":"","update_fn":""}
#
Each list is returned in alphabetic order w.r.t. the entity name.
sourcefn process_entity_node(
enitity_node: &ModelAnnotation,
enitity_type: &str,
) -> Result<Vec<(String, String)>, String>
fn process_entity_node( enitity_node: &ModelAnnotation, enitity_type: &str, ) -> Result<Vec<(String, String)>, String>
Given a ModelAnnotation
node corresponding to a particular entity type (like ‘variable’),
collect all entities of given type from the child nodes.
This is general for all entity types as annotations share common structure.
#!entity_type: ID: #CONTENT
#
List is returned in alphabetic order w.r.t. the property name.
source§impl Sketch
impl Sketch
sourcepub fn from_custom_json(json_str: &str) -> Result<Sketch, String>
pub fn from_custom_json(json_str: &str) -> Result<Sketch, String>
Create sketch instance from a custom JSON model format.
See SketchData::from_json_str for details on the actual parsing.
source§impl Sketch
impl Sketch
Utility functions for creating or modifying sketch instances.
sourcepub fn components_from_sketch_data(
sketch_data: &SketchData,
) -> Result<(ModelState, ObservationManager, PropertyManager), String>
pub fn components_from_sketch_data( sketch_data: &SketchData, ) -> Result<(ModelState, ObservationManager, PropertyManager), String>
Parse and validate all components of Sketch
from a corresponding SketchData
instance.
sourcepub fn new_from_sketch_data(sketch_data: &SketchData) -> Result<Sketch, String>
pub fn new_from_sketch_data(sketch_data: &SketchData) -> Result<Sketch, String>
Create a new Sketch
instance given a corresponding SketchData
object.
sourcepub fn modify_from_sketch_data(
&mut self,
sketch_data: &SketchData,
) -> Result<(), String>
pub fn modify_from_sketch_data( &mut self, sketch_data: &SketchData, ) -> Result<(), String>
Modify this Sketch
instance by loading all its components from a corresponding
SketchData
instance. The original sketch information is forgotten.
sourcepub fn modify_from_sketch(&mut self, other_sketch: &Sketch)
pub fn modify_from_sketch(&mut self, other_sketch: &Sketch)
Modify this Sketch
instance by loading all its components from a different
Sketch
instance. The original sketch information is forgotten.
sourcepub fn set_to_empty(&mut self)
pub fn set_to_empty(&mut self)
Modify this Sketch
instance to a default (empty) settings.
sourcepub fn get_annotation(&self) -> &str
pub fn get_annotation(&self) -> &str
Get annotation string.
sourcepub fn set_annotation(&mut self, annotation: &str)
pub fn set_annotation(&mut self, annotation: &str)
Set annotation string.
Trait Implementations§
source§impl Manager for Sketch
impl Manager for Sketch
source§fn generate_id<T>(
&self,
ideal_id: &str,
is_taken: &dyn Fn(&Self, &T) -> bool,
num_indices: usize,
start_index: Option<usize>,
) -> T
fn generate_id<T>( &self, ideal_id: &str, is_taken: &dyn Fn(&Self, &T) -> bool, num_indices: usize, start_index: Option<usize>, ) -> T
T
for a certain component of a manager (e.g., generate a
VariableId
for a Variable
in a ModelState
). Read moresource§fn assert_ids_unique_and_used<T>(
&self,
id_list: &Vec<&str>,
assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>,
) -> Result<(), String>
fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
source§fn assert_ids_unique_and_new<T>(
&self,
id_list: &Vec<&str>,
assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>,
) -> Result<(), String>
fn assert_ids_unique_and_new<T>( &self, id_list: &Vec<&str>, assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
source§impl SessionHelper for Sketch
impl SessionHelper for Sketch
source§fn starts_with<'a, 'b>(
prefix: &str,
at_path: &'a [&'b str],
) -> Option<&'a [&'b str]>
fn starts_with<'a, 'b>( prefix: &str, at_path: &'a [&'b str], ) -> Option<&'a [&'b str]>
at_path
starts with a specific first segment.
If yes, returns the remaining part of the path.source§fn matches(expected: &[&str], at_path: &[&str]) -> bool
fn matches(expected: &[&str], at_path: &[&str]) -> bool
at_path
is exactlysource§fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>
fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>
source§fn invalid_path_error_specific<T>(
path: &[&str],
component: &str,
) -> Result<T, DynError>
fn invalid_path_error_specific<T>( path: &[&str], component: &str, ) -> Result<T, DynError>
component
.source§fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>
fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>
source§impl SessionState for Sketch
impl SessionState for Sketch
impl StructuralPartialEq for Sketch
Auto Trait Implementations§
impl Freeze for Sketch
impl RefUnwindSafe for Sketch
impl Send for Sketch
impl Sync for Sketch
impl Unpin for Sketch
impl UnwindSafe for Sketch
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)