July 29, 2015, 12:29 a.m. by Rosalind Team
The first potential issue with implementing MedianString from “Find a Median String” is writing a function to compute d(Pattern, Dna) = ∑ti=1 d(Pattern, Dnai), the sum of distances between Pattern and each string in Dna = {Dna1, ..., Dnat}. This task is achieved by the following pseudocode.
DistanceBetweenPatternAndStrings(Pattern, Dna)
k ← |Pattern|
distance ← 0
for each string Text in Dna
HammingDistance ← ∞
for each k-mer Pattern’ in Text
if HammingDistance > HammingDistance(Pattern, Pattern’)
HammingDistance ← HammingDistance(Pattern, Pattern’)
distance ← distance + HammingDistance
return distance
Find the distance between a pattern and a set of strings.
Given: A DNA string Pattern and a collection of DNA strings Dna.
Return: DistanceBetweenPatternAndStrings(Pattern, Dna).
AAA TTACCTTAAC GATATCTGTC ACGGCGTTCG CCCTAAAGAG CGTCAGAGGT
5