Struct demes_forward::ForwardGraph

source ·
pub struct ForwardGraph { /* private fields */ }
Expand description

Forward-time representation of a demes::Graph.

Implementations§

source§

impl ForwardGraph

source

pub fn new_discrete_time<F: Into<ForwardTime> + Debug + Copy>( graph: Graph, burnin_time: F ) -> Result<Self, DemesForwardError>

Constructor

§Parameters
  • graph: a demes::Graph.
  • burnin_time: Burn-in time for the model.
source

pub fn update_state<F: Into<ForwardTime> + Debug + Copy>( &mut self, parental_generation_time: F ) -> Result<(), DemesForwardError>

Update the internal state of the graph to the parental generation time parental_generation_time.

source

pub fn num_demes_in_model(&self) -> usize

The total number of demes in the graph.

source

pub fn ancestry_proportions(&self, offspring_deme: usize) -> Option<&[f64]>

The ancestry proporitions for a given offspring deme at the current time.

§Parameters
  • offspring_deme: the index of an offspring deme.
§Returns
  • Some(&[f64]) if offspring_deme is a valid index and extant offspring demes exist.
  • None otherwise.
source

pub fn cloning_rates(&self) -> Option<&[CloningRate]>

Get cloning rates of all offspring demes.

Returns None if there are no extant offspring demes.

source

pub fn selfing_rates(&self) -> Option<&[SelfingRate]>

Get selfing rates of all offspring demes.

Returns None if there are no extant offspring demes.

source

pub fn last_time_updated(&self) -> Option<ForwardTime>

Obtain the time corresponding to the last call of ForwardGraph::update_state.

source

pub fn end_time(&self) -> ForwardTime

Obtain the end time of the model.

source

pub fn time_iterator(&self) -> impl Iterator<Item = ForwardTime>

Return an iterator over time values.

The iterator starts at the last updated time and continues until the end time.

source

pub fn parental_deme_sizes(&self) -> Option<&[CurrentSize]>

Obtain the sizes of each parental deme.

The length of the slice is equal to the number of demes in the graph (see ForwardGraph::num_demes_in_model).

Returns None if there are no parental demes at the current time.

source

pub fn offspring_deme_sizes(&self) -> Option<&[CurrentSize]>

Obtain the sizes of each offspring deme.

The length of the slice is equal to the number of demes in the graph (see ForwardGraph::num_demes_in_model).

Returns None if there are no offspring demes at the current time.

source

pub fn any_extant_parental_demes(&self) -> bool

Return true if there are any extant parental demes at the current time.

source

pub fn any_extant_offspring_demes(&self) -> bool

Return true if there are any extant offspring demes at the current time.

source

pub fn num_extant_parental_demes(&self) -> usize

Return the number of extant parental demes at the current time.

source

pub fn num_extant_offspring_demes(&self) -> usize

Return the number of extant offspring demes at the current time.

source

pub fn size_at<'a, I: Into<DemeId<'a>>, T: Into<BackwardTimeWrapper>>( &self, deme: I, time: T ) -> Result<Option<CurrentSize>, DemesForwardError>

Obtain the size (number of parental individuals) of a given deme at a given time.

§Parameters
  • deme: a deme identifier
  • time: a time
§Returns
  • Some(DemeSize) if there are parents at the given time.
  • None if deme does not exist or the deme exists but is not in existence at time.
§Errors

DemesForwardError if the calculation of deme size returns an invalid demes::DemeSize or if time is not a valid value.

§Notes
  • Time is measured backwards in time from 0.0 (inclusive of zero). The reason is that it is usually easier to reason about time in this way.
  • Unlike a demes::Graph, time does not go back in the past to “infinity”. The first parental generation is considered to exist at a time one generation prior to the start of events in the graph plus the burn-in time.
source

pub fn deme_size_history<'a, I>( &self, deme: I ) -> Result<impl Iterator<Item = DemeSizeAt>, DemesForwardError>
where I: Debug + Into<DemeId<'a>>,

Generate an iterator over the size history of a deme.

§Parameters
  • deme: the index or name of the deme
§Returns

An iterator over instances of DemeSizeAt.

§Errors

This function will return an error if:

  • deme does not exist in the graph
§Note

The iterated values are lazily evaluated. First self is cloned. Then, the entire model history is iterated over, and the output data is returned during iteration.

§Panics
  • Cloning the graph requires allocations which will panic if the system runs out of memory
source

pub fn backwards_start_time(&self) -> Time

Return the time in the past when the first generation of the model exists. This time point represents the individuals alive at time zero (forwards in time) who are the ancestors of those individuals born at time 1 of the model.

source

pub fn backwards_burn_in_time(&self) -> Time

Return the time in the model at the end of any “burn-in”.

§Note

This value is distinct from the burn-in duration. Instead, this value represents the time when all alive individuals are the ancestors of the first finite time in the demes::Graph.

source

pub fn time_to_backward<T: Into<ForwardTimeWrapper>>( &self, time: T ) -> Result<Option<Time>, DemesForwardError>

Convert a forward time value (ForwardTime) into a backwards time value (demes::Time)

§Returns
  • None if time is ancestral to the start of the model or more recent than the model’s end.
source

pub fn time_to_forward<T: Into<BackwardTimeWrapper>>( &self, time: T ) -> Result<Option<ForwardTime>, DemesForwardError>

Convert a backwards time value (demes::Time) into a forward time value (ForwardTime)

§Returns
  • None if time is ancestral to the start of the model or more recent than the model’s end.
source

pub fn deme_names(&self) -> Box<[&str]>

Get the names of each deme in the model.

§Note

Implemented by calling demes::Graph::deme_names.

source

pub fn demes_graph(&self) -> &Graph

Access to the underlying demes::Graph

Trait Implementations§

source§

impl Clone for ForwardGraph

source§

fn clone(&self) -> ForwardGraph

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 ForwardGraph

source§

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

Formats the value using the given formatter. Read more

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