protseq = raw_input("Protein sequence: ").upper()
protdeg = {"A":4,"C":2,"D":2,"E":2,"F":2,"G":4,"H":2,
           "I":3,"K":2,"L":6,"M":1,"N":2,"P":4,"Q":2,
           "R":6,"S":6,"T":4,"V":4,"W":1,"Y":2}
segsvalues=[]; segsseqs=[]; segment=protseq[:15]; a=0
while len(segment)==15:
    degen = 0
    for x in segment:
        degen += protdeg.get(x,3.05)
    segsvalues.append(degen)
    segsseqs.append(segment)
    a+=1; segment = protseq[a:a+15]
print segsseqs[segsvalues.index(min(segsvalues))]

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.