How to generate all strings with d-mismatches, python

Posted by mr.M on Stack Overflow See other posts from Stack Overflow or by mr.M
Published on 2013-11-06T21:08:49Z Indexed on 2013/11/06 21:54 UTC
Read the original article Hit count: 226

Filed under:
|

I have a following string - "AACCGGTTT" (alphabet is ["A","G","C","T"]). I would like to generate all strings that differ from the original in any two positions i.e.

GAGCGGTTT
^ ^ 
TATCGGTTT
^ ^

How can I do it in Python?

I have only brute force solution (it is working):

  1. generate all strings on a given alphabet with the same length

  2. append strings that have 2 mismatches with a given string

However, could you suggest more efficient way to do so?

© Stack Overflow or respective owner

Related posts about python

Related posts about bioinformatics