def merge_variable_codons_tables(self): variable_codons_table = TableForCodonFrequencies(self.merged_profile_db_path, progress=self.progress) for input_profile_db_path in self.profile_dbs_info_dict: sample_profile_db = dbops.ProfileDatabase(input_profile_db_path, quiet=True) sample_variable_codons_table = sample_profile_db.db.get_table_as_list_of_tuples(tables.variable_codons_table_name, tables.variable_codons_table_structure) sample_profile_db.disconnect() for tpl in sample_variable_codons_table: entry = tuple([variable_codons_table.next_id(tables.variable_codons_table_name)] + list(tpl[1:])) variable_codons_table.db_entries.append(entry) variable_codons_table.store()
def generate_variabile_codons_table(self): if self.skip_SNV_profiling or not self.profile_SCVs: return variable_codons_table = TableForCodonFrequencies( self.profile_db_path, progress=self.progress) codon_frequencies = bamops.CodonFrequencies() codons_in_genes_to_profile_SCVs_dict = {} for gene_callers_id, codon_order in self.codons_in_genes_to_profile_SCVs: if gene_callers_id not in codons_in_genes_to_profile_SCVs_dict: codons_in_genes_to_profile_SCVs_dict[gene_callers_id] = set([]) codons_in_genes_to_profile_SCVs_dict[gene_callers_id].add( codon_order) gene_caller_ids_to_profile = list( codons_in_genes_to_profile_SCVs_dict.keys()) for i in range(len(gene_caller_ids_to_profile)): gene_callers_id = gene_caller_ids_to_profile[i] codons_to_profile = codons_in_genes_to_profile_SCVs_dict[ gene_callers_id] gene_call = self.genes_in_contigs_dict[gene_callers_id] contig_name = gene_call['contig'] codon_frequencies_dict = codon_frequencies.process_gene_call( self.bam, gene_call, self.contig_sequences[contig_name]['sequence'], codons_to_profile) for codon_order in codon_frequencies_dict: e = codon_frequencies_dict[codon_order] db_entry = { 'sample_id': self.sample_id, 'corresponding_gene_call': gene_callers_id } db_entry['reference'] = e['reference'] db_entry['coverage'] = e['coverage'] db_entry['departure_from_reference'] = e[ 'departure_from_reference'] db_entry['codon_order_in_gene'] = codon_order for codon in list(constants.codon_to_AA.keys()): db_entry[codon] = e['frequencies'][codon] variable_codons_table.append(db_entry) variable_codons_table.store() # clear contents of set self.codons_in_genes_to_profile_SCVs.clear() if len(codon_frequencies.not_reported_items): items = codon_frequencies.not_reported_items self.run.warning( "The profiler of single-codon variants failed to report anything for a\ total of %d items, because they looked weird to anvi'o :( Here is a list\ of those that did ended up being ignored: '%s'." % (len(items), ', '.join(items)))
def generate_variabile_codons_table(self): if self.skip_SNV_profiling or not self.profile_SCVs: return variable_codons_table = TableForCodonFrequencies( self.profile_db_path, progress=null_progress) for contig in self.contigs: for gene_callers_id in contig.codon_frequencies_dict: for codon_order in contig.codon_frequencies_dict[ gene_callers_id]: e = contig.codon_frequencies_dict[gene_callers_id][ codon_order] db_entry = { 'sample_id': self.sample_id, 'corresponding_gene_call': gene_callers_id } db_entry['reference'] = e['reference'] db_entry['coverage'] = e['coverage'] db_entry['departure_from_reference'] = e[ 'departure_from_reference'] db_entry['codon_order_in_gene'] = codon_order for codon in list(constants.codon_to_AA.keys()): db_entry[codon] = e['frequencies'][codon] variable_codons_table.append(db_entry) variable_codons_table.store()
def generate_variabile_codons_table(self): if self.skip_SNV_profiling or not self.profile_SCVs: return variable_codons_table = TableForCodonFrequencies(self.profile_db_path, progress=null_progress) for contig in self.contigs: for gene_callers_id in contig.codon_frequencies_dict: for codon_order in contig.codon_frequencies_dict[gene_callers_id]: e = contig.codon_frequencies_dict[gene_callers_id][codon_order] db_entry = {'sample_id': self.sample_id, 'corresponding_gene_call': gene_callers_id} db_entry['reference'] = e['reference'] db_entry['coverage'] = e['coverage'] db_entry['departure_from_reference'] = e['departure_from_reference'] db_entry['codon_order_in_gene'] = codon_order for codon in list(constants.codon_to_AA.keys()): db_entry[codon] = e['frequencies'][codon] variable_codons_table.append(db_entry) variable_codons_table.store()