-
Notifications
You must be signed in to change notification settings - Fork 44
Genoverse functions
The following are functions that exist in the Genoverse
object. Any of these can have before/after hooks added to them, or be overwritten by supplying them as properties in configuration.
Called once the Genoverse instance is created. Sets initial properties of the instance and calls functions to creates its DOM elements, event handlers, tracks and highlights, and set the starting location.
Creates the DOM elements required by the instance of Genoverse
Argument Type Description width Integer The width for the container DOM element (usually this should be the initial value of genoverse.width
)
Creates the event handlers required for users to interact with the instance of Genoverse
If
genoverse.saveable
istrue
, configuration will be loaded fromwindow[
genoverse.storageType
].getItem(
genoverse.saveKey
)
. This configuration contains the user's previous tracks, their ordering, heights, and any other track configuration settings. If no configuration exists, the default set of tracks will be used instead.
If
genoverse.saveable
istrue
, the user's current tracks, their ordering, heights, and any other track configuration settings will be saved towindow[
genoverse.storageType
].getItem(
genoverse.saveKey
)
.
If
genoverse.saveable
istrue
, removes all tracks and unremovable highlights, adds the default set of tracks, and removes the value ingenoverse.saveKey
fromwindow[
genoverse.storageType
]
.
See the api documentation
Move the browser region a number of pixels left or right. This will be translated into a new chromosomal location based on the current value of
genoverse.scale
(width of the browser's containing DOM element in pixels / size of genomic region being viewed).Note:
genoverse.moveTo
should be used instead to change the location of a Genoverse instance externally.
Argument Type Description delta Integer The number of pixels to move the browser region by (> 1 for left to right, < 1 for right to left)
Sets
genoverse.start
andgenoverse.end
, moving the browser region in the process.Note:
genoverse.moveTo
should be used instead to change the location of a Genoverse instance externally.
Argument Type Description start Integer A number between 1
andgenoverse.chromosomeSize
end Integer A number between start
andgenoverse.chromosomeSize
update Boolean or undefined If true
, the URL will be updated with the newstart
andend
keepLength Boolean or undefined if true
, the new viewpoint will have the same zoom level as before (end - start
remains unchanged), centered on the givenstart
andend
.
Sets
genoverse.scale
to (width of the browser's containing DOM element in pixels / size of genomic region being viewed). If the scale changes, forces all tracks to draw new images at the new scale.
See the api documentation
See the api documentation
See the api documentation
See the api documentation
Called when a user moves track labels to reorder tracks in the browser. Set the moved track's
order
property such that it is between theorder
properties of its new immediate siblings.genoverse.sortTracks
is then called to update the position of the track's image element.See jQuery UI sortable update event for argument details.
Reorders the tracks' DOM elements based on each track's
order
property, lowest first.
See the api documentation
See the api documentation
If
genoverse.urlParamTemplate
is set, the URL will be updated to reflect the current browser region. This will be done either by usingwindow.history.pushState
, or by updatingwindow.location.hash
, depending on the value ofgenoverse.useHash
.
Called by
window.onpopstate
orwindow.onhashchange
to update the browser region if the user uses the back or forward buttons in their web browser.
Returns an object in the form
{ chr: '1', start: 123, end: 456 }
by parsing the URL using the value ofgenoverse.urlParamTemplate
.If the URL does not match
genoverse.urlParamTemplate
, or contains coordinates which do not match the definedgenoverse.genome
, return the initial coordinates defined bychr
,start
, andend
in the instance's configuration.
Returns a string of
genoverse.urlParamTemplate
with the placeholders replaced with their relevant values, to be used in updating the URL. Ifgenoverse.useHash
isfalse
, this will be appended to any existing value ofwindow.location.search
such that other parameters are unchanged.
Creates a popup menu for one or more features. If more than one feature is provided, the popup will contain one link per feature which each create another popup for that feature
Argument Type Description features Feature object or array of feature objects The feature(s) to make the menu for event jQuery event or undefined The click event that created the menu, used to position the menu at the mouse pointer track Genoverse.Track
instance or undefinedThe track which was clicked on
Called by
genoverse.makeMenu
to create a popup menu for a single feature
Argument Type Description feature Feature object The feature to make the menu for event jQuery event or undefined The click event that created the menu, used to position the menu at the mouse pointer track Genoverse.Track
instance or undefinedThe track which was clicked on
Called by
genoverse.makeFeatureMenu
, creates the HTML for a popup menu. This includes one or more<table>
elements, as well as titles and focus and highlight links where relevant (seecontroller.populateMenu
for futher details).If the popup menu is for a track's feature,
menuProperties
will be the value returned bycontroller.populateMenu
. If not, it will be thefeature
thatgenoverse.makeFeatureMenu
was called with.
Argument Type Description menuProperties Object or Array of Objects The properties of the feature to create the popup for feature Object The feature to create the popup for menuEl jQuery selector The element containing the popup menu contentEl jQuery selector The element containing the popup menu's content track Genoverse.Track
instance or undefinedThe track which was clicked on to create the popup
See the api documentation
See the api documentation
See the api documentation
Initializes a scroll action
Argument Type Description e jQuery event The user event which starts a scroll operation
Ends a scroll action
Argument Type Description update Boolean or undefined If not false
, will update the URL to the new location (providing the URL is changeable by the instance of Genoverse)
Initializes a select action
Argument Type Description e jQuery event The user event which starts a select operation
Ends a select action, showing an actions menu for the selected region
Argument Type Description e jQuery event The user event which ends a select operation
Hides the region selection element
Resizes the region selection element based on a mousemove event
Argument Type Description e jQuery event The mousemove event
If the shift key is pressed, region selection is enabled while it is held down (nothing happens if
genoverse.dragAction
was already"select"
). If the escape key is pressed, any popup menus (for track features or the region select menu) are hidden.
Argument Type Description e jQuery event The keydown event
If the shift key is released, region selection is disabled if it was enabled by pressing the key initially (nothing happens if
genoverse.dragAction
was already"select"
).
Argument Type Description e jQuery event The keyup event
Starts a scroll or select action by calling
genoverse.startDragScroll(e)
orgenoverse.startDragSelect(e)
, based on the value ofgenoverse.dragAction
Argument Type Description e jQuery event The mousedown event
Ends the current scroll or select action by calling
genoverse.stopDragScroll(update)
orgenoverse.stopDragSelect(e)
, as applicable
Argument Type Description e jQuery event The mouseup event
If a scroll action is taking place, moves the browser region as the mouse moves. If a region select is taking place, changes the size of the selected region as the mouse moves. If
genoverse.dragAction
is"select"
and a region select is not taking place, moves the region select element (a dotted red vertical line) to the location of the mouse pointer.
Argument Type Description e jQuery event The mousemove event
Performs zoom in and zoom out operations
Argument Type Description e jQuery event The user event which will cause a zoom operation delta 1
or-1
1
for zoom in,-1
for zoom out
Calls
genoverse.setRange
to zoom in, halving the size of the browser region (e.g. 100-200 becomes 125-175). If anx
argument is provided, the zoom will step towards that point, instead of directly inward.x
is the difference between the x coordinate of a mousewheel zoom event and the left offset of the browser images on the page.
Argument Type Description x Integer or undefined The point to zoom towards
Calls
genoverse.setRange
to zoom out, doubling the size of the browser region (e.g. 100-200 becomes 50-250). If anx
argument is provided, the zoom will step towards that point, instead of directly outward.x
is the difference between the x coordinate of a mousewheel zoom event and the left offset of the browser images on the page.
Argument Type Description x Integer or undefined The point to zoom towards
See the api documentation
See the api documentation
See the api documentation
See the api documentation
See the api documentation
If
genoverse.genome
is an object, returns the size of the chromosome in the genome, else returnsgenoverse.chromosomeSize
Argument Type Description chr String The name of the chromosome
Returns an object in the form
{ start: 1, end: 2, left: 1, width, 1 }
representing the position of the region selector DOM element.start
andend
are the genomic coordinates selected by the region,left
andwidth
are the CSS positional values of the element.
Calls the function
functionName
on all tracks in the instance of Genoverse, with the arguments provided
Argument Type Description functionName String The name of the function to call. This function can be in Genoverse.Track
,Genoverse.Track.Controller
,Genoverse.Track.Model
, orGenoverse.Track.View
args Anything A list of arguments to be passed to the function being called