Skip to content
Permalink
6d5cc671f5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
36 lines (28 sloc) 665 Bytes
#!/usr/bin/python
from collections import OrderedDict
value,key="",""
s=OrderedDict({})
with open("rosalind_long.txt","rU") as f:
for x in f:
if x[0]!=">":
value=value+x.strip()
else:
if key!="": s[key]=value
key=x[1:].strip()
value=""
s[key]=value
strs=s.values()
while len(strs)>1:
h=strs.pop()
print len(h)
k=h[0:400]
for i,x in enumerate(strs):
j=x.find(k)
if j>=0:
if len(h)+j>len(x):
strs[i]=x[0:j]+h
strs.insert(0,strs.pop(i))
break
else:
strs.insert(0,h)
print strs[0]