Created
June 5, 2013 19:04
-
-
Save ivan-krukov/5716306 to your computer and use it in GitHub Desktop.
lcsm problem on Rosalind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import fastaparse | |
import sys | |
sequences = [i.seq for i in fastaparse.parse_fasta(sys.argv[1])] | |
def substrings(string): | |
n = len(string) | |
for length in range(n,0,-1): | |
for offset in range(n-length): | |
yield(string[offset:offset+length]) | |
first = sequences.pop() | |
sub = substrings(first) | |
for motif in sub: | |
if all((motif in seq for seq in sequences)): | |
break | |
print(motif) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment