trackhub.BaseTrack

digraph inheritance5d138bf573 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "trackhub.base.HubComponent" [URL="trackhub.base.HubComponent.html#trackhub.base.HubComponent",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for various track hub components. Several methods must be"]; "trackhub.track.BaseTrack" [URL="#trackhub.BaseTrack",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "trackhub.base.HubComponent" -> "trackhub.track.BaseTrack" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class trackhub.BaseTrack(name, tracktype=None, short_label=None, long_label=None, subgroups=None, source=None, filename=None, html_string=None, html_string_format='rst', **kwargs)[source]

Bases: HubComponent

Represents a single track stanza, base class for other track types.

Parameters:
  • name (str) – Name of the track

  • tracktype (str) – Type of the track (e.g., “bam”, “bigWig”). The UCSC parameter name is “type” which is a reserved Python keyword, hence using “tracktype” here.

  • short_label (str) – Used for the left-hand side track label; alias for UCSC parameter “shortLabel”

  • long_label (str) – Used for the longer middle labels; if None will copy short_label. Alias for UCSC parameter “longLabel”.

  • subgroups (dict) –

    A dictionary of {name: tag} where each name is the name of a SubGroupDefinition in a parent CompositeTrack and each tag is a key in the SubGroupDefinition.mapping dictionary. The dictionary {‘celltype’: ‘ES’} would end up looking like this in the string representation:

    subGroups celltype=ES
    

    or like this, if the track had been added to a ViewTrack whose name is aln:

    subGroups view=aln celltype=ES
    

  • source (str or None) – Local path to the file. If None, then url must instead be used to point to an already-existing filename or URL.

  • filename (str or None) – Path to upload the file to, over rsync and ssh, relative to the hub directory. Typically only used when you need extensive control over the remote filename. If None, will use a filename of “<name>.tracktype>” in the same directory as the TrackDb. By default, TrackDb goes in a directory named after the assembly of its parent Genome object.

  • html_string (str) – String containing documentation for a track. By default, the format is assumed to be ReStructured Text format, use html_string_format=”html” if the documentation is already in HTML format.

  • html_string_format ('html' or 'rst') – Indicates the format of html_string. If “html”, then use as-is; if “rst” then convert ReST to HTML.

Methods

__init__(name[, tracktype, short_label, ...])

Represents a single track stanza, base class for other track types.

add_child(child)

Adds self as parent to child, and then adds child.

add_params(**kw)

Add [possibly many] parameters to the track.

add_parent(parent)

Adds self as child of parent, then adds parent.

add_subgroups(subgroups)

Update the subgroups for this track.

add_trackdb(trackdb)

Attach this track to a parent TrackDb object.

leaves(cls[, level, intermediate])

Returns an iterator of the HubComponent leaves that are of class cls.

makedirs(fn)

remove_params(*args)

Remove [possibly many] parameters from the track.

render([staging])

Renders the object to file, returning a list of created files.

root([cls, level])

Returns the top-most HubComponent in the hierarchy.

validate()

Runs validation, raising exceptions as needed.

__init__(name, tracktype=None, short_label=None, long_label=None, subgroups=None, source=None, filename=None, html_string=None, html_string_format='rst', **kwargs)[source]

Represents a single track stanza, base class for other track types.

Parameters:
  • name (str) – Name of the track

  • tracktype (str) – Type of the track (e.g., “bam”, “bigWig”). The UCSC parameter name is “type” which is a reserved Python keyword, hence using “tracktype” here.

  • short_label (str) – Used for the left-hand side track label; alias for UCSC parameter “shortLabel”

  • long_label (str) – Used for the longer middle labels; if None will copy short_label. Alias for UCSC parameter “longLabel”.

  • subgroups (dict) –

    A dictionary of {name: tag} where each name is the name of a SubGroupDefinition in a parent CompositeTrack and each tag is a key in the SubGroupDefinition.mapping dictionary. The dictionary {‘celltype’: ‘ES’} would end up looking like this in the string representation:

    subGroups celltype=ES
    

    or like this, if the track had been added to a ViewTrack whose name is aln:

    subGroups view=aln celltype=ES
    

  • source (str or None) – Local path to the file. If None, then url must instead be used to point to an already-existing filename or URL.

  • filename (str or None) – Path to upload the file to, over rsync and ssh, relative to the hub directory. Typically only used when you need extensive control over the remote filename. If None, will use a filename of “<name>.tracktype>” in the same directory as the TrackDb. By default, TrackDb goes in a directory named after the assembly of its parent Genome object.

  • html_string (str) – String containing documentation for a track. By default, the format is assumed to be ReStructured Text format, use html_string_format=”html” if the documentation is already in HTML format.

  • html_string_format ('html' or 'rst') – Indicates the format of html_string. If “html”, then use as-is; if “rst” then convert ReST to HTML.

add_child(child)

Adds self as parent to child, and then adds child.

add_params(**kw)[source]

Add [possibly many] parameters to the track.

Parameters will be checked against known UCSC parameters and their supported formats.

E.g.:

add_params(color='128,0,0', visibility='dense')
add_parent(parent)

Adds self as child of parent, then adds parent.

add_subgroups(subgroups)[source]

Update the subgroups for this track.

Note that in contrast to CompositeTrack(), which takes a list of SubGroupDefinition objects representing the allowed subgroups, this method takes a single dictionary indicating the particular subgroups for this track.

Parameters:

subgroups (dict) – Dictionary of subgroups, e.g., {‘celltype’: ‘K562’, ‘treatment’: ‘a’}. Each key must match a SubGroupDefinition name in the composite’s subgroups list. Each value must match a key in that SubGroupDefinition.mapping dictionary.

add_trackdb(trackdb)[source]

Attach this track to a parent TrackDb object.

leaves(cls, level=0, intermediate=False)

Returns an iterator of the HubComponent leaves that are of class cls.

If intermediate is True, then return any intermediate classes as well.

remove_params(*args)[source]

Remove [possibly many] parameters from the track.

E.g.:

remove_params('color', 'visibility')
render(staging=None)

Renders the object to file, returning a list of created files.

Calls validation code, and, as long as each child is also a subclass of HubComponent, the rendering is recursive.

root(cls=None, level=0)

Returns the top-most HubComponent in the hierarchy.

If cls is not None, then return the top-most attribute HubComponent that is an instance of class cls.

For a fully-constructed track hub (and cls=None), this should return a a Hub object for every component in the hierarchy.

validate()[source]

Runs validation, raising exceptions as needed. Must be overridden by subclass.