Class: BaseUMAdapter

LocusZoom_Adapters~BaseUMAdapter(config)

The base adapter for the UMich Portaldev API server. This adds a few custom behaviors that handle idiosyncrasies of one particular web server.

Constructor

new BaseUMAdapter(config)

Parameters:
Name Type Description
config Object
Properties
Name Type Attributes Description
build String <optional>

The genome build to be used by all requests for this adapter. (UMich APIs are all genome build aware). "GRCh37" or "GRCh38"

Source:

Extends

Methods

_annotateRecords(records, options) → {*}

Perform custom client-side operations on the retrieved data. For example, add calculated fields or perform rapid client-side filtering on cached data. Annotations are applied after cache, which means that the same network request can be dynamically annotated/filtered in different ways in response to user interactions.

This result is currently not cached, but it may become so in the future as responsibility for dynamic UI behavior moves to other layers of the application.

Parameters:
Name Type Description
records Array.<Object>
options Object
Overrides:
Source:
Returns:
Type
*

_buildRequestOptions(options, dependent_data) → {*}

Build an object with options that control the request. This can take into account both explicit options, and prior data.

Parameters:
Name Type Description
options Object

Any global options passed in via getData. Eg, in locuszoom, every request is passed a copy of plot.state as the options object, in which case every adapter would expect certain basic information like chr, start, end to be available.

dependent_data Array.<Object>

If the source is called with dependencies, this function will receive one argument with the fully parsed response data from each other source it depends on. Eg, ld(assoc) means that the LD adapter would be called with the data from an association request as a function argument. Each dependency is its own argument: there can be 0, 1, 2, ...N arguments.

Overrides:
Source:
Returns:

An options object containing initial options, plus any calculated values relevant to the request.

Type
*

_findPrefixedKey(a_record, fieldname)

Convenience method, manually called in LZ sources that deal with dependent data.

In the last step of fetching data, LZ adds a prefix to each field name. This means that operations like "build query based on prior data" can't just ask for "log_pvalue" because they are receiving "assoc:log_pvalue" or some such unknown prefix.

This helper lets us use dependent data more easily. Not every adapter needs to use this method.

Parameters:
Name Type Description
a_record Object

One record (often the first one in a set of records)

fieldname String

The desired fieldname, eg "log_pvalue"

Overrides:
Source:

_getCacheKey(options) → {string}

Determine how a particular request will be identified in cache. Most LZ requests are region based, so the default is a string concatenation of chr_start_end. This adapter is "region aware"- if the user zooms in, it won't trigger a network request because we alread have the data needed.

Parameters:
Name Type Description
options

Receives plot.state plus any other request options defined by this source

Overrides:
Source:
Returns:
Type
string

_normalizeResponse(response_text, options) → {Array.<Object>}

Some endpoints in the UM portaldev API returns columns of data, rather than rows. Convert the response to record objects, each row of a table being represented as an object of {field:value} pairs.

Parameters:
Name Type Description
response_text
options
Overrides:
Source:
Returns:
Type
Array.<Object>

_performRequest(options) → {Promise}

Perform the act of data retrieval (eg from a URL, blob, or JSON entity)

Parameters:
Name Type Description
options object

Request options from _buildRequestOptions

Overrides:
Source:
Returns:
Type
Promise

_postProcessResponse(records, options) → {*}

Add the "local namespace" as a prefix for every field returned for this request. Eg if the association api returns a field called variant, and the source is referred to as "assoc" within a particular data layer, then the returned records will have a field called "assoc:variant"

Parameters:
Name Type Description
records
options
Overrides:
Source:
Returns:
Type
*

getData(options, …dependent_data) → {Promise.<*>}

All adapters must implement this method to asynchronously return data. All other methods are simply internal hooks to customize the actual request for data.

Parameters:
Name Type Attributes Description
options object

Shared options for this request. In LocusZoom, this is typically a copy of plot.state.

dependent_data Array.<Array> <repeatable>

Zero or more recordsets corresponding to each individual adapter that this one depends on. Can be used to build a request that takes into account prior data.

Overrides:
Source:
Returns:
Type
Promise.<*>