def generate_html(region_layer: RegionLayer, results: SactiResults, record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("sactipeptides") motifs_in_region = defaultdict(list) # type: Dict[str, List[CDSMotif]] for locus, motifs in results.motifs_by_locus.items(): for motif in motifs: if motif.is_contained_by(region_layer.region_feature): motifs_in_region[locus].append(motif) sacti_layer = SactipeptideLayer(record_layer, region_layer.region_feature) detail_tooltip = ("Lists the possible core peptides for each biosynthetic enzyme, including the predicted class. " "Each core peptide shows the leader and core peptide sequences, separated by a dash.") template = FileTemplate(path.get_full_path(__file__, "templates", "details.html")) details = template.render(record=record_layer, region=sacti_layer, options=options_layer, results=motifs_in_region, tooltip=detail_tooltip) html.add_detail_section("Sactipeptides", details) side_tooltip = ("Lists the possible core peptides in the region. " "Each core peptide lists its RODEO score and predicted core sequence.") template = FileTemplate(path.get_full_path(__file__, "templates", "sidepanel.html")) sidepanel = template.render(record=record_layer, region=sacti_layer, options=options_layer, results=motifs_in_region, tooltip=side_tooltip) html.add_sidepanel_section("Sactipeptides", sidepanel) return html
def generate_html(region_layer: RegionLayer, results: LanthiResults, _record_layer: RecordLayer, _options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML output for the module """ html = HTMLSections("lanthipeptides") detail_tooltip = ( "Lists the possible core peptides for each biosynthetic enzyme, including the predicted class. " "Each core peptide shows the leader and core peptide sequences, separated by a dash." ) template = FileTemplate( path.get_full_path(__file__, "templates", "details.html")) motifs = results.get_motifs_for_region(region_layer.region_feature) html.add_detail_section( "Lanthipeptides", template.render(results=motifs, tooltip=detail_tooltip)) side_tooltip = ( "Lists the possible core peptides in the region. " "Each core peptide lists the number of lanthionine bridges, possible molecular weights, " "and the scores for cleavage site prediction and RODEO.") template = FileTemplate( path.get_full_path(__file__, "templates", "sidepanel.html")) motifs = results.get_motifs_for_region(region_layer.region_feature) html.add_sidepanel_section( "Lanthipeptides", template.render(results=motifs, tooltip=side_tooltip)) return html
def generate_html(region_layer: RegionLayer, results: SactiResults, record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("sactipeptides") motifs_in_region = defaultdict(list) # type: Dict[str, List[CDSMotif]] for locus, motifs in results.motifs_by_locus.items(): for motif in motifs: if motif.is_contained_by(region_layer.region_feature): motifs_in_region[locus].append(motif) sacti_layer = SactipeptideLayer(record_layer, region_layer.region_feature) template = FileTemplate( path.get_full_path(__file__, "templates", "details.html")) details = template.render(record=record_layer, region=sacti_layer, options=options_layer, results=motifs_in_region) html.add_detail_section("Sactipeptides", details) template = FileTemplate( path.get_full_path(__file__, "templates", "sidepanel.html")) sidepanel = template.render(record=record_layer, region=sacti_layer, options=options_layer, results=motifs_in_region) html.add_sidepanel_section("Sactipeptides", sidepanel) return html
def generate_html(region_layer: RegionLayer, results: ThioResults, record_layer: RecordLayer, options_layer: OptionsLayer ) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("thiopeptides") if not results: return html thio_layer = ThiopeptideLayer(record_layer, results, region_layer.region_feature) detail_tooltip = ("Lists the possible core peptides for each biosynthetic enzyme, including the predicted class. " "Each core peptide shows the leader and core peptide sequences, separated by a dash. " "Predicted tail sequences are also shown.") template = FileTemplate(path.get_full_path(__file__, "templates", "details.html")) details = template.render(record=record_layer, cluster=thio_layer, options=options_layer, tooltip=detail_tooltip) html.add_detail_section("Thiopeptides", details) side_tooltip = ("Lists the possible core peptides in the region. " "Each core peptide lists its possible molecular weights " "and the scores for cleavage site prediction and RODEO. " "If relevant, other features, such as macrocycle and amidation, will also be listed.") template = FileTemplate(path.get_full_path(__file__, "templates", "sidepanel.html")) sidepanel = template.render(record=record_layer, cluster=thio_layer, options=options_layer, tooltip=side_tooltip) html.add_sidepanel_section("Thiopeptides", sidepanel) return html
def generate_html(region_layer: RegionLayer, results: ModuleResults, _record_layer: RecordLayer, _options_layer: OptionsLayer) -> HTMLSections: """ Generates the HTML sections for all sideloaded annotations """ assert isinstance(results, SideloadedResults) template = FileTemplate( path.get_full_path(__file__, "templates", "general.html")) tooltip_content = ( "This annotation was made externally by %r and not by antiSMASH") html = HTMLSections("sideloaded") tools_by_name = {} areas_by_tool_name = defaultdict(list) for area in results.get_areas(): if not region_layer.location.start <= area.start <= region_layer.location.end: continue areas_by_tool_name[area.tool.name].append(area) tools_by_name[area.tool.name] = area.tool for tool_name, areas in areas_by_tool_name.items(): # avoid HTML class names containing spaces html_name = tool_name.replace(" ", "-") html.add_detail_section( tool_name, template.render( tool=tools_by_name[tool_name], areas=areas, tooltip_content=tooltip_content % tool_name, ), html_name) return html
def generate_html(region_layer: RegionLayer, results: ThioResults, record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("thiopeptides") if not results: return html thio_layer = ThiopeptideLayer(record_layer, results, region_layer.region_feature) template = FileTemplate( path.get_full_path(__file__, "templates", "details.html")) details = template.render(record=record_layer, cluster=thio_layer, options=options_layer) html.add_detail_section("Thiopeptides", details) template = FileTemplate( path.get_full_path(__file__, "templates", "sidepanel.html")) sidepanel = template.render(record=record_layer, cluster=thio_layer, options=options_layer) html.add_sidepanel_section("Thiopeptides", sidepanel) return html
def generate_html(region_layer: RegionLayer, _results: ModuleResults, _record_layer: RecordLayer, _options_layer: OptionsLayer ) -> HTMLSections: """ Generate the details section of NRPS/PKS domains in the main HTML output """ template = FileTemplate(path.get_full_path(__file__, 'templates', 'details.html')) section = template.render(has_domain_details=has_domain_details, region=region_layer) html = HTMLSections("nrps_pks") html.add_detail_section("NRPS/PKS domains", section) return html
def generate_html_sections( records: List[RecordLayer], results: Dict[str, Dict[str, module_results.ModuleResults]], options: ConfigType) -> Dict[str, Dict[int, List[HTMLSections]]]: """ Generates a mapping of record->region->HTMLSections for each record, region and module Arguments: records: a list of RecordLayers to pass through to the modules results: a dictionary mapping record name to a dictionary mapping each module name to its results object options: the current antiSMASH config Returns: a dictionary mapping record id to a dictionary mapping region number to a list of HTMLSections, one for each module """ details = {} for record in records: record_details = {} record_result = results[record.id] for region in record.regions: sections = [] for handler in region.handlers: if handler.will_handle(region.products): handler_results = record_result.get(handler.__name__) if handler_results is None: continue sections.append( handler.generate_html(region, handler_results, record, options)) record_details[region.get_region_number()] = sections if any( record.get_pfam_domains_in_cds(cds) for cds in region.cds_children): html = HTMLSections("pfam-domains") template = FileTemplate( path.get_full_path(__file__, "templates", "pfam_domains.html")) tooltip = """Shows Pfam domains found in each gene within the region. Click on each domain for more information about the domain's accession, location, description, and any relevant Gene Ontology. Domains with a bold border have Gene Ontology information. """ section = template.render(region=region, record=record, tooltip=tooltip) html.add_detail_section("Pfam domains", section, "pfam-details") sections.append(html) details[record.id] = record_details return details
def generate_html(region_layer: RegionLayer, results: ClusterCompareResults, record_layer: RecordLayer, _options_layer: OptionsLayer) -> HTMLSections: """ Generates the HTML sections for all variants """ html = HTMLSections("cluster-compare") base_tooltip = ( "Shows careas that are similar to the current region to a reference database.<br>" "Mouseover a score cell in the table to get a breakdown of how " "the score was calculated.") for label, db_results in results.by_database.items(): tooltip = base_tooltip if db_results.description: tooltip += f"{db_results.description}<br>" if db_results.url: tooltip += f"<br>Click on an accession to open that entry in the {db_results.name} database." variant_results = db_results.by_region.get( region_layer.get_region_number(), {}) divs: List[Tuple[str, str, Markup]] = [] for variant, result in sorted(variant_results.items()): scores = result.scores_by_region[:DISPLAY_LIMIT] scores_by_proto = result.details.details tag = variant.replace(" ", "-") search_type = "row" kind = "Protocluster to Region" if "ProtoToProto" in variant: kind = "Protocluster to Protocluster" search_type = "matrix" elif "RegionToRegion" in variant: kind = "Region to Region" search_type = "single" assert isinstance(scores_by_proto, list) scores_by_proto = scores_by_proto[:DISPLAY_LIMIT] div = generate_div(tag, region_layer, record_layer, search_type, tooltip, scores, scores_by_proto, len(divs) == 0, label, db_results.url) divs.append((tag, kind, div)) template = FileTemplate( path.get_full_path(__file__, "templates", "gathered.html")) markup = template.render(variants=divs, class_name=label, description="Similar gene clusters", tooltip=tooltip, anchor=region_layer.anchor_id) html.add_detail_section(f"{label} comparison", markup, label + "-cluster-compare") return html
def generate_html(region_layer: RegionLayer, results: LanthiResults, _record_layer: RecordLayer, _options_layer: OptionsLayer ) -> HTMLSections: """ Generates HTML output for the module """ html = HTMLSections("lanthipeptides") template = FileTemplate(path.get_full_path(__file__, "templates", "details.html")) motifs = results.get_motifs_for_region(region_layer.region_feature) html.add_detail_section("Lanthipeptides", template.render(results=motifs)) template = FileTemplate(path.get_full_path(__file__, "templates", "sidepanel.html")) motifs = results.get_motifs_for_region(region_layer.region_feature) html.add_sidepanel_section("Lanthipeptides", template.render(results=motifs)) return html
def generate_html(region_layer: RegionLayer, _results: ModuleResults, _record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generate the details section of NRPS/PKS domains in the main HTML output """ template = FileTemplate( path.get_full_path(__file__, 'templates', 'details.html')) html = HTMLSections("nrps_pks") if not has_domain_details(region_layer): return html # hide lids by default if none have predictions (e.g. in a minimal run) hide_lids = not domains_have_predictions(region_layer) section = template.render(has_domain_details=has_domain_details, region=region_layer, docs_url=options_layer.urls.docs_baseurl, hide_lids=hide_lids) html.add_detail_section("NRPS/PKS domains", section) return html
def generate_html(region_layer: RegionLayer, _results: ClusterBlastResults, record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generates the HTML sections for all variants of clusterblast """ html = HTMLSections("clusterblast") region = region_layer.region_feature base_tooltip = ( "Shows %s that are similar to the current region. Genes marked with the " "same colour are interrelated. White genes have no relationship.<br>" "Click on reference genes to show details of similarities to " "genes within the current region.") if options_layer.cb_general or region.clusterblast is not None: tooltip = base_tooltip % "clusters from the antiSMASH database and other clusters of interest" tooltip += "<br>Click on an accession to open that entry in the antiSMASH database (if applicable)." div = generate_div(region_layer, record_layer, options_layer, "clusterblast", tooltip) html.add_detail_section("ClusterBlast", div, "clusterblast") if options_layer.cb_knownclusters or region.knownclusterblast is not None: tooltip = base_tooltip % "clusters from the MiBIG database" tooltip += "<br>Click on an accession to open that entry in the MiBIG database." div = generate_div(region_layer, record_layer, options_layer, "knownclusterblast", tooltip) html.add_detail_section("KnownClusterBlast", div, "knownclusterblast") if options_layer.cb_subclusters or region.subclusterblast is not None: tooltip = base_tooltip % "sub-cluster units" div = generate_div(region_layer, record_layer, options_layer, "subclusterblast", tooltip) html.add_detail_section("SubClusterBlast", div, "subclusterblast") return html
def generate_html(region_layer: RegionLayer, results: LassoResults, record_layer: RecordLayer, _options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("lassopeptides") motifs_in_region = {} for locus in results.motifs_by_locus: if record_layer.get_cds_by_name(locus).is_contained_by(region_layer.region_feature): motifs_in_region[locus] = results.motifs_by_locus[locus] detail_tooltip = ("Lists the possible core peptides for each biosynthetic enzyme, including the predicted class. " "Each core peptide shows the leader and core peptide sequences, separated by a dash.") template = FileTemplate(path.get_full_path(__file__, "templates", "details.html")) html.add_detail_section("Lasso peptides", template.render(results=motifs_in_region, tooltip=detail_tooltip)) side_tooltip = ("Lists the possible core peptides in the region. " "Each core peptide lists the number of disulfide bridges, possible molecular weights, " "and the scores for cleavage site prediction and RODEO.") template = FileTemplate(path.get_full_path(__file__, "templates", "sidepanel.html")) html.add_sidepanel_section("Lasso peptides", template.render(results=motifs_in_region, tooltip=side_tooltip)) return html
def generate_html(region_layer: RegionLayer, results: LassoResults, record_layer: RecordLayer, _options_layer: OptionsLayer) -> HTMLSections: """ Generates HTML for the module """ html = HTMLSections("lassopeptides") motifs_in_region = {} for locus in results.motifs_by_locus: if record_layer.get_cds_by_name(locus).is_contained_by( region_layer.region_feature): motifs_in_region[locus] = results.motifs_by_locus[locus] template = FileTemplate( path.get_full_path(__file__, "templates", "details.html")) html.add_detail_section("Lasso peptides", template.render(results=motifs_in_region)) template = FileTemplate( path.get_full_path(__file__, "templates", "sidepanel.html")) html.add_sidepanel_section("Lasso peptides", template.render(results=motifs_in_region)) return html
def generate_html(region_layer: RegionLayer, _results: ClusterBlastResults, record_layer: RecordLayer, options_layer: OptionsLayer) -> HTMLSections: """ Generates the HTML sections for all variants of clusterblast """ html = HTMLSections("clusterblast") region = region_layer.region_feature if options_layer.cb_general or region.clusterblast is not None: div = generate_div(region_layer, record_layer, options_layer, "clusterblast") html.add_detail_section("ClusterBlast", div, "clusterblast") if options_layer.cb_knownclusters or region.knownclusterblast is not None: div = generate_div(region_layer, record_layer, options_layer, "knownclusterblast") html.add_detail_section("KnownClusterBlast", div, "knownclusterblast") if options_layer.cb_subclusters or region.subclusterblast is not None: div = generate_div(region_layer, record_layer, options_layer, "subclusterblast") html.add_detail_section("SubClusterBlast", div, "subclusterblast") return html