GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
206 stars 62 forks source link

Make feature detail formatters to allow things like external links #1981

Closed cmdcolin closed 2 years ago

cmdcolin commented 3 years ago

These was fairly common in jbrowse 1 to allow formatting detail panels to have custom link-outs to external DBs, etc.

fmtDetailValue was the way it was done in jbrowse 1

cmdcolin commented 3 years ago

here is a random possibility for jbrowse 2

it could potentially be session level (?)

i did this out of convenience and because it kind of makes sense...oftentimes the fmtDetailValues were highly duplicated throughout a trackList, so perhaps centralizing it would be nice

here is an example expression that stitches together a URL for civicDB plugin, we have a config slot on session model (default value here just for example)

extraFields: {
            type: 'string',
            description: 'modifies on the base feature details',
            defaultValue: `jexl:{civicdb:"<a href=https://civicdb.org/events/genes/"+feature.gene_id+"/summary/variants/"+feature.id+"/summary>Link to CIVIC</a>"}`,
            contextVariable: ['feature'],
          },

Then in basefeaturedetails, we call

const extraFields = getConf(session, ['featureDetails', 'extraFields'], {
    feature,
  })

And mix the result into the feature

This way, we can obtain new fields that are not in the data, and or mutate existing fields

cmdcolin commented 3 years ago

screenshot showing link at the bottom

localhost_3000__config=test_data%2Fconfig_demo json session=local-lu0eld9wg