def get_summary_object_for_profile_db(self, profile_db_path, init_gene_coverages=True): collection_name = self.descriptions.genomes[ self.unique_profile_db_path_to_internal_genome_name[ profile_db_path][0]]['collection_id'] profile_db_path = self.descriptions.genomes[ self.unique_profile_db_path_to_internal_genome_name[ profile_db_path][0]]['profile_db_path'] contigs_db_path = self.descriptions.genomes[ self.unique_profile_db_path_to_internal_genome_name[ profile_db_path][0]]['contigs_db_path'] # poor-man's whatever bin_names_list = [ self.descriptions.genomes[g]['bin_id'] for g in self. unique_profile_db_path_to_internal_genome_name[profile_db_path] ] ARGS = summarizer.ArgsTemplateForSummarizerClass() ARGS.profile_db = profile_db_path ARGS.contigs_db = contigs_db_path ARGS.skip_init_functions = True ARGS.init_gene_coverages = init_gene_coverages ARGS.collection_name = collection_name ARGS.bin_names_list = bin_names_list ARGS.output_dir = None summary = summarizer.ProfileSummarizer(ARGS) summary.init() summary.init_collection_profile(collection_name) return summary
def gen_summary(args, d, request, response, collection_name): set_default_headers(response) if args.read_only: return json.dumps({'error': "Sorry! This is a read-only instance."}) if d.manual_mode: return json.dumps({ 'error': "Creating summaries is only possible with proper anvi'o runs at the moment :/" }) run.info_single('A summary of collection "%s" has been requested.' % collection_name) # get a dummy args instance, and fill it down below summarizer_args = summarizer.ArgsTemplateForSummarizerClass() # common params. we will set pan/profile specific params a bit later: summarizer_args.collection_name = collection_name summarizer_args.taxonomic_level = d.taxonomic_level if d.mode == 'pan': summarizer_args.pan_db = d.pan_db_path summarizer_args.genomes_storage = d.genomes_storage_path summarizer_args.output_dir = os.path.join( os.path.dirname(summarizer_args.pan_db), 'SUMMARY_%s' % collection_name) elif d.mode == 'full': summarizer_args.profile_db = d.profile_db_path summarizer_args.contigs_db = d.contigs_db_path summarizer_args.output_dir = os.path.join( os.path.dirname(summarizer_args.profile_db), 'SUMMARY_%s' % collection_name) else: return json.dumps({ 'error': 'We do not know anything about this mode: "%s"' % d.mode }) # call the summary: try: summary = summarizer.PanSummarizer( summarizer_args, r=run, p=progress) if d.mode == 'pan' else summarizer.ProfileSummarizer( summarizer_args, r=run, p=progress) summary.process() except Exception as e: return json.dumps({ 'error': 'Something failed in the "%s" summary mode. This is what we know: %s' % (d.mode, e) }) run.info_single('HTML output for summary is ready: %s' % summary.index_html) path = "summary/%s/index.html" % (collection_name) return json.dumps({'path': path})
def init_pan_summary(self): self.progress.new('Pan summary') self.progress.update('Initializing...') args = summarizer.ArgsTemplateForSummarizerClass() args.pan_db = self.pan_db_path args.genomes_storage = self.genomes_storage_path args.skip_check_collection_name = True args.skip_init_functions = True self.pan_summary = summarizer.PanSummarizer(args) self.progress.end()