Struct demes_forward::ForwardGraph
source · pub struct ForwardGraph { /* private fields */ }
Expand description
Forward-time representation of a demes::Graph
.
Implementations§
source§impl ForwardGraph
impl ForwardGraph
sourcepub fn new_discrete_time<F: Into<ForwardTime> + Debug + Copy>(
graph: Graph,
burnin_time: F
) -> Result<Self, DemesForwardError>
pub fn new_discrete_time<F: Into<ForwardTime> + Debug + Copy>( graph: Graph, burnin_time: F ) -> Result<Self, DemesForwardError>
sourcepub fn update_state<F: Into<ForwardTime> + Debug + Copy>(
&mut self,
parental_generation_time: F
) -> Result<(), DemesForwardError>
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
.
sourcepub fn num_demes_in_model(&self) -> usize
pub fn num_demes_in_model(&self) -> usize
The total number of demes in the graph.
sourcepub fn ancestry_proportions(&self, offspring_deme: usize) -> Option<&[f64]>
pub fn ancestry_proportions(&self, offspring_deme: usize) -> Option<&[f64]>
sourcepub fn cloning_rates(&self) -> Option<&[CloningRate]>
pub fn cloning_rates(&self) -> Option<&[CloningRate]>
Get cloning rates of all offspring demes.
Returns None
if there are no extant offspring
demes.
sourcepub fn selfing_rates(&self) -> Option<&[SelfingRate]>
pub fn selfing_rates(&self) -> Option<&[SelfingRate]>
Get selfing rates of all offspring demes.
Returns None
if there are no extant offspring
demes.
sourcepub fn last_time_updated(&self) -> Option<ForwardTime>
pub fn last_time_updated(&self) -> Option<ForwardTime>
Obtain the time corresponding to the last
call of ForwardGraph::update_state
.
sourcepub fn end_time(&self) -> ForwardTime
pub fn end_time(&self) -> ForwardTime
Obtain the end time of the model.
sourcepub fn time_iterator(&self) -> impl Iterator<Item = ForwardTime>
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.
sourcepub fn parental_deme_sizes(&self) -> Option<&[CurrentSize]>
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.
sourcepub fn offspring_deme_sizes(&self) -> Option<&[CurrentSize]>
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.
sourcepub fn any_extant_parental_demes(&self) -> bool
pub fn any_extant_parental_demes(&self) -> bool
Return true
if there are any extant parental
demes at the current time.
sourcepub fn any_extant_offspring_demes(&self) -> bool
pub fn any_extant_offspring_demes(&self) -> bool
Return true
if there are any extant offspring
demes at the current time.
sourcepub fn num_extant_parental_demes(&self) -> usize
pub fn num_extant_parental_demes(&self) -> usize
Return the number of extant parental demes at the current time.
sourcepub fn num_extant_offspring_demes(&self) -> usize
pub fn num_extant_offspring_demes(&self) -> usize
Return the number of extant offspring demes at the current time.
sourcepub fn size_at<'a, I: Into<DemeId<'a>>, T: Into<BackwardTimeWrapper>>(
&self,
deme: I,
time: T
) -> Result<Option<CurrentSize>, DemesForwardError>
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 identifiertime
: a time
§Returns
Some(DemeSize)
if there are parents at the given time.None
ifdeme
does not exist or the deme exists but is not in existence attime
.
§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.
sourcepub fn deme_size_history<'a, I>(
&self,
deme: I
) -> Result<impl Iterator<Item = DemeSizeAt>, DemesForwardError>
pub fn deme_size_history<'a, I>( &self, deme: I ) -> Result<impl Iterator<Item = DemeSizeAt>, DemesForwardError>
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
sourcepub fn backwards_start_time(&self) -> Time
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.
sourcepub fn backwards_burn_in_time(&self) -> Time
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
.
sourcepub fn time_to_backward<T: Into<ForwardTimeWrapper>>(
&self,
time: T
) -> Result<Option<Time>, DemesForwardError>
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
iftime
is ancestral to the start of the model or more recent than the model’s end.
sourcepub fn time_to_forward<T: Into<BackwardTimeWrapper>>(
&self,
time: T
) -> Result<Option<ForwardTime>, DemesForwardError>
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
iftime
is ancestral to the start of the model or more recent than the model’s end.
sourcepub fn deme_names(&self) -> Box<[&str]>
pub fn deme_names(&self) -> Box<[&str]>
sourcepub fn demes_graph(&self) -> &Graph
pub fn demes_graph(&self) -> &Graph
Access to the underlying demes::Graph
Trait Implementations§
source§impl Clone for ForwardGraph
impl Clone for ForwardGraph
source§fn clone(&self) -> ForwardGraph
fn clone(&self) -> ForwardGraph
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more