Struct demes::Graph

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

A resolved demes Graph.

Instances of this type will be fully-resolved according to the machine data model described here.

A graph cannot be directly initialized. See:

Implementations§

source§

impl Graph

source

pub fn num_demes(&self) -> usize

The number of Deme instances in the graph.

source

pub fn get_deme_from_name<'name>( &'name self, name: &'name str ) -> Option<&'name Deme>

Obtain a reference to a Deme by its name.

Returns

Some(&Deme) if name exists, None otherwise.

Examples

See here.

source

pub fn deme(&self, at: usize) -> &Deme

Get the Deme at index at.

source

pub fn get_deme(&self, at: usize) -> Option<&Deme>

Get the Deme at index at.

Details

Returns None if at is out of range.

source

pub fn demes(&self) -> &[Deme]

Get the Deme instances via a slice.

source

pub fn generation_time(&self) -> GenerationTime

Get the GenerationTime for the graph.

source

pub fn time_units(&self) -> TimeUnits

Get the TimeUnits for the graph.

source

pub fn migrations(&self) -> &[AsymmetricMigration]

Get the migration events for the graph.

source

pub fn pulses(&self) -> &[Pulse]

Get the pulse events for the graph.

source

pub fn metadata(&self) -> Option<Metadata>

Get a copy of the top-level Metadata.

source

pub fn into_generations(self) -> Result<Self, DemesError>

Convert the time units to generations.

Errors

If the time unit of an event differs sufficiently in magnitude from the generation_time, it is possible that conversion results in epochs (or migration durations) of length zero, which will return an error.

If any field is unresolved, an error will be returned.

source

pub fn into_integer_generations(self) -> Result<Graph, DemesError>

Convert the time units to generations, rounding the output to an integer value.

source

pub fn into_generations_with( self, with: fn(_: Time, _: GenerationTime) -> Time ) -> Result<Graph, DemesError>

Convert the time units to generations with a callback to specify the conversion policy

source

pub fn as_string(&self) -> Result<String, DemesError>

Return a representation of the graph as a string.

The format is in YAML and corresponds to the MDM representation of the data.

Error

Will return an error if serde_yaml::to_string returns an error.

source

pub fn as_json_string(&self) -> Result<String, DemesError>

Available on crate feature json only.

Return a representation of the graph as a string.

The format is in JSON and corresponds to the MDM representation of the data.

Error

Will return an error if serde_json::to_string returns an error.

source

pub fn most_recent_deme_end_time(&self) -> Time

Return the most recent end time of any deme in the Graph.

This function is useful to check if the most recent end time is greater than zero, meaning that the model ends at a time point ancestral to “now”.

source

pub fn description(&self) -> Option<&str>

Return the description field.

source

pub fn doi(&self) -> impl Iterator<Item = &str>

Return an iterator over DOI information.

source

pub fn has_non_integer_sizes(&self) -> Option<(&str, usize)>

Check if any epochs have non-integer start_size or end_size.

Returns
  • The deme name and epoch index where the first non-integer value is encountered
  • None if non non-integer values are encountered
source

pub fn into_integer_start_end_sizes(self) -> Result<Self, DemesError>

Round all epoch start/end sizes to nearest integer value.

Returns

A modified graph with rounded sizes.

Error
Note

Rounding uses f64::round

Trait Implementations§

source§

impl Debug for Graph

source§

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

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

impl Display for Graph

source§

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

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

impl PartialEq<Graph> for Graph

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 Serialize for Graph

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Graph

Auto Trait Implementations§

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnwindSafe for Graph

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToString for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.