###################################################################### ##### READ IN FASTA FILE AND STORE CONTENTS IN *SEQUENCE* ############ ###################################################################### file = open("hemoglobin.txt") # Read in first line of file and check for FASTA format headerLine = file.readline() if (headerLine[0] == '>'): # First character is '>' print "The file is in FASTA format." else: print "The file is not in FASTA format." # Read in the rest of the file (i.e., the sequence) sequence = file.read() # Remove all carriage returns from the sequence sequence = sequence.replace("\n", "") ###################################################################### ##### PRINT OUT *SEQUENCE* THREE NUCLEOTIDES AT A TIME ############### ###################################################################### # Assuming we have a coding sequence, print out each codon startOfCodon = 0 while (startOfCodon < len(sequence)): codon = sequence[startOfCodon:startOfCodon+3] print codon startOfCodon = startOfCodon + 3