Skip to content

Commit 73b838c

Browse files
authored
Merge pull request #57 from molpopgen/describe_edge_buffering
Describe edge buffering. Closes #54
2 parents fab97d4 + 4e1ae1e commit 73b838c

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/edge_buffer.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,48 @@ use crate::segment::Segment;
55
/// Simplification of simulated data happens
66
/// via [``crate::simplify_from_edge_buffer()``].
77
///
8+
/// # Overview
9+
///
10+
/// The typical tree sequence recording workflow
11+
/// goes like this. When a new node is "born",
12+
/// we:
13+
///
14+
/// 1. Add a new node to the node table. This
15+
/// new node is a "child".
16+
/// 2. Add edges to the edge table representing
17+
/// the genomic intervals passed on from
18+
/// various parents to this child node.
19+
///
20+
/// We repeat `1` and `2` for a while, then
21+
/// we [``sort the tables``](crate::TableCollection::sort_tables_for_simplification).
22+
/// After sorting, we [``simplify``](crate::simplify_tables()) the tables.
23+
///
24+
/// We can avoid the sorting step using this type.
25+
/// To start, we record the list of currently-alive nodes
26+
/// [``here``](crate::SamplesInfo::edge_buffer_founder_nodes).
27+
///
28+
/// Then, we use `parent` ID values as the
29+
/// `head` values for linked lists stored in a
30+
/// [``NestedForwardList``](crate::nested_forward_list::NestedForwardList).
31+
///
32+
/// By its very nature, offspring are generated by birth order.
33+
/// Further, a well-behaved forward simulation is capable of calculating
34+
/// edges from left-to-right along a genome. Thus, we can
35+
/// [``extend``](crate::nested_forward_list::NestedForwardList::extend)
36+
/// the data for each chain with [``Segment``] instances representing
37+
/// transmission events. The segment's [``node``](Segment::node) field represents
38+
/// the child.
39+
///
40+
/// After recording for a while, we call
41+
/// [``simplify_from_edge_buffer``](crate::simplify_from_edge_buffer()) to simplify
42+
/// the tables. After simplification, the client code must re-populate
43+
/// [``the list``](crate::SamplesInfo::edge_buffer_founder_nodes) of alive nodes.
44+
/// Once that is done, we can keep recording, etc..
45+
///
846
/// # Example
947
///
1048
/// For a full example of use in simulation,
1149
/// see the source code for
12-
/// [``crate::wright_fisher::neutral_wf()``].
50+
/// [``wright_fisher::neutral_wf``](crate::wright_fisher::neutral_wf)
51+
///
1352
pub type EdgeBuffer = NestedForwardList<Segment>;

src/simplify_from_edge_buffer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ fn process_births_from_buffer(
147147
///
148148
/// The input tables must be sorted.
149149
/// See [``TableCollection::sort_tables_for_simplification``].
150+
///
151+
/// # Limitations
152+
///
153+
/// The simplification code does not currently validate
154+
/// that "buffered" edges do indeed represent a valid sort order.
150155
pub fn simplify_from_edge_buffer(
151156
samples: &SamplesInfo,
152157
flags: SimplificationFlags,

0 commit comments

Comments
 (0)