gramene-search 2.40.0 → 2.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -232,6 +232,14 @@ $parcel$export(module.exports, "bootViewFromUrl", () => $c69c61828e36a328$export
232
232
 
233
233
 
234
234
 
235
+ // The API the gene Expression tab takes its studies from: configuration
236
+ // expressionApi when set, for a site whose own index has no expression studies
237
+ // or attributes but shares its genes (by id) with one that does, as Gramene
238
+ // Maize (maize_v5) does with Gramene's current release.
239
+ const $9d9aeaf9299e61a1$var$expressionApi = (store)=>{
240
+ const cfg = store.selectConfiguration();
241
+ return (cfg && cfg.expressionApi || store.selectGrameneAPI()).replace(/\/$/, '');
242
+ };
235
243
  const $9d9aeaf9299e61a1$var$facets = [
236
244
  "{!facet.limit='300' facet.mincount='1' key='taxon_id'}taxon_id",
237
245
  // "{!facet.limit='100' facet.mincount='1' key='genetree'}gene_tree",
@@ -423,7 +431,7 @@ const $9d9aeaf9299e61a1$var$expressionStudies = (0, $gXNCa$reduxbundler.createAs
423
431
  persist: true,
424
432
  staleAfter: 86400000,
425
433
  getPromise: ({ store: store })=>{
426
- return fetch(`${store.selectGrameneAPI()}/experiments?rows=-1`).then((res)=>res.json()).then((res)=>(0, ($parcel$interopDefault($gXNCa$lodash))).groupBy(res, 'taxon_id'));
434
+ return fetch(`${$9d9aeaf9299e61a1$var$expressionApi(store)}/experiments?rows=-1`).then((res)=>res.json()).then((res)=>(0, ($parcel$interopDefault($gXNCa$lodash))).groupBy(res, 'taxon_id'));
427
435
  }
428
436
  });
429
437
  // Only fetch when a view that consumes expression studies is enabled.
@@ -766,8 +774,10 @@ const $9d9aeaf9299e61a1$var$grameneParalogs = {
766
774
  // e.g. ['E-MTAB-3839', 'JGI-SB-2']), keyed by gene id. The search results do
767
775
  // not carry the field (it is not among /search's default fields), so the
768
776
  // Expression tab asks for it gene by gene. Each entry is {pending: true} while
769
- // the request is out, then {studies: [...]} ([] for a gene expressed in no
770
- // study), or {studies: null} when the request failed (asked again next time).
777
+ // the request is out, then {studies: [...]}, or {studies: null} when the
778
+ // request failed (asked again next time) or the gene's doc lacks the field:
779
+ // older indexes (e.g. maize_v5) never carry it, so its absence can't be read
780
+ // as "in no study". A site with an expressionApi asks that instead.
771
781
  const $9d9aeaf9299e61a1$var$grameneGeneStudies = {
772
782
  name: 'grameneGeneStudies',
773
783
  getReducer: ()=>(state = {}, { type: type, payload: payload })=>{
@@ -805,12 +815,12 @@ const $9d9aeaf9299e61a1$var$grameneGeneStudies = {
805
815
  payload: geneId
806
816
  });
807
817
  const q = encodeURIComponent(`id:"${geneId}"`);
808
- fetch(`${store.selectGrameneAPI()}/search?q=${q}&fl=id,expressed_in_gxa_attr_ss&rows=1`).then((res)=>{
818
+ fetch(`${$9d9aeaf9299e61a1$var$expressionApi(store)}/search?q=${q}&fl=id,expressed_in_gxa_attr_ss&rows=1`).then((res)=>{
809
819
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
810
820
  return res.json();
811
821
  }).then((res)=>{
812
822
  const doc = res.response.docs.find((d)=>d.id === geneId);
813
- const studies = doc && doc.expressed_in_gxa_attr_ss || [];
823
+ const studies = doc && doc.expressed_in_gxa_attr_ss || null;
814
824
  dispatch({
815
825
  type: 'GRAMENE_GENE_STUDIES_RECEIVED',
816
826
  payload: {
@@ -8362,18 +8372,6 @@ const $9e29a4f60318db7a$var$Detail = (props)=>{
8362
8372
  studies,
8363
8373
  geneStudyIds
8364
8374
  ]);
8365
- // Without a baseline study the EBI Studies heatmap has nothing to draw (its
8366
- // request fails rather than coming back empty), so the tab says so and
8367
- // points at the differential EBI studies the gene does appear in -- e.g.
8368
- // Medicago truncatula, whose studies are all differential.
8369
- const ebiDifferential = (0, $gXNCa$react.useMemo)(()=>{
8370
- if (!geneStudyIds || !studies) return [];
8371
- const mine = new Set(geneStudyIds);
8372
- return studies.filter((e)=>mine.has(e._id) && $9e29a4f60318db7a$var$isDifferential(e) && !$9e29a4f60318db7a$var$isJgiStudy(e)).sort((a, b)=>$9e29a4f60318db7a$var$studyLabel(a) < $9e29a4f60318db7a$var$studyLabel(b) ? -1 : 1);
8373
- }, [
8374
- studies,
8375
- geneStudyIds
8376
- ]);
8377
8375
  const allJgiKey = JSON.stringify(allJgiStudies.map((e)=>[
8378
8376
  e._id,
8379
8377
  e.name
@@ -8478,32 +8476,21 @@ const $9e29a4f60318db7a$var$Detail = (props)=>{
8478
8476
  children: [
8479
8477
  gene.name || gene._id,
8480
8478
  " is not in any baseline expression study, so there is no heatmap here.",
8481
- ebiDifferential.length > 0 && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)((0, $gXNCa$reactjsxruntime.Fragment), {
8479
+ paralogQuery && atlasExperiment && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)((0, $gXNCa$reactjsxruntime.Fragment), {
8482
8480
  children: [
8483
8481
  ' ',
8484
- "It has results in ",
8485
- ebiDifferential.length === 1 ? 'a differential study' : `${ebiDifferential.length} differential studies`,
8486
- " at Expression Atlas:",
8487
- /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("ul", {
8488
- className: "mt-1 mb-0",
8489
- children: ebiDifferential.map((e)=>/*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("li", {
8490
- children: [
8491
- /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("a", {
8492
- href: `${$9e29a4f60318db7a$var$EBI_GXA}experiments/${encodeURIComponent(e._id)}/Results?geneQuery=${encodeURIComponent(JSON.stringify([
8493
- {
8494
- value: geneQuery
8495
- }
8496
- ]))}`,
8497
- target: "_blank",
8498
- rel: "noopener noreferrer",
8499
- children: e.description || e._id
8500
- }),
8501
- " (",
8502
- e._id,
8503
- ")"
8504
- ]
8505
- }, e._id))
8506
- })
8482
+ "To explore the differential expression of this gene and its paralogs, use the",
8483
+ ' ',
8484
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $gXNCa$reactbootstrap.Button), {
8485
+ variant: "link",
8486
+ size: "sm",
8487
+ className: "p-0 align-baseline",
8488
+ onClick: ()=>setExpression({
8489
+ activeTab: 'paralogs'
8490
+ }),
8491
+ children: "Paralogs tab"
8492
+ }),
8493
+ "."
8507
8494
  ]
8508
8495
  })
8509
8496
  ]
@@ -8818,6 +8805,32 @@ function $cd8bc494277e92a4$export$965a6b1d7408d496(docs, tree) {
8818
8805
  }
8819
8806
  const $cd8bc494277e92a4$var$gridBorder = '1px solid var(--tbrowse-grid-line, rgba(0,0,0,0.06))';
8820
8807
  const $cd8bc494277e92a4$var$stressWidth = (width, organCount)=>Math.max($cd8bc494277e92a4$var$STRESS_MIN, width - organCount * $cd8bc494277e92a4$var$ORGAN_CELL_W - $cd8bc494277e92a4$var$MAXTPM_W);
8808
+ // "Expressed only" toggle. Homology applies it: while on (and the zone is
8809
+ // visible) it prunes every branch with no gene that has expression
8810
+ // attributes, and turning it on expands the branches that remain.
8811
+ const $cd8bc494277e92a4$var$ExpressedOnlyToggle = ({ on: on, onChange: onChange })=>/*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("label", {
8812
+ title: "Prune branches without expression data and expand the rest",
8813
+ style: {
8814
+ display: 'inline-flex',
8815
+ alignItems: 'center',
8816
+ gap: 3,
8817
+ fontSize: 10,
8818
+ cursor: 'pointer',
8819
+ whiteSpace: 'nowrap',
8820
+ margin: 0
8821
+ },
8822
+ children: [
8823
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("input", {
8824
+ type: "checkbox",
8825
+ checked: on,
8826
+ onChange: (e)=>onChange(e.target.checked),
8827
+ style: {
8828
+ margin: 0
8829
+ }
8830
+ }),
8831
+ "expressed only"
8832
+ ]
8833
+ });
8821
8834
  const $cd8bc494277e92a4$var$ExprHeader = ({ zoneState: zoneState, setZoneState: setZoneState, width: width, data: data, hoveredNodeId: hoveredNodeId })=>{
8822
8835
  const ea = data.hostData && data.hostData.exprAttrs || {};
8823
8836
  const organs = ea.organs || [];
@@ -8850,6 +8863,13 @@ const $cd8bc494277e92a4$var$ExprHeader = ({ zoneState: zoneState, setZoneState:
8850
8863
  name: next
8851
8864
  }))
8852
8865
  }),
8866
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)($cd8bc494277e92a4$var$ExpressedOnlyToggle, {
8867
+ on: !!zoneState?.expressedOnly,
8868
+ onChange: (on)=>setZoneState((s)=>({
8869
+ ...s ?? {},
8870
+ expressedOnly: on
8871
+ }))
8872
+ }),
8853
8873
  /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("span", {
8854
8874
  style: {
8855
8875
  display: 'flex',
@@ -9312,6 +9332,30 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9312
9332
  const keepGeneId = this.gene && this.gene._id;
9313
9333
  return (0, $gXNCa$tbrowsecore.maximalExcludedClades)(snap.tree, (leaf)=>leaf.taxonomyId != null && activeSet.has(String(leaf.taxonomyId)) || leaf.geneId === keepGeneId);
9314
9334
  }
9335
+ // The Expression zone's "expressed only" toggle (zoneStates.expression
9336
+ // .expressedOnly): while it is on and the zone is visible, prune the largest
9337
+ // branches with no leaf carrying expression attributes. The gene of interest
9338
+ // stays, as with the genome prunes, so the root is never pruned.
9339
+ getExpressionPrunedIds(vs, hostProps) {
9340
+ const zs = vs && vs.zoneStates && vs.zoneStates.expression;
9341
+ if (!zs || !zs.expressedOnly) return [];
9342
+ if (!(vs.zones || []).some((z)=>z.id === 'expression' && z.visible)) return [];
9343
+ const ea = hostProps && hostProps.hostData && hostProps.hostData.exprAttrs;
9344
+ if (!ea || !ea.byNode || !hostProps.tree) return [];
9345
+ const keepGeneId = this.gene && this.gene._id;
9346
+ return (0, $gXNCa$tbrowsecore.maximalExcludedClades)(hostProps.tree, (leaf)=>ea.byNode.hasOwnProperty(leaf.id) || leaf.geneId === keepGeneId);
9347
+ }
9348
+ // Turning "expressed only" on also expands every branch, so the expressed
9349
+ // genes left after pruning are all in view. Done here, in the same update
9350
+ // as the toggle, rather than by a second viewer action that would race it.
9351
+ expandOnExpressedOnly(prev, next) {
9352
+ const was = !!(prev && prev.zoneStates && prev.zoneStates.expression && prev.zoneStates.expression.expressedOnly);
9353
+ const is = !!(next && next.zoneStates && next.zoneStates.expression && next.zoneStates.expression.expressedOnly);
9354
+ return !was && is ? {
9355
+ ...next,
9356
+ collapsedNodeIds: []
9357
+ } : next;
9358
+ }
9315
9359
  // Seed the bundle with a pivot-computed initial tbrowse view state once the
9316
9360
  // loader has the tree and the user is actually looking at the tbrowse
9317
9361
  // viewer, from lifecycle (not render) to avoid dispatching mid-render. The
@@ -9454,12 +9498,17 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9454
9498
  },
9455
9499
  children: /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $gXNCa$reactbootstrap.Spinner), {})
9456
9500
  });
9457
- // Layer the genome-limit prune set on top of the user's own prunes for the
9458
- // controlled view state, but persist only the user's prunes (the layer
9459
- // strips the genome-derived ones in onViewStateChange) so the bundle stays
9460
- // free of filter-derived state and re-applies cleanly when the filter
9461
- // changes.
9462
- const pruneLayer = (0, $gXNCa$tbrowsecore.createDerivedPruneLayer)(this.getGenomePrunedIds());
9501
+ // Layer the genome-limit and "expressed only" prune sets on top of the
9502
+ // user's own prunes for the controlled view state, but persist only the
9503
+ // user's prunes (the layer strips the derived ones in onViewStateChange) so
9504
+ // the bundle stays free of derived state and re-applies cleanly when the
9505
+ // filter or toggle changes.
9506
+ const pruneLayer = (0, $gXNCa$tbrowsecore.createDerivedPruneLayer)([
9507
+ ...new Set([
9508
+ ...this.getGenomePrunedIds(),
9509
+ ...this.getExpressionPrunedIds(tbrowseVS, hostProps)
9510
+ ])
9511
+ ]);
9463
9512
  return /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)((0, $gXNCa$reactjsxruntime.Fragment), {
9464
9513
  children: [
9465
9514
  /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("div", {
@@ -9473,7 +9522,7 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9473
9522
  zones: this.getTbrowseZones(),
9474
9523
  nodeOfInterest: this.gene._id,
9475
9524
  viewState: pruneLayer.effective(tbrowseVS),
9476
- onViewStateChange: (next)=>this.setTbrowseViewState(pruneLayer.onChange(next)),
9525
+ onViewStateChange: (next)=>this.setTbrowseViewState(this.expandOnExpressedOnly(tbrowseVS, pruneLayer.onChange(next))),
9477
9526
  densityControls: true,
9478
9527
  defaultOpenSections: {
9479
9528
  zones: true,