import sys # Parse the command line. if (len(sys.argv) != 2): print "USAGE: do-tryptic-digest.py " sys.exit(1) # Initialize the list of peptides. myPeptides = {} # Open the file and read it line by line. myFile = open(sys.argv[1], "r") for protein in myFile: protein = protein.rstrip() # Traverse the protein. peptideStart = 0 for proteinIndex in range(0, len(protein)): # The final peptide is always tryptic. if (proteinIndex == len(protein) - 1): myPeptide = protein[peptideStart:proteinIndex + 1] myPeptides[myPeptide] = 1 else: thisAmino = protein[proteinIndex] nextAmino = protein[proteinIndex + 1] # Check for a tryptic cleavage location. if (((thisAmino == "K") or (thisAmino == "R")) and (nextAmino != "P")): myPeptide = protein[peptideStart:proteinIndex + 1] myPeptides[myPeptide] = 1 peptideStart = proteinIndex + 1 myFile.close() # Print all the peptides. for peptide in myPeptides.keys(): print peptide