###################################################################### ##### READ IN FASTA FILE AND STORE CONTENTS IN *SEQUENCE* ############ ###################################################################### file = open("yeastGenome.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", "") ###################################################################### ##### DETERMINE GC CONTENT OF *SEQUENCE* ############################# ###################################################################### # Calculate GC content of sequence numberOfGuanines = float(sequence.count('G')) numberOfCytosines = float(sequence.count('C')) totalNucleotides = float(len(sequence)) GC_content = (numberOfGuanines + numberOfCytosines) / totalNucleotides print GC_content