Skip to main content
. Author manuscript; available in PMC: 2022 Apr 21.
Published before final editing as: Stat Appl Genet Mol Biol. 2020 Oct 21:/j/sagmb.ahead-of-print/sagmb-2019-0026/sagmb-2019-0026.xml. doi: 10.1515/sagmb-2019-0026

Algorithm 1. Reconstruction of phylogenetic tree topology for a given transmission tree and infection times.

toPhylo is a recursive function that gets as input the root of a transmission tree. In lines 2-4, the function checks if the current node has no children i.e., a leaf, in this case the corresponding phylogenetic tree is simply a phylogenetic tree with a single node. In line 5, all child nodes of the root are decreasingly sorted according to their infection times in order to place them in the right order for the recursive calls in the subsequent lines (see Figure 2b). The for-loop in the lines 8-12 grows a ladder-like mini-phylogenetic tree from left where the right node at each iteration points to the recursively reconstructed phylogenetic subtree, by calling toPhylo at line 9, on the current transmission subtree.

INPUT:tRoot:the root of the transmission treeOUTPUT:a phylogenetic tree with equal branch lengths1:functionTOPHYLO(tNode)a recursive function2:iftNode.isLeafthen3:returnnew phyloNode(tNode.name)4:endif5:cNodessort(tNode.children)sort decreasingly by infection times6:pNodenew phyloNode()create the root of mini-phylogenetic tree7:nextPNodepNode8:fori1tocNodes.sizedo9:nextPNode.righttoPhylo(cNodes[i])10:nextPNode.leftnew phyloNode()11:nextPNodenextPNode.left12:endfor13:nextPNodenew phyloNode(tNode.name)14:returnpNode15:endfunction16:17:toPhylo(tRoot)FunctiontoPhylowith the inputtRootcreates thecorresponding phylogenetic tree.