Implement DistanceBetweenPatternAndStrings solved by 1097

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’)
HammingDistanceHammingDistance(Pattern, Pattern’)
distancedistance + HammingDistance
return distance

Compute DistanceBetweenPatternAndStrings

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).

Sample Dataset

AAA
TTACCTTAAC GATATCTGTC ACGGCGTTCG CCCTAAAGAG CGTCAGAGGT

Sample Output

5

Extra Datasets

Please login to solve this problem.