protseq = raw_input("Enter your protein sequence: ")
protweight = {"A":89,"V":117,"L":131,"I":131,"P":115,"F":165,
              "W":204,"M":149,"G":75,"S":105,"C":121,"T":119,
              "Y":181,"N":132,"Q":146,"D":133,"E":147,
              "K":146,"R":174,"H":155}
totalW = 0
for aa in protseq:
    totalW = totalW + protweight.get(aa.upper(),0)
totalW = totalW-(18*(len(protseq)-1))
print("The net weight is: "+str(totalW))

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