phylopomp
Phylodynamics for POMPs
Loading...
Searching...
No Matches
yaml.cc
Go to the documentation of this file.
1// YAML output
2
3#include "ball.h"
4#include "pocket.h"
5#include "node.h"
6#include "nodeseq.h"
7#include "genealogy.h"
8#include "internal.h"
9
10string_t
12(string_t tab) const
13{
14 string_t o;
15 o = "color: " + color_name() + "\n"
16 + tab + "name: " + std::to_string(uniq) + "\n";
17 if (color==black) {
18 o += tab + "deme: " + std::to_string(deme()) + "\n";
19 }
20 return o;
21}
22
23string_t
25(string_t tab) const
26{
27 string_t o = "";
28 string_t t = tab + " ";
29 for (ball_t *b : *this) {
30 o += tab + "- " + b->yaml(t);
31 }
32 return o;
33}
34
35string_t
37(string_t tab) const
38{
39 string_t t = tab + " ";
40 string_t o = "name: " + std::to_string(uniq) + "\n"
41 + tab + "time: " + std::to_string(slate) + "\n"
42 + tab + "deme: " + std::to_string(deme()) + "\n";
43 if (lineage() != null_lineage) {
44 o += tab + "lineage: " + std::to_string(lineage()) + "\n";
45 }
46 o += tab + "pocket:\n" + pocket_t::yaml(tab);
47 return o;
48}
49
50string_t
52(string_t tab) const
53{
54 string_t o = "";
55 string_t t = tab + " ";
56 for (node_t *p : *this) {
57 o += tab + "- " + p->yaml(t);
58 }
59 return o;
60}
61
62string_t
64(string_t tab) const
65{
66 string_t o;
67 string_t t = tab + " ";
68 o = tab + "t0: " + std::to_string(timezero()) + "\n"
69 + tab + "time: " + std::to_string(time()) + "\n"
70 + tab + "ndeme: " + std::to_string(ndeme()) + "\n"
71 + tab + "nodes:\n" + nodeseq_t::yaml(tab);
72 return o;
73}
74
75extern "C" {
76
78 SEXP yaml (SEXP State) {
79 genealogy_t A = State;
80 return mkString(A.yaml().c_str());
81 }
82
83}
@ black
Definition ball.h:12
Balls function as pointers.
Definition ball.h:27
name_t deme(void) const
view deme
Definition ball.h:84
name_t uniq
Definition ball.h:35
string_t color_name(void) const
human-readable colors
Definition ball.h:119
string_t yaml(string_t tab="") const
human/machine-readable info
Definition yaml.cc:12
color_t color
Definition ball.h:36
Encodes a genealogy.
Definition genealogy.h:19
string_t yaml(string_t tab="") const
human/machine-readable info
Definition yaml.cc:64
size_t ndeme(void) const
number of demes
Definition genealogy.h:59
slate_t & timezero(void)
view/set zero time.
Definition genealogy.h:153
slate_t & time(void)
view/set current time.
Definition genealogy.h:145
Encodes a genealogical node.
Definition node.h:21
string_t yaml(string_t tab="") const
human/machine-readable info
Definition yaml.cc:37
name_t lineage(void) const
view lineage
Definition node.h:104
name_t deme(void) const
view deme
Definition node.h:96
name_t uniq
Definition node.h:32
slate_t slate
Definition node.h:33
string_t yaml(string_t tab="") const
human/machine-readable info
Definition yaml.cc:52
string_t yaml(string_t tab="") const
human/machine-readable info
Definition yaml.cc:25
static const name_t null_lineage
Definition node.h:11
SEXP yaml(SEXP State)
extract a YAML description
Definition yaml.cc:78