phylopomp
Phylodynamics for POMPs
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse.cc File Reference
#include "genealogy.h"
#include "generics.h"
#include "internal.h"
Include dependency graph for parse.cc:

Go to the source code of this file.

Functions

SEXP parse_newick (SEXP X, SEXP T0, SEXP Tf)
 

Function Documentation

◆ parse_newick()

SEXP parse_newick ( SEXP X,
SEXP T0,
SEXP Tf )

A parser for Newick code. Returns a genealogy in the phylopomp format.

Definition at line 10 of file parse.cc.

10 {
11 PROTECT(X = AS_CHARACTER(X));
12 PROTECT(T0 = AS_NUMERIC(T0));
13 PROTECT(Tf = AS_NUMERIC(Tf));
14 double t0 = *REAL(T0);
15 double tf = *REAL(Tf);
16 // parse the Newick representation into a genealogy:
17 std::string x = CHAR(STRING_ELT(X,0));
18 genealogy_t G(t0);
19 G.parse(x,t0);
20 if (!ISNA(tf)) {
21 G.curtail(tf,t0);
22 }
23 G.trace_lineages();
24 UNPROTECT(3);
25 return serial(G);
26 }
Encodes a genealogy.
Definition genealogy.h:22
SEXP serial(const TYPE &X)
binary serialization
Definition generics.h:28
Here is the call graph for this function: