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 = []
for aa in range(len(ProtSeq)):
    segment = ProtSeq[aa:aa+15]
    degen = 0
    if len(segment)==15:
        for x in segment:
            degen += ProtDeg.get(x,3.05)
        SegsValues.append(degen)
    else:
        pass
MinValue = min(SegsValues)
minpos = SegsValues.index(MinValue)
print ProtSeq[minpos:minpos+15]

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