July 2, 2012, midnight by Rosalind Team

**Topics**:
String Algorithms

## Finding a Most Likely Common Ancestor

In “Counting Point Mutations”, we calculated the minimum number of symbol mismatches between two strings of equal length to model the problem of finding the minimum number of point mutations occurring on the evolutionary path between two homologous strands of DNA. If we instead have several homologous strands that we wish to analyze simultaneously, then the natural problem is to find an average-case strand to represent the most likely common ancestor of the given strands.

A matrix is a rectangular table of values divided into rows and columns. An

Say that we have a collection of DNA strings, all having the same length

A consensus string

A T C C A G C T | |

G G G C A A C T | |

A T G G A T C T | |

DNA Strings | A A G C A A C C |

T T G G A A C T | |

A T G C C A T T | |

A T G G C A C T | |

A 5 1 0 0 5 5 0 0 | |

Profile | C 0 0 1 4 2 0 6 1 |

G 1 1 6 3 0 1 0 0 | |

T 1 5 0 0 0 1 1 6 | |

Consensus | A T G C A A C T |

Given: A collection of at most 10 DNA strings of equal length (at most 1 kbp) in FASTA format.

Return: A consensus string and profile matrix for the collection. (If several possible consensus strings exist, then you may return any one of them.)

>Rosalind_1 ATCCAGCT >Rosalind_2 GGGCAACT >Rosalind_3 ATGGATCT >Rosalind_4 AAGCAACC >Rosalind_5 TTGGAACT >Rosalind_6 ATGCCATT >Rosalind_7 ATGGCACT

ATGCAACT A: 5 1 0 0 5 5 0 0 C: 0 0 1 4 2 0 6 1 G: 1 1 6 3 0 1 0 0 T: 1 5 0 0 0 1 1 6