Data / BioEntities#
The methods contained within ‘Data / BioEntities’ are used to access/modify data on content/drugs/chemicals entities, as well as markers drawn on the map: pins, surfaces, lines, polygons, texts and images.
Below is a description of the methods, as well as the types they return.
Available data access methods include:
getAllChemicals- gets list of searched chemicals
- returns array of
Chemical
getAllContent- gets list of searched content
- returns array of
BioEntity
getAllDrugs- gets list of searched drugs
- returns array of
Drug
getAllMarkers- gets list of added markers
- returns array of
Marker
getShownElementsgets list of all currently shown content/chemicals/drugs BioEntities + markers
returns object of
{ content: BioEntity[] drugs: BioEntity[] chemicals: BioEntity[] markers: Marker[] }
Available data modify methods include:
clearAllElements#
accepts single argument
- array of
stringwhich includes one or more of:'drugs','chemicals','content','marker'
- array of
clears all elements of provided type(s)
returns nothing
example:
window.minerva.data.bioEntities.clearAllElements(['drugs', 'chemicals']);
addSingleMarker#
accepts single argument: a marker object
fields common to all marker types:
{ type: 'pin' OR 'surface' OR 'line' OR 'polygon' OR 'text' OR 'image' id: string [optional] opacity: number modelId: number [optional] }id - optional, if not provided uuidv4 is generated; a plugin can choose its own ids to recognise its markers in click events
opacity - should be a float between
0and1(example:0.54)modelId - if marker should be visible only on single map, modelId should be provided
colors should be provided in hex format with hash (example:
#FF0000)
fields specific to the marker type:
type fields pincolor,x,y,number[optional] - number presented on the pin,width[optional],height[optional]surfacecolor,x,y,width,heightlinecolor,start: { x, y },end: { x, y }polygonfillColor,borderColor,borderWidth,points: [{ x, y }, ...]- ordered list of the polygon verticestextcolor,x,y,text,fontName[optional] - one of'ARIAL','HELVETICA','TIMES_NEW_ROMAN','COURIER_NEW','GEORGIA','VERDANA'(default'ARIAL'),fontSize[optional] (default12)imagex,y,width,height,url- source of the image- x, y, start, end and points are coordinates on the map
adds one marker to markers list
returns created
Markerthrows an error when a marker with the given
idis already shown; useupdateSingleMarkerto change an existing markerclicking a marker on the map triggers an event, see Events
examples:
window.minerva.data.bioEntities.addSingleMarker({ type: 'surface', color: '#106AD7', opacity: 0.67, x: 4438, y: 1124, width: 200, height: 300, modelId: 52, });window.minerva.data.bioEntities.addSingleMarker({ type: 'pin', color: '#106AD7', opacity: 1, x: 8723, y: 4322, number: 43, }); window.minerva.data.bioEntities.addSingleMarker({ type: 'line', color: '#106AD7', opacity: 1, modelId: 52, start: { x: 8723, y: 4322, }, end: { x: 4438, y: 1124, }, });window.minerva.data.bioEntities.addSingleMarker({ type: 'polygon', fillColor: '#106AD7', borderColor: '#000000', borderWidth: 2, opacity: 0.5, points: [ { x: 8723, y: 4322 }, { x: 4438, y: 1124 }, { x: 5000, y: 6000 }, ], modelId: 52, }); window.minerva.data.bioEntities.addSingleMarker({ type: 'text', color: '#106AD7', opacity: 1, x: 8723, y: 4322, text: 'Hello map', fontSize: 24, modelId: 52, }); window.minerva.data.bioEntities.addSingleMarker({ type: 'image', opacity: 1, x: 8723, y: 4322, width: 200, height: 200, url: 'https://example.com/image.png', modelId: 52, });
updateSingleMarker#
accepts single argument: a marker object with the same fields as in
addSingleMarker;idis required and identifies the marker to changereplaces the shown marker with the given
idand keeps its id; the whole marker is replaced (not patched), so all fields required by the marker type must be provided, and the type itself may changereturns updated
Markerthrows an error when no marker with the given
idis shownexample:
window.minerva.data.bioEntities.addSingleMarker({ id: 'gene-TP53', type: 'pin', color: '#106AD7', opacity: 1, x: 8723, y: 4322, }); window.minerva.data.bioEntities.updateSingleMarker({ id: 'gene-TP53', type: 'pin', color: '#D71010', opacity: 1, x: 8723, y: 4322, });
removeSingleMarker#
accepts single argument of
stringwhich represents markeridremoves one marker from markers list
returns nothing
example:
window.minerva.data.bioEntities.removeSingleMarker('f4c068d1-9695-4f1b-928c-d0cff92164b2');
removeAllMarkers#
removes all markers from markers list
returns nothing
example:
window.minerva.data.bioEntities.removeAllMarkers();