def get_description(record: Record, feature: CDSFeature, type_: str, options: ConfigType, mibig_result: List[clusterblast.results.MibigEntry]) -> str: "Get the description text of a CDS feature" urls = { "blastp": ("http://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE=Proteins&" "PROGRAM=blastp&BLAST_PROGRAMS=blastp&QUERY=%s&" "LINK_LOC=protein&PAGE_TYPE=BlastSearch") % feature.translation, "mibig": "", "transport": "", "smcog_tree": "" } genomic_context_url = "http://www.ncbi.nlm.nih.gov/projects/sviewer/?" \ "Db=gene&DbFrom=protein&Cmd=Link&noslider=1&"\ "id=%s&from=%s&to=%s" if mibig_result: assert feature.region region_number = feature.region.get_region_number() mibig_homology_file = os.path.join(options.output_dir, "knownclusterblast", "region%d" % region_number, feature.get_accession() + '_mibig_hits.html') generate_html_table(mibig_homology_file, mibig_result) urls["mibig"] = mibig_homology_file[len(options.output_dir) + 1:] if type_ == 'transport': urls["transport"] = ("http://blast.jcvi.org/er-blast/index.cgi?project=transporter;" "program=blastp;database=pub/transporter.pep;" "sequence=sequence%%0A%s") % feature.translation urls["context"] = genomic_context_url % (record.id, max(feature.location.start - 9999, 0), min(feature.location.end + 10000, len(record))) if options.smcog_trees: for note in feature.notes: # TODO find a better way to store image urls if note.startswith('smCOG tree PNG image:'): urls["smcog_tree"] = note.split(':')[-1] break asf_notes = generate_asf_tooltip_section(record, feature) go_notes = generate_pfam2go_tooltip(record, feature) pfam_notes = generate_pfam_tooltip(record, feature) tigr_notes = generate_tigr_tooltip(record, feature) urls["searchgtr"] = searchgtr_links.get("{}_{}".format(record.id, feature.get_name()), "") template = html_renderer.FileTemplate(path.get_full_path(__file__, "templates", "cds_detail.html")) ec_numbers = "" ec_number_qual = feature.get_qualifier("EC_number") if isinstance(ec_number_qual, list): ec_numbers = ",".join(ec_number_qual) return template.render(feature=feature, ec_numbers=ec_numbers, go_notes=go_notes, asf_notes=asf_notes, pfam_notes=pfam_notes, tigr_notes=tigr_notes, record=record, urls=urls)
def get_description( record: Record, feature: CDSFeature, type_: str, options: ConfigType, mibig_result: List[clusterblast.results.MibigEntry]) -> str: "Get the description text of a CDS feature" blastp_url = "http://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE=Proteins&" \ "PROGRAM=blastp&BLAST_PROGRAMS=blastp&QUERY=%s&" \ "LINK_LOC=protein&PAGE_TYPE=BlastSearch" % feature.translation genomic_context_url = "http://www.ncbi.nlm.nih.gov/projects/sviewer/?" \ "Db=gene&DbFrom=protein&Cmd=Link&noslider=1&"\ "id=%s&from=%s&to=%s" template = '<span class="svgene-tooltip-bold">%s</span><br>\n' % feature.product or feature.get_name( ) template += 'Locus-tag: %s; Protein-ID: %s<br>\n' % (feature.locus_tag, feature.protein_id) if feature.get_qualifier('EC_number'): template += "EC-number(s): %s<br>\n" % ",".join( feature.get_qualifier('EC_number')) for gene_function in feature.gene_functions: template += "%s<br>\n" % str(gene_function) template += "Location: %d - %d<br><br>\n" % ( feature.location.start + 1, # 1-indexed feature.location.end) if mibig_result: cluster_number = feature.cluster.get_cluster_number() mibig_homology_file = os.path.join( options.output_dir, "knownclusterblast", "cluster%d" % cluster_number, feature.get_accession() + '_mibig_hits.html') generate_html_table(mibig_homology_file, mibig_result) mibig_path = mibig_homology_file[len(options.output_dir) + 1:] template += '<br><a href="%s" target="_new">MiBIG Hits</a><br>\n' % mibig_path if type_ == 'transport': url = "http://blast.jcvi.org/er-blast/index.cgi?project=transporter;" \ "program=blastp;database=pub/transporter.pep;" \ "sequence=sequence%%0A%s" % feature.translation template += '<a href="%s" target="_new">TransportDB BLAST on this gene<br>' % url key = record.id + "_" + feature.get_name() if key in searchgtr_links: url = searchgtr_links[key] template += '<a href="%s" target="_new">SEARCHGTr on this gene<br>\n' % url template += '<a href="%s" target="_new">NCBI BlastP on this gene</a><br>\n' % blastp_url context = genomic_context_url % ( record.id, max(feature.location.start - 9999, 0), min(feature.location.end + 10000, len(record))) template += """<a href="%s" target="_new">View genomic context</a><br>\n""" % context if options.smcogs_trees: for note in feature.notes: # TODO find a better way to store image urls if note.startswith('smCOG tree PNG image:'): url = note.split(':')[-1] entry = '<a href="%s" target="_new">View smCOG seed phylogenetic tree with this gene</a>\n' template += entry % url break template += generate_asf_tooltip_section(record, feature) go_notes = generate_pfam2go_tooltip(record, feature) if go_notes: template += '<br><span class="bold">Gene Ontology terms for PFAM domains:</span><br>\n' \ '%s<br><br>\n' % "<br>".join(go_notes) clipboard_fragment = """<a href="javascript:copyToClipboard('%s')">Copy to clipboard</a>""" template += "AA sequence: %s<br>\n" % (clipboard_fragment % feature.translation) template += "Nucleotide sequence: %s<br>\n" % (clipboard_fragment % feature.extract(record.seq)) return "".join(char for char in template if char in string.printable)