EIYBrowse.tracks.base module¶
The tracks.base module defines abstract base classes, which should be subclassed to create new tracks.
The Track class should be chosen as a base class if
the track does not rely on any external data (e.g. if you want
to plot a scale bar.
The FileTrack class should be chosen as a base class
if the track does rely on some external data file.
-
class
EIYBrowse.tracks.base.FileTrack(datafile, name=None, name_rotate=False)¶ Bases:
EIYBrowse.tracks.base.TrackBase class for browser tracks that need external data
Create a new track object with an attached datafile.
Essentially this class does the same work as
Trackexcept that it first usesopen_file()to create a new file object and then attaches that object to self.datafile.Parameters: - datafile – A datafile object which handles extracting the data to plot for any given genomic region.
- name (str) – Optional name label for the track
- name_rotate (bool) – Whether the name label should be rotated 90 degrees
-
classmethod
from_config_dict(file_path, file_type, **kwargs)¶ Instead of instantiating a new track object with an open datafile object, instead pass the path to the datafile and the file_type string specifiying the class which handles that file format. Open the datafile and instantiate the class with the newly created datafile object.
Parameters: - file_path (str) – Path to the datafile location
- file_type (str) – String specifying the format of the datafile.
The mapping between format specifiers and classes is defined by
the EIYBrowse.filetypes entry point (see setuptools documentation
or
EIYBrowse.filetypesfor more information.)
-
class
EIYBrowse.tracks.base.Track(name=None, name_rotate=False)¶ Bases:
objectBase class for all browser tracks
Create a new track object.
Parameters: - name (str) – Optional name label for the track
- name_rotate (bool) – Whether the name label should be rotated 90 degrees
-
classmethod
from_config_dict(**kwargs)¶ Intantiating a track object from the config file may require instantiating some other objects first (namely datafiles).
For some tracks, we don’t need to do this, so we simpy return an object of type cls with the arguments in kwargs.
Any subclass that needs some logic to be executed before it can be instatiated should put that logic here.
-
get_config(region, browser)¶ Any subclass that needs to do setup before the axes are created should place that code here.
-
plot(region, plot_ax, label_ax=None)¶ Public method called when we need to plot the track to an axis. Sets up the axes, plots the name label if specified, and passes the rest of the work to the
_plot()method.Parameters: - region (
pybedtools.Interval) – Genomic region to plot. - plot_ax (
matplotlib.axes.AxesSubplot) – Axis for plotting the data - label_ax (
matplotlib.axes.AxesSubplot) – Axis for plotting the name label
- region (