JBrowseConfig API
- class JBrowseConfig(view='LGV', conf=None)
Creates JBrowse configuration objects. Currently supporting configuration objects for the React JBrowse Linear Genome View and React JBrowse Circular Genome View https://jbrowse.org/storybook/lgv/main https://jbrowse.org/storybook/cgv/main/
- add_df_track(track_data, name, **kwargs)
Adds track from a pandas DataFrame. If the score column is present, it will create a Quantitative track else it will create a Feature track.
Requires DataFrame to have columns named ‘refName’, ‘start’, ‘end’, and ‘name’
Requires refName and name columns to be of type str and start, end, and score to be int
e.g: add_df_track(df, “track_name”)
- Parameters
track_data – panda DataFrame with the track data.
name (str) – name for the track.
track_id (str) – (optional) trackId for the track
overwrite (str) – flag wether or not to overwrite existing track.
- Raises
Exception – if assembly has not been configured.
TypeError – if track data is invalid
TypeError – if view is not LGV
TypeError – if track with that trackId already exists list of tracks
- add_text_search_adapter(ix, ixx, meta, adapter_id=None)
Adds an aggregate trix text search adapter. Currently not available for Circular Genome View
e.g: add_text_search_adapter(“url/file.ix”, url/file.ixx”, “url/meta.json”)
- Parameters
ix (str) – url/path to ix file
ixx (str) – url/path to ixx file
meta (str) – url/path to meta.json file
adapter_id (str) – optional adapter_id
- Raises
Exception – if assembly has not been configured
TypeError – if adapter with same adapter id is already configured
TypeError – Paths are only supported in jupyter.
TypeError – if view is CGV
- add_track(data, **kwargs)
Adds a track subconfiguration to the list of tracks in the config.
if an index is not provided, it will assume an index file with the same name can be found in the directory of the track data
e.g: add_track(“url.bam”) assumes “url.bam.bai” also exists
- Parameters
data (str) – track file url/path
name (str) – (optional) name for the track (defaults to data filename)
track_id (str) – (optional) trackId for the track
index (str) – (optional) file url/path for the track
track_type (str) – (optional) track type
overwrite (boolean) – (optional) defaults to False
- Raises
Exception – if assembly has not been configured
TypeError – if track data is not provided
TypeError – if track type is not supported
TypeError – Paths are only supported in jupyter.
- delete_track(track_id)
Deletes a track from the config.
e.g: delte_track(“test_track_id”)
Will delete track with track_id test_track_id.
- Parameters
track_id (str) – track_id to delete
- Raises
TypeError – if track_id provided does not exist
- get_config()
Returns the configuration object of the JBrowseConfig instance. This object can then be passed to launch or create_component to launch or create a Dash JBrowse component
e.g: create(“LGV”, genome=”hg19”).get_config()
- Returns
returns configuration object
- Return type
obj
- set_assembly(assembly_data, **kwargs)
Sets the assembly.
Assumes assembly_data.fai exists for fasta assembly data that is not bgzipped.
Assumes assembly_data.fai and assembly_data.gzi exist for bgzipped assembly data.
e.g set_assembly(“url/assembly.fasta.gz”, overwrite=True) assumes “url/assembly.fasta.gz.fai” and “url/assembly.fasta.gz.gzi” also exist
For configuring assemblies check out our config docs https://jbrowse.org/jb2/docs/config_guide/#assembly-config
- Parameters
assembly_data (str) – url/path to the sequence data
name (str) – (optional) name for the assembly, defaults to name generated from assembly_data file name
aliases (list) – (optional) list of aliases for the assembly
refname_aliases (obj) – (optional) config for refname aliases.
overwrite (str) – flag wether or not to overwrite existing assembly, default to False.
- Raises
TypeError – Paths are only supported in jupyter.
TypeError – adapter used for file type is not supported or recognized
- set_default_session(tracks_ids, display_assembly=True)
Sets the default session given a list of track ids
e.g: set_default_session([‘track_id’, ‘track_id2’])
- Parameters
tracks_ids – list[str] list of track ids to display
display_assembly (boolean) – display the assembly reference sequence track. Defaults to True
- Raises
Exception – if assembly has not been configured
- set_env(notebook_host='localhost', notebook_port=8888)
Changes the port and the host for creating links to files found within the file tree of jupyter.
We want to be able to use paths to local files that can be accessed within the file tree of jupyter notebook and jupyter lab. The port and host should match those configured in your jupyter config.
You can set_env after creating your view. browser = create(“LGV”) browser.set_env(“localhost”, 8989)
- Parameters
notebook_host (str) – host used in jupyter config for for using paths to local files. (Defaults to “localhost”)
notebook_port (str) – port used in jupyter config for for using paths to local files. (Defaults to 8888)
- set_location(location)
Sets initial location for when the browser first loads.
e.g: set_location(“chr1:1..90”)
- Parameters
location (str) – location, syntax ‘refName:start-end’
- Raises
TypeError – if view is CGV, location not supported in CGV
- set_theme(primary, secondary=None, tertiary=None, quaternary=None)
Sets the theme in the configuration. Accepts up to 4 hexadecimal colors.
e.g: set_theme(“#311b92”, “#0097a7”, “#f57c00”, “#d50000”)
- Parameters
primary (str) – primary color of custom palette
secondary (str) – (optional) secondary color
tertiary (str) – (optional) tertiary color
quaternary (str) – (optional) quaternary color