pub struct RegulatoryGraph { /* private fields */ }
Expand description

A directed graph representing relationships between a collection of Boolean variables using Regulations.

It can be explored using regulators, targets, transitive_regulators, or transitive_targets (for example to determine if two variables depend on each other). We can also compute the SCCs of this graph.

A regulatory graph can be described using a custom string format. In this format, each line represents a regulation or a comment (starting with #).

Regulations can be represented as strings in the form of "regulator_name 'relationship' target_name". The ‘relationship’ is one of the arrow strings ->, ->?, -|, -|?, -?, -??. Here, > means activation, | is inhibition and ? is unspecified monotonicity. The last question mark signifies observability — if it is present, the regulation is not necessarily observable. See Regulation and tutorial module for a more detailed explanation.

Example of a RegulatoryGraph:

 # Regulators of a
 a ->? a
 b -|? a

 # Regulators of b
 a -> b
 b -| b

Implementations§

source§

impl RegulatoryGraph

Methods for parsing RegulatoryGraphs from string representations.

source

pub fn try_from_string_regulations( regulations: Vec<String> ) -> Result<RegulatoryGraph, String>

Create a RegulatoryGraph from a collection of regulation strings.

The variables of the RegulatoryGraph are determined from the regulations and are ordered alphabetically. Otherwise, this is equivalent to iteratively calling add_string_regulation.

source

pub fn add_string_regulation(&mut self, regulation: &str) -> Result<(), String>

Add a new Regulation to this RegulatoryGraph where the regulation is given in its string representation (e.g. “v1 ->? v2”).

The regulation parameter must be a valid string representation of a regulation, plus all conditions of add_regulation must be satisfied as well.

source§

impl RegulatoryGraph

Methods for safely constructing new instances of RegulatoryGraphs.

source

pub fn new(variables: Vec<String>) -> RegulatoryGraph

Create a new RegulatoryGraph with variables using the given names and no regulations.

The ordering of the variables is preserved.

source

pub fn add_regulation( &mut self, regulator: &str, target: &str, observable: bool, monotonicity: Option<Monotonicity> ) -> Result<(), String>

Add a new Regulation to this RegulatoryGraph.

Returns Err if regulator or target are not valid graph variables or when the regulation between the two variables already exists.

source

pub fn remove_regulation( &mut self, regulator: VariableId, target: VariableId ) -> Result<Regulation, String>

Remove a Regulation from this RegulatoryGraph assuming it exists.

Note that if there is a [BooleanNetwork] that uses this graph internally, this can make some if its functions invalid if they depend on the existence of this regulation.

source

pub fn add_raw_regulation( &mut self, regulation: Regulation ) -> Result<(), String>

Add a new regulation using the Regulation object.

source

pub fn set_variable_name( &mut self, id: VariableId, name: &str ) -> Result<(), String>

Set the name of a network variable. The name must not be used by any other variable.

Note that you don’t have to rename anything else in the network, since all other structures reference variables with ids.

source

pub fn variable_names(&self) -> Vec<String>

Copy the variable names from this graph into a separate vector.

source§

impl RegulatoryGraph

Some basic utility methods for inspecting the RegulatoryGraph.

source

pub fn num_vars(&self) -> usize

The number of variables in this RegulatoryGraph.

source

pub fn find_variable(&self, name: &str) -> Option<VariableId>

Find a VariableId for the given name, or None if the variable does not exist.

source

pub fn get_variable(&self, id: VariableId) -> &Variable

Return a Variable corresponding to the given VariableId.

source

pub fn get_variable_name(&self, id: VariableId) -> &String

Shorthand for self.get_variable(id).get_name().

source

pub fn find_regulation( &self, regulator: VariableId, target: VariableId ) -> Option<&Regulation>

Find a Regulation between two variables if it exists, None otherwise.

source

pub fn regulators(&self, target: VariableId) -> Vec<VariableId>

Return a sorted list of variables that regulate the given target variable.

source

pub fn targets(&self, regulator: VariableId) -> Vec<VariableId>

Return a sorted list of variables that are regulated by the given regulator variable.

source

pub fn components(&self) -> Vec<HashSet<VariableId>>

👎Deprecated

Compute the strongly connected components of this regulatory graph. The components are sorted topologically based on their position in the graph condensation.

When sorting topologically incomparable components, we use component size as the secondary criterion. Also, note that the algorithm is not particularly efficient, so it should be used on large networks with caution!

**Deprecated in favor of strongly_connected_components.

source

pub fn variables(&self) -> VariableIdIterator

Return an iterator over all variable ids of this graph.

source

pub fn regulations(&self) -> RegulationIterator<'_>

Return an iterator over all regulations of this graph.

source

pub fn is_valid_name(name: &str) -> bool

A static check that allows to verify validity of a variable name.

source§

impl RegulatoryGraph

source

pub fn to_dot(&self) -> String

Export this regulatory graph to a .dot format.

In the representation, we use red and green color to distinguish positive and negative regulations. Dashed edges show regulations without observability requirement.

source

pub fn write_as_dot(&self, output: &mut dyn Write) -> Result<(), Error>

source§

impl RegulatoryGraph

Algorithms for analysing the underlying signed directed graph.

source

pub fn strongly_connected_components(&self) -> Vec<HashSet<VariableId>>

Compute all non-trivial strongly connected components of the regulatory graph.

The result is sorted by component size.

source

pub fn restricted_strongly_connected_components( &self, restriction: &HashSet<VariableId> ) -> Vec<HashSet<VariableId>>

Compute all non-trivial strongly connected components restricted within the given set of vertices.

The result is sorted by component size.

source

pub fn transitive_regulators(&self, target: VariableId) -> HashSet<VariableId>

Compute all variables that transitively regulate the given target variable.

source

pub fn transitive_targets(&self, regulator: VariableId) -> HashSet<VariableId>

Compute all variables that are transitively regulated by the given regulator variable.

source

pub fn shortest_cycle(&self, pivot: VariableId) -> Option<Vec<VariableId>>

Compute the shortest cycle that contains the given pivot vertex, or None if there is no such cycle.

source

pub fn shortest_parity_cycle( &self, pivot: VariableId, target_parity: Sign ) -> Option<Vec<VariableId>>

Compute the shortest simple cycle that contains the given pivot vertex and has the specified target_parity.

source

pub fn feedback_vertex_set(&self) -> HashSet<VariableId>

Compute the set of variables that, if removed, cause this RegulatoryGraph to become acyclic.

The method tries to obtain a minimal such set, but the minimality is not guaranteed.

source

pub fn parity_feedback_vertex_set(&self, parity: Sign) -> HashSet<VariableId>

Compute the set of variables that, if removed, causes this RegulatoryGraph to lose all cycles of the specified parity.

The method tries to obtain a minimal such set, but the minimality is not guaranteed.

source

pub fn independent_cycles(&self) -> Vec<Vec<VariableId>>

Compute a collection of independent cycles of this RegulatoryGraph. That is, disjoint cycles that intersect every cycle in the graph.

The method tries to obtain a maximal such set, but the maximality is not guaranteed.

source

pub fn independent_parity_cycles(&self, parity: Sign) -> Vec<Vec<VariableId>>

Compute a collection of independent cycles of this RegulatoryGraph with desired parity. That is, disjoint cycles of the given parity that intersect every other cycle of this parity in the graph.

The method tries to obtain a maximal such set, but the maximality is not guaranteed.

Trait Implementations§

source§

impl Clone for RegulatoryGraph

source§

fn clone(&self) -> RegulatoryGraph

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 RegulatoryGraph

source§

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

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

impl Display for RegulatoryGraph

source§

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

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

impl From<&RegulatoryGraph> for SdGraph

source§

fn from(rg: &RegulatoryGraph) -> Self

Converts to this type from the input type.
source§

impl Index<VariableId> for RegulatoryGraph

Allow indexing RegulatoryGraph using VariableId objects.

§

type Output = Variable

The returned type after indexing.
source§

fn index(&self, index: VariableId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq for RegulatoryGraph

To consider two regulatory graphs equivalent, we generally assume that they have the same number of variables, with the same names, and stored in the same order. Furthermore, they also need to have the same regulations, however, these do not have a specific order that needs to be preserved. The reason why we enforce variable order and not regulation order is that VariableId objects should be compatible across equivalent graphs, but there is no RegulationId or a similar requirement.

source§

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

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

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

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

impl TryFrom<&str> for RegulatoryGraph

§

type Error = String

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

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for RegulatoryGraph

Auto Trait Implementations§

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

source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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

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

source§

fn vzip(self) -> V