//http://rosalind.info/problems/mend/ public InferringGenotypeFromAPedigree() { var tree = new NewickTree(File.ReadAllLines(@"C:\code\dataset.txt")[0]); for (int i = tree.Nodes.Count - 1; i > 0; i--) { TrieNode node = tree.Nodes[i]; TrieNode parent = tree.Nodes[node.ParentValue]; if (string.IsNullOrEmpty(parent.Name)) { parent.Name = node.Name; } else { parent.Name = Combined(parent.Name, node.Name); } } List <double> stuff = tree.Nodes[0].Name.Split(' ').Select(s => Convert.ToDouble(s)).ToList(); double aa = stuff[2]; double Aa = stuff[1]; double AA = stuff[0]; double count = aa + Aa + AA; Console.Write(AA / count + " " + Aa / count + " " + aa / count); }
//http://rosalind.info/problems/ctbl/ public CreatingACharacterTable() { var tree = new NewickTree(File.ReadAllLines(@"C:\code\dataset.txt")[0]); var lexList = new List <string>(tree.Nodes.Where(n => n.HasName).Select(n => n.Name)); lexList.Sort(); CharacterTable.WriteCharacterTable(tree.Nodes, lexList); }