app.newick

Parses Newick-format phylogenetic tree strings into nested ClojureScript maps.

Newick format represents trees using nested parentheses with optional branch names and lengths. For example: (A:0.1,B:0.2)Root:0.3;

The main entry point is newick->map, which returns a recursive map of {:name :branch-length :children}.

map->newick

(map->newick node)

Converts a tree map back into a Newick-format string.

This is the inverse of newick->map. Takes a recursive map with keys :name, :branch-length, and :children and produces a standard Newick string terminated by a semicolon.

Example:

(map->newick {:name “Root” :branch-length 0.3 :children [{:name “A” :branch-length 0.1 :children []} {:name “B” :branch-length 0.2 :children []}]}) ;;=> “(A:0.1,B:0.2)Root:0.3;”

newick->map

(newick->map s)

Parses a Newick-format string into a nested tree map.

Input should be a standard Newick string, optionally terminated by a semicolon. For example:

“(A:0.1,(B:0.2,C:0.3):0.4)Root:0.5;”

Returns a recursive map with keys: - :name - node label (string or nil) - :branch-length - distance to parent (number or nil if missing/unparseable) - :children - vector of child node maps (empty for leaves)