Skip to content

Instantly share code, notes, and snippets.

@ivan-krukov
Created June 5, 2013 19:04
Show Gist options
  • Save ivan-krukov/5716306 to your computer and use it in GitHub Desktop.
Save ivan-krukov/5716306 to your computer and use it in GitHub Desktop.
lcsm problem on Rosalind
#!/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