Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def codon_usage(self, options):
"""Codon usage command"""
gene_files = self._input_files(options.nucleotide_gene_files, options.file_ext)
# calculate amino acid usage
codon_usage = CodonUsage(options.cpus, options.keep_ambiguous)
genome_codon_usage, codon_set, _mean_length = codon_usage.run(gene_files)
# write out results
self._write_usage_profile(genome_codon_usage,
codon_set,
options.counts,
options.output_file)
self.logger.info('Codon usage written to: %s' % options.output_file)
def stop_usage(self, options):
"""Stop codon usage command"""
gene_files = self._input_files(options.nucleotide_gene_files, options.file_ext)
# calculate amino acid usage
codon_usage = CodonUsage(options.cpus, keep_ambiguous=False, stop_codon_only=True)
genome_codon_usage, codon_set, mean_gene_length = codon_usage.run(gene_files)
# write out results
if not options.mean_gene_length:
self._write_usage_profile(genome_codon_usage,
codon_set,
options.counts,
options.output_file)
else:
fout = open(options.output_file, 'w')
for codon in codon_set:
fout.write('\t' + codon)
if mean_gene_length:
fout.write('\t' + codon + ': avg. seq. length')
fout.write('\n')