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

Utilities to perform consistency checks.

source

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.

source

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
source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

fn assert_dataset_valid(&self, dataset_id: &DatasetId) -> Result<(), String>

Check that dataset is valid. If not, return error with a proper message.

source

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

source

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.

source

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

source

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.

source

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

source

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#

source

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
source

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
source

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

source

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.

source

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

source

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

Utility functions for creating or modifying sketch instances.

source

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.

source

pub fn new_from_sketch_data(sketch_data: &SketchData) -> Result<Sketch, String>

Create a new Sketch instance given a corresponding SketchData object.

source

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.

source

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.

source

pub fn set_to_empty(&mut self)

Modify this Sketch instance to a default (empty) settings.

source

pub fn get_annotation(&self) -> &str

Get annotation string.

source

pub fn set_annotation(&mut self, annotation: &str)

Set annotation string.

Trait Implementations§

source§

impl Clone for Sketch

source§

fn clone(&self) -> Sketch

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sketch

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Sketch

source§

fn default() -> Sketch

Default empty sketch.

source§

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
where T: FromStr, <T as FromStr>::Err: Debug,

Generate an ID of type T for a certain component of a manager (e.g., generate a VariableId for a Variable in a ModelState). Read more
source§

fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are already managed by the manager instance (this is important, for instance, when we need to change already existing elements). Read more
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>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are NOT yet managed by the manager instance, i.e., they are fresh new values (this is important, for instance, when we need to add several new elements). Read more
source§

impl PartialEq for Sketch

source§

fn eq(&self, other: &Sketch) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SessionHelper for Sketch

source§

fn starts_with<'a, 'b>( prefix: &str, at_path: &'a [&'b str], ) -> Option<&'a [&'b str]>

A utility function which checks if 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

A utility function which checks if at_path is exactly
source§

fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>

A utility function which emits a generic “invalid path” error.
source§

fn invalid_path_error_specific<T>( path: &[&str], component: &str, ) -> Result<T, DynError>

A utility function which emits a “invalid path” error mentioning specific state’s component.
source§

fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>

A utility function to get and clone a payload of an event. Errors if payload is empty. Read more
source§

fn assert_path_length( path: &[&str], length: usize, component: &str, ) -> Result<(), DynError>

A utility function to assert that path has a given length, or emit a DynError otherwise. Read more
source§

fn assert_payload_empty(event: &Event, component: &str) -> Result<(), DynError>

A utility function to assert that payload is empty - otherwise, DynError is emitted. Read more
source§

impl SessionState for Sketch

source§

fn perform_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>

Modify the session state using the provided event. The possible outcomes are described by Consumed.
source§

fn refresh( &self, full_path: &[String], at_path: &[&str], ) -> Result<Event, DynError>

“Read” session state into an event without modifying it.
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,