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) class Args: pass summarizer_args = Args() summarizer_args.profile_db = d.profile_db_path summarizer_args.contigs_db = d.contigs_db_path summarizer_args.collection_name = collection_name summarizer_args.taxonomic_level = d.taxonomic_level summarizer_args.list_collections = None summarizer_args.debug = None summarizer_args.quick_summary = False summarizer_args.output_dir = os.path.join(os.path.dirname(summarizer_args.profile_db), 'SUMMARY_%s' % collection_name) try: summary = summarizer.PanSummarizer(summarizer_args, r=run, p=progress) summary.process() except Exception as e: return json.dumps({'error': 'Something failed. This is what we know: %s' % 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 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()