Smartview (web graphics)¶
Server¶
Keep the data of trees and present a REST api to talk to the world.
- REST call examples:
GET /trees Get all trees GET /trees/{id} Get the tree information identified by “id” POST /trees Create a new tree PUT /trees/{id} Update the tree information identified by “id” DELETE /trees/{id} Delete tree by “id”
- class TreeData(tree: ete4.core.tree.Tree = None, name: str = None, style: ete4.smartview.renderer.treestyle.TreeStyle = None, nodestyles: dict = None, include_props: list = None, exclude_props: list = None, layouts: list = None, timer: float = None, ultrametric: bool = False, initialized: bool = False, selected: dict = None, active: <function namedtuple at 0x7f8510f236a0> = None, searches: dict = None)[source]¶
- __init__(tree: Tree = None, name: str = None, style: TreeStyle = None, nodestyles: dict = None, include_props: list = None, exclude_props: list = None, layouts: list = None, timer: float = None, ultrametric: bool = False, initialized: bool = False, selected: dict = None, active: namedtuple = None, searches: dict = None) None ¶
- active: namedtuple = None¶
- exclude_props: list = None¶
- include_props: list = None¶
- initialized: bool = False¶
- layouts: list = None¶
- name: str = None¶
- nodestyles: dict = None¶
- searches: dict = None¶
- selected: dict = None¶
- timer: float = None¶
- ultrametric: bool = False¶
- get_command_search(text)[source]¶
Return the appropriate node search function according to the command
- get_eval_search(expression)[source]¶
Return a function of a node that evaluates the given expression
- get_next_available_port(host='localhost', port_min=5000, port_max=6000)[source]¶
Return the next available port where we can put a server socket.
- get_search_function(text)[source]¶
Return a function of a node that returns True for the searched nodes
- get_topological_search(pattern)[source]¶
Return a function of a node that sees if it matches the given pattern
- get_trees_from_file(filename, fileobject=None)[source]¶
Return list of {‘name’: …, ‘newick’: …} extracted from file.
- get_trees_from_nexus_or_newick(btext, name_newick)[source]¶
Return list of {‘name’: …, ‘newick’: …} extracted from btext.
- initialize(tree=None, layouts=None, include_props=None, exclude_props=None, safe_mode=False, compress=False)[source]¶
Initialize the global object app.
- maintenance(app, check_interval=60, max_time=1800)[source]¶
Perform maintenance tasks every check_interval seconds.
- retrieve_tree_data(tid)[source]¶
Retrieve and return tree data from file.
It retrieves all that from a previously saved pickle file in /tmp.
- run_smartview(tree=None, name=None, layouts=[], include_props=None, exclude_props=None, safe_mode=False, host='localhost', port=None, quiet=True, compress=False, keep_server=False, open_browser=True)[source]¶
- sort(tree_id, node_id, key_text, reverse)[source]¶
Sort the (sub)tree corresponding to tree_id and node_id
- store_search(tree_id, args)[source]¶
Store the results and parents of a search and return their numbers
- store_selection(tree_id, args)[source]¶
Store the results and parents of a selection and return their numbers
Renderer¶
Drawer¶
Classes and functions for drawing a tree.
- class Drawer(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
Base class (needs subclassing with extra functions to draw)
- COLLAPSE_SIZE = 6¶
- MIN_SIZE = 1¶
- NPANELS = 1¶
- TYPE = 'base'¶
- __init__(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- draw_collapsed(collapsed_node, active_children=(0, 0), selected_children=[])[source]¶
Yield graphic elements to draw the list of nodes in self.collapsed
- draw_content(node, point, active_children=(0, 0), selected_children=[])[source]¶
Yield the node content’s graphic elements
- draw_node(node, point, bdx, bdy, bdy0, bdy1, active_children=(0, 0), selected_children=[])[source]¶
Yield graphic elements to draw the contents of the node
- flush_outline(minimum_dx=0)[source]¶
Return box outlining the collapsed nodes and reset the current outline
- get_collapsed_node()[source]¶
Get node that will be rendered as a collapsed node. Either the only node collapsed or the parent of all collapsed nodes.
- is_fully_collapsed(collapsed_node)[source]¶
Returns true if collapsed_node is utterly collapsed, i.e. has no branch width
- class DrawerAlignCircFaces(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- NPANELS = 2¶
- class DrawerAlignRectFaces(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- NPANELS = 4¶
- class DrawerCirc(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
Minimal functional drawer for a circular representation
- TYPE = 'circ'¶
- __init__(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- draw_childrenline(p1, p2, style)[source]¶
Yield an arc spanning children that starts at p1 and ends at p2
- class DrawerCircFaces(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- class DrawerRect(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
Minimal functional drawer for a rectangular representation
- TYPE = 'rect'¶
- draw_childrenline(p1, p2, style)[source]¶
Yield a line spanning children that starts at p1 and ends at p2
- draw_collapsed(collapsed_node, active_children=(0, 0), selected_children=[])[source]¶
Yield graphic elements to draw the list of nodes in self.collapsed
- class DrawerRectFaces(tree, viewport=None, panel=0, zoom=(1, 1), limits=None, collapsed_ids=None, active=None, selected=None, searches=None, layouts=None, tree_style=None, include_props=None, exclude_props=None)[source]¶
- drawn_size(elements, get_box, min_x=None)[source]¶
Return the size of a box containing all the elements
- get_asec(element, zoom=(0, 0))[source]¶
Return the annular sector that contains the given graphic element
Draw helpers¶
- class Box(x, y, dx, dy)¶
- dx¶
Alias for field number 2
- dy¶
Alias for field number 3
- x¶
Alias for field number 0
- y¶
Alias for field number 1
- draw_arrow(box, tip, orientation='right', arrow_type='', style=None, tooltip=None)[source]¶
Create arrow provided a bounding box
- draw_rhombus(box, rhombus_type='', style=None, tooltip=None)[source]¶
Create rhombus provided a bounding box
- draw_triangle(box, tip, triangle_type='', style=None, tooltip=None)[source]¶
Returns array with all the information needed to draw a triangle in front end. :box: bounds triangle :tip: defines tip orientation ‘top’, ‘left’ or ‘right’. :triangle_type: will label triangle in front end (class)
- first_value(tree, prop)[source]¶
Return the value of the requested property for the first node that has it
- intersects_angles(rect, asec)[source]¶
Return True if any part of rect is contained within the angles of the asec
Faces¶
- class AlignLinkFace(stroke_color='gray', stroke_width=0.5, line_type=1, opacity=0.8)[source]¶
- __init__(stroke_color='gray', stroke_width=0.5, line_type=1, opacity=0.8)[source]¶
Line types: 0 solid, 1 dotted, 2 dashed
- class AlignmentFace(seq, seqtype='aa', gap_format='line', seq_format='[]', width=None, height=None, fgcolor='black', bgcolor='#bcc3d0', gapcolor='gray', gap_linewidth=0.2, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- __init__(seq, seqtype='aa', gap_format='line', seq_format='[]', width=None, height=None, fgcolor='black', bgcolor='#bcc3d0', gapcolor='gray', gap_linewidth=0.2, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class ArrowFace(width, height, orientation='right', color='gray', stroke_color='gray', stroke_width='1.5px', tooltip=None, text=None, fgcolor='black', min_fsize=6, max_fsize=15, ftype='sans-serif', name='', padding_x=0, padding_y=0)[source]¶
- __init__(width, height, orientation='right', color='gray', stroke_color='gray', stroke_width='1.5px', tooltip=None, text=None, fgcolor='black', min_fsize=6, max_fsize=15, ftype='sans-serif', name='', padding_x=0, padding_y=0)[source]¶
- property orientation¶
- class AttrFace(attr, formatter=None, name=None, color='black', min_fsize=6, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class CircleFace(radius, color, name='', tooltip=None, padding_x=0, padding_y=0)[source]¶
- class Face(name='', padding_x=0, padding_y=0)[source]¶
Base class for faces.
Ete uses “faces” to show some piece of information from a node in a tree (as text or graphics of many kinds).
- class LegendFace(colormap, title, min_fsize=6, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class OutlineFace(stroke_color=None, stroke_width=None, color=None, opacity=0.3, collapsing_height=5, padding_x=0, padding_y=0)[source]¶
- __init__(stroke_color=None, stroke_width=None, color=None, opacity=0.3, collapsing_height=5, padding_x=0, padding_y=0)[source]¶
- class RectFace(width, height, color='gray', opacity=0.7, text=None, fgcolor='black', min_fsize=6, max_fsize=15, ftype='sans-serif', tooltip=None, name='', padding_x=0, padding_y=0, stroke_color=None, stroke_width=0)[source]¶
- __init__(width, height, color='gray', opacity=0.7, text=None, fgcolor='black', min_fsize=6, max_fsize=15, ftype='sans-serif', tooltip=None, name='', padding_x=0, padding_y=0, stroke_color=None, stroke_width=0)[source]¶
- class ScaleFace(name='', width=None, color='black', scale_range=(0, 0), tick_width=80, line_width=1, formatter='%.0f', min_fsize=6, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- __init__(name='', width=None, color='black', scale_range=(0, 0), tick_width=80, line_width=1, formatter='%.0f', min_fsize=6, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class SeqFace(seq, seqtype='aa', poswidth=15, draw_text=True, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- __init__(seq, seqtype='aa', poswidth=15, draw_text=True, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class SeqMotifFace(seq=None, motifs=None, seqtype='aa', gap_format='line', seq_format='[]', width=None, height=None, fgcolor='black', bgcolor='#bcc3d0', gapcolor='gray', gap_linewidth=0.2, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- __init__(seq=None, motifs=None, seqtype='aa', gap_format='line', seq_format='[]', width=None, height=None, fgcolor='black', bgcolor='#bcc3d0', gapcolor='gray', gap_linewidth=0.2, max_fsize=12, ftype='sans-serif', padding_x=0, padding_y=0)[source]¶
- class StackedBarFace(width, height, data=None, name='', opacity=0.7, min_fsize=6, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0, tooltip=None)[source]¶
Face to show a series of stacked bars.
- class TextFace(text, name='', color='black', min_fsize=6, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0, width=None, rotation=None)[source]¶
- __init__(text, name='', color='black', min_fsize=6, max_fsize=15, ftype='sans-serif', padding_x=0, padding_y=0, width=None, rotation=None)[source]¶
Face positions¶
- class AlignedGrid(facecontainer=None)¶
Grid that also allows to store the horizontal size of each column (dxs).
The idea is to use it for headers and footers in the aligned panel.
- __init__(*args, **kwargs)¶
- class Grid¶
Grid (dict that for each column assigns a list of items).
The idea is to use it with faces, like this:
d[col] == [face1, face2, …] # faces stacked in the column col
- add_face(self, face, int column=0)¶
Add the given face to the specified column.
- make_faces()¶
Return a named tuple that for each position can store a grid of faces.
NodeStyle¶
- class NodeStyle(*args, **kargs)[source]¶
Dictionary with all valid node graphical attributes.
- __init__(*args, **kargs)[source]¶
For all possible parameters, see NODE_STYLE_DEFAULT. Some descriptions:
- Parameters:
draw_descendants (True) – Mark an internal node as a leaf.
hz_line_width (0) – Horizontal line width in pixels. If 0 it is automatic (normally 1 pixel).
vt_line_width (0) – Vertical line width in pixels. If 0 it is automatic (normally 1 pixel).
TreeLayout¶
TreeStyle¶
Layouts¶
context¶
- class LayoutGenomicContext(name='Genomic context', nside=2, conservation_threshold=0, width=70, height=15, collapse_size=1, gene_name='name', tooltip_props=[], stroke_color='gray', stroke_width='1.5px', anchor_stroke_color='black', anchor_stroke_width='3px', non_conserved_color='#d0d0d0', collapse_conservation=0.2, collapse_by_conservation=True)[source]¶
- __init__(name='Genomic context', nside=2, conservation_threshold=0, width=70, height=15, collapse_size=1, gene_name='name', tooltip_props=[], stroke_color='gray', stroke_width='1.5px', anchor_stroke_color='black', anchor_stroke_width='3px', non_conserved_color='#d0d0d0', collapse_conservation=0.2, collapse_by_conservation=True)[source]¶
default¶
- class LayoutBranchLength(name='Branch length', pos='branch_top', formatter='%0.5s', color='#8d8d8d', ftype='sans-serif', min_fsize=6, max_fsize=15, padding_x=2, padding_y=0)[source]¶
- class LayoutBranchSupport(name='Branch support', pos='branch_bottom', formatter='%0.4s', color='#fa8072', ftype='sans-serif', min_fsize=6, max_fsize=15, padding_x=2, padding_y=0)[source]¶
- class LayoutLeafName(name='Leaf name', pos='branch_right', color='black', ftype='sans-serif', min_fsize=4, max_fsize=15, padding_x=5, padding_y=0)[source]¶
- class LayoutNumberLeaves(name='Number of leaves', pos='branch_right', collapsed_only=True, formatter='(%s)', color='black', min_fsize=4, max_fsize=15, ftype='sans-serif', padding_x=5, padding_y=0)[source]¶
domain¶
eggnog6¶
- class LayoutBestName(prop='best_name', name='Best name', pos='aligned', column=3, color='black', *args, **kwargs)¶
- __init__(prop='best_name', name='Best name', pos='aligned', column=3, color='black', *args, **kwargs)¶
- class LayoutBigg(prop='bigg', name='BIGG', pos='aligned', column=8, color='gray', *args, **kwargs)¶
- __init__(prop='bigg', name='BIGG', pos='aligned', column=8, color='gray', *args, **kwargs)¶
- class LayoutCard(prop='card', name='CARD', pos='aligned', column=6, color='gray', *args, **kwargs)¶
- __init__(prop='card', name='CARD', pos='aligned', column=6, color='gray', *args, **kwargs)¶
- class LayoutCazy(prop='cazy', name='Cazy', pos='aligned', column=5, color='gray', *args, **kwargs)¶
- __init__(prop='cazy', name='Cazy', pos='aligned', column=5, color='gray', *args, **kwargs)¶
- class LayoutEvolEvents(name='Evolutionary events', prop='evol_event', speciation_color='blue', duplication_color='red', legend=True)[source]¶
- class LayoutKeggEnzyme(prop='kegg_enzyme', name='KEGG enzyme', pos='aligned', column=12, color='gray', *args, **kwargs)¶
- __init__(prop='kegg_enzyme', name='KEGG enzyme', pos='aligned', column=12, color='gray', *args, **kwargs)¶
- class LayoutKeggModule(prop='kegg_module', name='KEGG module', pos='aligned', column=11, color='gray', *args, **kwargs)¶
- __init__(prop='kegg_module', name='KEGG module', pos='aligned', column=11, color='gray', *args, **kwargs)¶
- class LayoutKeggNumber(prop='kegg_number', name='KEGG number', pos='aligned', column=9, color='gray', *args, **kwargs)¶
- __init__(prop='kegg_number', name='KEGG number', pos='aligned', column=9, color='gray', *args, **kwargs)¶
- class LayoutKeggPathway(prop='kegg_pathway', name='KEGG pathway', pos='aligned', column=10, color='gray', *args, **kwargs)¶
- __init__(prop='kegg_pathway', name='KEGG pathway', pos='aligned', column=10, color='gray', *args, **kwargs)¶
- class LayoutLastCommonAncestor(name='Last common ancestor', rect_width=15, column=1000)[source]¶
- Node properties needed
- taxid:
color
- sci_name:
text shown
- class LayoutPdb(prop='pdb', name='PDB', pos='aligned', column=7, color='gray', *args, **kwargs)¶
- __init__(prop='pdb', name='PDB', pos='aligned', column=7, color='gray', *args, **kwargs)¶
- class LayoutPfamDomains(prop='pfam', name='Pfam domains', column=20, *args, **kwargs)¶
- __init__(prop='pfam', name='Pfam domains', column=20, *args, **kwargs)¶
- class LayoutProteinName(prop='prot_name', name='Protein name', pos='aligned', column=4, color='gray', *args, **kwargs)¶
- __init__(prop='prot_name', name='Protein name', pos='aligned', column=4, color='gray', *args, **kwargs)¶
etecompare¶
evocell¶
- class LayoutHumanOGs(name='Human OGs', human_orth_prop='human_orth', column=5, color='#6b92d6')[source]¶
evol_events¶
ncbi_taxonomy¶
phylocloud_egg5¶
seq¶
spongilla¶
staple¶
- class LayoutBarplot(name=None, width=200, size_prop=None, color_prop=None, position='aligned', column=0, color_gradient=None, color='red', colors=None, padding_x=10, scale=True, legend=True, active=True)[source]¶