# find_substitution.py # Author: Sami Khuri # Last updated: December 28, 2017 # Purpose: To locate the positions where 2 similar sequences differ # Program uses the functions len() and min() and user defined function # substitution() to form a list of indices at which the 2 seqs differ # def substitution(a, b): """ Creates a list of indices for which the values in seqs a and b differ """ x1 = len(a) x2 = len(b) z = [ ] end = min(x1, x2) for p in range(0, end): if a[p] != b[p]: z = z + [p] return z # main program handle_Protein_wildtype = open("Protein_wildtype.txt","r") seq_wildtype = handle_Protein_wildtype.read() seq_wildtype = seq_wildtype.replace(" ","") seq_wildtype = seq_wildtype.lower() handle_Protein_mutant = open("Protein_mutant.txt","r") seq_mutant = handle_Protein_mutant.read() seq_mutant = seq_mutant.replace(" ","") seq_mutant = seq_mutant.lower() my_list = substitution(seq_wildtype,seq_mutant) # Output findings in tabular fashion (not zero-based) print("Postion" + "\tFirst" + "\tSecond") print("-------" + "\t-----" + "\t------") for pos in my_list: print(str(pos+1) + "\t" + seq_wildtype[pos] + "\t" + seq_mutant[pos])