def compute_codon_occupancy_counts(self): read_positions = self.load_read_positions() buffered_codon_counts = {} codon_counts = {} codon_counts_stringent = {} codon_counts_anisomycin = {} for name, position_counts in read_positions.iteritems(): buffered_counts, identities = positions.compute_codon_counts(position_counts, self.offset_type) buffered_counts_stringent, _ = positions.compute_codon_counts(position_counts, self.offset_type + '_stringent') buffered_counts_anisomycin, _ = positions.compute_codon_counts(position_counts, self.offset_type + '_anisomycin') buffered_codon_counts[name] = {'relaxed': buffered_counts, 'stringent': buffered_counts_stringent, 'anisomycin': buffered_counts_anisomycin, 'identities': identities, } num_codons = buffered_counts.CDS_length # + 1 is to include the stop codon codon_counts[name] = buffered_counts['start_codon', :num_codons + 1] codon_counts_stringent[name] = buffered_counts_stringent['start_codon', :num_codons + 1] codon_counts_anisomycin[name] = buffered_counts_anisomycin['start_codon', :num_codons + 1] self.write_file('buffered_codon_counts', buffered_codon_counts) self.write_file('codon_counts', codon_counts) self.write_file('codon_counts_anisomycin', codon_counts_anisomycin) self.write_file('codon_counts_stringent', codon_counts_stringent)
def get_metagene_positions(self): piece_CDSs, max_gene_length = self.get_CDSs() read_positions = self.load_read_positions() metagene_positions = positions.compute_metagene_positions(piece_CDSs, read_positions, max_gene_length, ) self.write_file('metagene_positions', metagene_positions) three_prime_read_positions = self.load_read_positions(modifier='three_prime') read_positions = self.load_read_positions(modifier='three_prime') processed_read_positions = {} for name, counts in read_positions.iteritems(): gene = {'three_prime_genomic': counts[0], 'three_prime_nongenomic': counts['all'] - counts[0], 'sequence': counts['sequence'], } processed_read_positions[name] = gene three_prime_metagene_positions = positions.compute_metagene_positions(piece_CDSs, processed_read_positions, max_gene_length, ) self.write_file('three_prime_metagene_positions', three_prime_metagene_positions)