from Bio import SeqIO # highly or mildly hydrophobic or hydrophilic residues mildphob=['A','M','C','F'] highphob=['L','V','I'] mildphil=['G','S','T','W','P','Y'] highphil=['D','E','H','K','N','Q','R'] def hphob(aa): # return a score for a given amino acid based on its hydrophobicity score = 0 # this is the default, in case you can't find the amino acid if aa in mildphob: # True if aa matches any member of the list mildphob score = 2 elif aa in highphob: score = 4 elif aa in mildphil: score = -1 elif aa in highphil: score = -4 return score # score a sliding window of length L for hydrophobicity # def evalseq(seqname, inputseq, winlen): # your code goes here L = 21 # window size for seq_record in SeqIO.parse("tmcombined.fasta", "fasta"): name=seq_record.id result=evalseq(name,seq_record.seq,L) # return list: [bestscore, position] score=result[0] pos=result[1] print "%s: \t\tmax is %d at position %d" % (name, score, pos)