You are in Plugin JavaScript API » v12.1 || Go to



Plugin JavaScript API

Introduction

There is possibility to create JavaScript plugins for minerva. Tutorial on how to create plugins can be found in the minerva starter kit repository. Here we provide only documentation for the JavaScript API.

Registering with Minerva

When the plugin is loaded into Minerva minervaDefine function is called, so this needs to be present in every plugin script. This function needs to return an object which maps keys register, unregister, getName and getVersion to the corresponding functions. Register function has single argument being the Minerva object which can then later be used to interact with the map.

Below you can find sample plugin:

minervaDefine(function () {
  return {
    register: function (minervaObject) {
      console.log("registering test plugin");
    },
    unregister: function () {
      console.log("unregistering test plugin");
    },
    getName: function () {
      return "test plugin";
    },
    getVersion: function () {
      return "0.0.1";
    }
  };
})

minervaObject

minervaObject contains following properties:

Project data

project contains following properties:

  • data - interface to obtain data about map:
    • getBioEntityById({id, modelId, type}) - returns Promise of the BioEntity identified by the triplet:
      • id - unique BioEntity identifier,
      • modelId - submap on which BioEntity is expected
      • type - type of the BioEntity (‘ALIAS’ or ‘REACTION’)
    • getAllBioEntities() - returns Promise with array containing all BioEntities in given project
    • getReactionsWithElement({id, modelId, type}) - returns a Promise of an array with all reactions that include BioEntity identified by the parameter triplet
    • getProjectId() - returns string with project id
    • getName() - returns string with project name
    • getVersion() - returns string with project version
    • getDisease() - returns a structure with disease identifier associated with the project
    • getOrganism() - returns a structure with organism identifier associated with the project
    • getModels() - returns array with data about all submaps
  • map - interface to interact with minerva interface:
    • getVisibleDataOverlays() - returns Promise with list of visible data overlays
    • addListener({type, dbOverlayName, object, callback}) - adds a listener to database connector like drug database or to ‘object’ in minerva:
      • dbOverlayName - string representing database for which we want to register listener, available databases are: search, drug, chemical, mirna, comment
      • object - object type for which we want to register listener. Currently valid objects are: map, overlay, map-dialog, plugin
      • type - type of the event, supported db Events are:
        • for dbOverlayName: onSearch
        • for ‘map’ object: onZoomChanged, onCenterChanged
        • for ‘overlay’ object: onShow, onHide
        • for ‘map-dialog’ object: onDrag, onDragStart, onDragStop, onResize, onResizeStart, onResizeStop, onOpen
        • for ‘plugin’: onResize, onUnload
    • removeListener({type, dbOverlayName, callback}) - removes listener added in addListener method
    • removeAllListeners() - removes all listeners added by addListener method
    • getHighlightedBioEntities(dbOverlayName) - returns a promise with list of elements that are currently highlight by the specific database
    • showBioEntity({element, type, options}) - highlight element on the map. Returns a Promise when operation is finished. Arguments:
      • element - triplet identifying the element, it should contain three fields: id, type, model
      • type - how do you want to visualize BioEntity: ‘ICON’, ‘SURFACE’
      • options - set of visualization options: color, opacity, lineColor, lineWeight, lineOpacity
    • hideBioEntity({element, type}) - hides element on the map. Arguments:
      • element - triplet identifying the element, it should contain three fields: id, type, model
      • type - how do you want to visualize BioEntity: ‘ICON’, ‘SURFACE’
    • setCenter({modelId, x, y}) - set center point on the map:
      • modelId - submap that should be centered
      • x, y - center coordinates
    • getCenter({modelId}) - returns center point on the map:
      • modelId - submap that we are interested in
    • fitBounds({modelId, x1, y1, x2, y2}) - zoom in the map in a way that rectangle defined by parameter coordinates is visible:
      • modelId - submap that we are interested in
      • x1, y1 - top left corner coordinates
      • x2, y2 - right bottom corner coordinates
    • getBounds({modelId}) - returns bounds of the map
      • modelId - submap that we are interested in
    • setZoom({modelId, zoom}) - set zoom level of the map
      • modelId - submap that we are interested in
      • zoom - zoom level (integer)
    • getZoom({modelId}) - returns zoom level of the map
      • modelId - submap that we are interested in
    • openMap({id}) - opens submap
      • id - submap that we are interested in

Configuration

configuration contains following properties:

  • elementTypes: list of all element types used in current minerva version
  • reactionTypes: list of all reaction types used in current minerva version

Server side plugin data

pluginData structure allows you to set/get some data on the server side. Here are methods that allows it:

  • setGlobalParam(key, value) - sets global (for all users) key value property for given plugin; method returns Promise that is resolved when data is persisted
  • getGlobalParam(key) - gets global (for all users) property for given key; method returns Promise that is resolved when data is obtained
  • setUserParam(key, value) - sets key value property for given plugin and current user; method returns Promise that is resolved when data is persisted
  • getUserParam(key) - gets key value property for given plugin and current user; method returns Promise that is resolved when data is obtained