Problem
Figure 1. The rooted binary tree whose Newick format is (aa,((Aa,AA),AA)). Each leaf encodes the genotype of an ancestor for the given individual, which is represented by '?'.
图1 。根树状二叉树,其Newick格式为(aa,(((Aa,AA),AA))。每个叶子编码给定个体的祖先的基因型,用“?”表示。
A rooted binary tree can be used to model the pedigree of an individual. In this case, rather than time progressing from the root to the leaves, the tree is viewed upside down with time progressing from an individual's ancestors (at the leaves) to the individual (at the root).
An example of a pedigree for a single factor in which only the genotypes of ancestors are given is shown in Figure 1.
Given: A rooted binary tree in Newick format encoding an individual's pedigree for a Mendelian factor whose alleles are A (dominant) and a (recessive).
Return: Three numbers between 0 and 1, corresponding to the respective probabilities that the individual at the root of will exhibit the "AA", "Aa" and "aa" genotypes.
有根的二叉树可用于对个人的谱系进行建模。在这种情况下,不是将时间从根部转移到叶子,而是将树倒置查看,而时间却从一个个体的祖先(在叶子)发展到一个个体(在根部)。
图1显示了一个单一因子的谱系实例,其中仅给出了祖先的基因型 。
给定:纽克(Newick)格式的有根二叉树,编码一个人的血统,用于其等位基因为A(显性)和A(隐性)的孟德尔因子。
返回值: 0到1之间的三个数字,分别对应于根源个人显示“ AA”,“ Aa”和“ aa”基因型的概率。
Sample Dataset
((((Aa,aa),(Aa,Aa)),((aa,aa),(aa,AA))),Aa);
Sample Output
0.156 0.5 0.344