Python Programs for Beginner Bioinformatics — Part 4

Input: GGACCGTTGAC
GGACCGTTGAC
Output: 3
def HammingDistance(p, q):
return reduce(lambda a, b: a + b, list(map(lambda x, y: int(x != y), list(p), list(q))), 0)
def pattern_count_with_mismatch(text, pattern, mismatch_threshold):
return sum(1 for i in range(len(text) - len(pattern) + 1) if HammingDistance(text[i:i + len(pattern)], pattern) <= mismatch_threshold)

--

--

--

Educator, Founder @ Interleap

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introduction to Python Lists

What can we learn from ENS airdrop?

Tuning linux network stack - with examples - Part 1

Case Study: Rhätische Bahn accelerates service integration with Red Hat OpenShift

Building Frontend Applications By Mocking Your Entire API With Testing Tools

Storyboard no more. Crafting (coding) a custom UIView

Explore FutureBuilder In Flutter

The Essentials of the Basic Structure of a C Program

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhinav

Abhinav

Educator, Founder @ Interleap

More from Medium

Python Code for the Beginner Bioinformatics Course — Part 1

The importance of quran classes

Python Use of Break, Continue, Pass

The way you learn RPA is wrong