# calculate the RSCU value for each of the codons for codon in codons: denominator = float(float(1) / float(len(codons))) * float(total) #denominator = float(total) / len(codons) if self.codon_count[codon] > 0: RCSU_vector.append(self.codon_count[codon] / denominator) else: #TODO: give some kine of warning message that codon count is 0 RCSU_vector.append(0) # print aa, "@", codons, "@",len(codons), "@",total, "@",rcsu print os.path.splitext(os.path.basename(fasta_file))[0] + '\t' + '\t'.join( ['{:.6f}'.format(x) for x in RCSU_vector]) #Add these methods to CAI class CAI.generate_matrix_rcsu = MethodType(generate_matrix_rcsu, CAI) CAI.cutg_generate_matrix_rcsu = MethodType(cutg_generate_matrix_rcsu, CAI) CAI.header_matrix_rcsu = MethodType(header_matrix_rcsu, CAI) # define function that dowloads GenBank files and extracts CDS/gene sequences def extract_gb_ORFs(gi_id): """ Extract feature sequences from genbak file """ handle = Entrez.efetch(db="nuccore", id=gi_id, rettype="gb", retmode="text") #record = SeqIO.parse(handle, "gb")