gramene-search 2.38.2 → 2.39.0

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
@@ -6351,6 +6351,9 @@ var $d365d8c287ab0c94$export$2e2bcd8739ae039 = $d365d8c287ab0c94$var$ontologyEnr
6351
6351
  // - expandedDetail: which detail tab is open in the gene-list card
6352
6352
  // - fullscreen: whether the expanded detail is full-screened
6353
6353
  // - homology.viewer: 'treevis' | 'tbrowse'
6354
+ // - homology.tree: which of the gene's trees is shown — the homology field
6355
+ // holding it ('gene_tree', or a tree set such as 'wheat'); unset = the
6356
+ // first (gene_tree when the gene has one)
6354
6357
  // - homology.height: drag-resize height of the homology detail pane
6355
6358
  // - homology.tbrowse: the tbrowse ViewState (collapsedNodeIds, prunedNodeIds,
6356
6359
  // swappedNodeIds, compressedNodeIds, nodeOfInterestId, zones, zoneStates,
@@ -6480,6 +6483,14 @@ const $7f865ea0feda21af$var$uiViewState = {
6480
6483
  return $7f865ea0feda21af$var$setHomology(state, payload.geneId, {
6481
6484
  viewer: payload.viewer
6482
6485
  });
6486
+ case 'UI_HOMOLOGY_TREE_SET':
6487
+ // payload: { geneId, tree }. The tbrowse ViewState belongs to one tree
6488
+ // (its node ids), so a switch drops it and Homology re-seeds the new
6489
+ // tree pivoted on the gene.
6490
+ return $7f865ea0feda21af$var$setHomology(state, payload.geneId, {
6491
+ tree: payload.tree,
6492
+ tbrowse: undefined
6493
+ });
6483
6494
  case 'UI_HOMOLOGY_HEIGHT_SET':
6484
6495
  // payload: { geneId, height }
6485
6496
  return $7f865ea0feda21af$var$setHomology(state, payload.geneId, {
@@ -6542,6 +6553,15 @@ const $7f865ea0feda21af$var$uiViewState = {
6542
6553
  }
6543
6554
  });
6544
6555
  },
6556
+ doSetHomologyTree: ({ geneId: geneId, tree: tree })=>({ dispatch: dispatch })=>{
6557
+ dispatch({
6558
+ type: 'UI_HOMOLOGY_TREE_SET',
6559
+ payload: {
6560
+ geneId: geneId,
6561
+ tree: tree
6562
+ }
6563
+ });
6564
+ },
6545
6565
  doSetHomologyHeight: ({ geneId: geneId, height: height })=>({ dispatch: dispatch })=>{
6546
6566
  dispatch({
6547
6567
  type: 'UI_HOMOLOGY_HEIGHT_SET',
@@ -6676,7 +6696,7 @@ var $6048209b532f201d$export$2e2bcd8739ae039 = $6048209b532f201d$var$taxTreeView
6676
6696
  // { geneId,
6677
6697
  // expandedDetail: string|null,
6678
6698
  // fullscreen: boolean,
6679
- // homology: { viewer, height, tbrowse: <ViewState> } | undefined,
6699
+ // homology: { viewer, tree, height, tbrowse: <ViewState> } | undefined,
6680
6700
  // sequences: { tab, tid, upstream, downstream } | undefined,
6681
6701
  // expression: { activeTab, atlasExperiment, jgiExperiment,
6682
6702
  // jgiAxes: { [jgiExperiment]: { rowFactor, columnFactor } },
@@ -6734,7 +6754,7 @@ const $472fe3745b238881$var$isMeaningfulGene = (entry)=>{
6734
6754
  if (!entry) return false;
6735
6755
  if (entry.expandedDetail) return true;
6736
6756
  if (entry.fullscreen) return true;
6737
- if (entry.homology && (entry.homology.viewer !== undefined || entry.homology.height !== undefined || entry.homology.tbrowse !== undefined)) return true;
6757
+ if (entry.homology && (entry.homology.viewer !== undefined || entry.homology.tree !== undefined || entry.homology.height !== undefined || entry.homology.tbrowse !== undefined)) return true;
6738
6758
  if (entry.sequences && Object.keys(entry.sequences).length) return true;
6739
6759
  if (entry.expression && Object.keys(entry.expression).length) return true;
6740
6760
  if (entry.primers && Object.keys(entry.primers).length) return true;
@@ -9074,28 +9094,38 @@ const $64fad37f770d2bfe$var$TBROWSE_BASE_ZONES = [
9074
9094
  (0, $gXNCa$tbrowse.msaZone),
9075
9095
  (0, $gXNCa$tbrowse.neighborhoodZone)
9076
9096
  ];
9077
- // A gene's tree is either the main Compara tree (homology.gene_tree) or, for
9078
- // genomes in a clade-specific tree set, homology.<tree_set> — e.g. wheat genes
9079
- // carry homology.wheat = {id: 'EplWheatGT_…'}. Solr indexes the tree id under
9080
- // the same name (gene_tree, wheat, oat, …), so `field` is also the fq field.
9081
- // Null when the gene has homologues but no tree at all.
9097
+ // A gene's trees: the main Compara tree (homology.gene_tree) and/or trees in
9098
+ // clade-specific tree sets, homology.<tree_set> — e.g. a wheat gene may carry
9099
+ // gene_tree, homology.wheat = {id: 'EplWheatGT_…'} and homology.barley. Solr
9100
+ // indexes each tree id under the same name (gene_tree, wheat, barley, …), so
9101
+ // `field` is also the fq field. gene_tree comes first; empty when the gene
9102
+ // has homologues but no tree at all.
9082
9103
  const $64fad37f770d2bfe$var$NOT_TREE_KEYS = [
9083
9104
  'homologous_genes',
9084
9105
  'supertree'
9085
9106
  ];
9086
- function $64fad37f770d2bfe$var$geneTreeRef(gene) {
9107
+ function $64fad37f770d2bfe$var$geneTreeRefs(gene) {
9087
9108
  const h = gene && gene.homology;
9088
- if (!h) return null;
9089
- if (h.gene_tree && h.gene_tree.id) return {
9090
- field: 'gene_tree',
9091
- id: h.gene_tree.id
9092
- };
9093
- const key = Object.keys(h).find((k)=>!$64fad37f770d2bfe$var$NOT_TREE_KEYS.includes(k) && h[k] && typeof h[k] === 'object' && typeof h[k].id === 'string');
9094
- return key ? {
9095
- field: key,
9096
- id: h[key].id
9097
- } : null;
9109
+ if (!h) return [];
9110
+ const isTree = (k)=>!$64fad37f770d2bfe$var$NOT_TREE_KEYS.includes(k) && h[k] && typeof h[k] === 'object' && typeof h[k].id === 'string';
9111
+ const keys = Object.keys(h).filter(isTree);
9112
+ keys.sort((a, b)=>a === 'gene_tree' ? -1 : b === 'gene_tree' ? 1 : 0);
9113
+ return keys.map((field)=>({
9114
+ field: field,
9115
+ id: h[field].id,
9116
+ rootTaxonName: h[field].root_taxon_name
9117
+ }));
9118
+ }
9119
+ // The tree to show: the one picked in the switcher (`field`), else the first.
9120
+ function $64fad37f770d2bfe$var$geneTreeRef(gene, field) {
9121
+ const refs = $64fad37f770d2bfe$var$geneTreeRefs(gene);
9122
+ return refs.find((r)=>r.field === field) || refs[0] || null;
9098
9123
  }
9124
+ // Switcher label: the tree set and the clade the tree is rooted at.
9125
+ const $64fad37f770d2bfe$var$treeLabel = (ref)=>{
9126
+ const set = ref.field === 'gene_tree' ? 'Compara' : ref.field.charAt(0).toUpperCase() + ref.field.slice(1);
9127
+ return ref.rootTaxonName ? `${set} \xb7 ${ref.rootTaxonName}` : set;
9128
+ };
9099
9129
  class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$react))).Component {
9100
9130
  constructor(props){
9101
9131
  super(props);
@@ -9132,6 +9162,10 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9132
9162
  getViewer() {
9133
9163
  return this.getHomologySlice().viewer || 'tbrowse';
9134
9164
  }
9165
+ // The gene's selected tree (see the tree switcher in renderViewerToggle).
9166
+ selectedTreeRef(gene) {
9167
+ return $64fad37f770d2bfe$var$geneTreeRef(gene, this.getHomologySlice().tree);
9168
+ }
9135
9169
  // The genome (gene-structure) zone is opt-in per site via
9136
9170
  // `enable_tbrowse_genome_zone` (defaults to false).
9137
9171
  isGenomeZoneEnabled() {
@@ -9155,6 +9189,12 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9155
9189
  const h = this.getHomologySlice().height;
9156
9190
  return typeof h === 'number' ? h : 600;
9157
9191
  }
9192
+ setTree(field) {
9193
+ this.props.doSetHomologyTree({
9194
+ geneId: this.getGeneId(),
9195
+ tree: field
9196
+ });
9197
+ }
9158
9198
  setViewer(viewer) {
9159
9199
  this.props.doSetHomologyViewer({
9160
9200
  geneId: this.getGeneId(),
@@ -9218,7 +9258,7 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9218
9258
  const id = this.getGeneId();
9219
9259
  if (!this.props.geneDocs.hasOwnProperty(id)) return;
9220
9260
  const gene = this.props.geneDocs[id];
9221
- const ref = $64fad37f770d2bfe$var$geneTreeRef(gene);
9261
+ const ref = this.selectedTreeRef(gene);
9222
9262
  if (!ref) return;
9223
9263
  const treeId = ref.id;
9224
9264
  const raw = this.props.grameneTrees[treeId];
@@ -9270,7 +9310,7 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9270
9310
  const id = this.getGeneId();
9271
9311
  if (!this.props.geneDocs.hasOwnProperty(id)) return;
9272
9312
  const gene = this.props.geneDocs[id];
9273
- const ref = $64fad37f770d2bfe$var$geneTreeRef(gene);
9313
+ const ref = this.selectedTreeRef(gene);
9274
9314
  if (!ref) return;
9275
9315
  const treeId = ref.id;
9276
9316
  const raw = this.props.grameneTrees[treeId];
@@ -9566,13 +9606,52 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9566
9606
  },
9567
9607
  children: label
9568
9608
  }, id);
9609
+ // A second row when the gene sits in more than one tree (e.g. a wheat
9610
+ // gene in the Compara, wheat and barley trees).
9611
+ const refs = $64fad37f770d2bfe$var$geneTreeRefs(this.gene);
9612
+ const treeBtn = (ref)=>/*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("button", {
9613
+ type: "button",
9614
+ title: ref.id,
9615
+ onClick: ()=>this.setTree(ref.field),
9616
+ style: {
9617
+ padding: '4px 10px',
9618
+ marginRight: 4,
9619
+ fontSize: 12,
9620
+ border: '1px solid #ccc',
9621
+ background: this.treeRef.field === ref.field ? '#2878dc' : '#fff',
9622
+ color: this.treeRef.field === ref.field ? '#fff' : '#222',
9623
+ cursor: 'pointer',
9624
+ borderRadius: 3
9625
+ },
9626
+ children: $64fad37f770d2bfe$var$treeLabel(ref)
9627
+ }, ref.field);
9569
9628
  return /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("div", {
9570
9629
  style: {
9571
9630
  margin: '8px 0'
9572
9631
  },
9573
9632
  children: [
9574
- btn('tbrowse', 'TBrowse'),
9575
- btn('treevis', 'TreeVis')
9633
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("div", {
9634
+ children: [
9635
+ btn('tbrowse', 'TBrowse'),
9636
+ btn('treevis', 'TreeVis')
9637
+ ]
9638
+ }),
9639
+ refs.length > 1 && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("div", {
9640
+ className: "homology-tree-switcher",
9641
+ style: {
9642
+ marginTop: 6
9643
+ },
9644
+ children: [
9645
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("span", {
9646
+ style: {
9647
+ fontSize: 12,
9648
+ marginRight: 6
9649
+ },
9650
+ children: "Gene tree:"
9651
+ }),
9652
+ refs.map(treeBtn)
9653
+ ]
9654
+ })
9576
9655
  ]
9577
9656
  });
9578
9657
  }
@@ -9677,7 +9756,10 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9677
9756
  const id = this.props.searchResult.id;
9678
9757
  if (!this.props.geneDocs.hasOwnProperty(id)) return /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $gXNCa$reactbootstrap.Spinner), {});
9679
9758
  this.gene = this.props.geneDocs[id];
9680
- this.treeRef = $64fad37f770d2bfe$var$geneTreeRef(this.gene);
9759
+ this.treeRef = this.selectedTreeRef(this.gene);
9760
+ // Recomputed below only once the selected tree has loaded, so a switch to
9761
+ // a tree still in flight never draws the previous one.
9762
+ this.tree = undefined;
9681
9763
  if (!this.treeRef) {
9682
9764
  // Homologues but no tree (some pan-genome assemblies): offer the
9683
9765
  // ortholog/paralog searches instead of a phylogram.
@@ -9716,10 +9798,10 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9716
9798
  /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $5c2c79352d3d7b81$export$393edc798c47379d), {
9717
9799
  children: "This phylogram shows the relationships between this gene and others similar to it, as determined by Ensembl Compara."
9718
9800
  }, "description"),
9719
- this.tree && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)((0, $5c2c79352d3d7b81$export$7c6e2c02157bb7d2), {
9801
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)((0, $5c2c79352d3d7b81$export$7c6e2c02157bb7d2), {
9720
9802
  children: [
9721
9803
  this.renderViewerToggle(),
9722
- this.getViewer() === 'tbrowse' ? this.renderTBrowse() : this.renderTreeVis()
9804
+ !this.tree ? /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $gXNCa$reactbootstrap.Spinner), {}) : this.getViewer() === 'tbrowse' ? this.renderTBrowse() : this.renderTreeVis()
9723
9805
  ]
9724
9806
  }, "content"),
9725
9807
  this.tree && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)((0, $5c2c79352d3d7b81$export$900f1bfcd1cb6476), {
@@ -9732,7 +9814,7 @@ class $64fad37f770d2bfe$var$Homology extends (0, ($parcel$interopDefault($gXNCa$
9732
9814
  });
9733
9815
  }
9734
9816
  }
9735
- var $64fad37f770d2bfe$export$2e2bcd8739ae039 = (0, $gXNCa$reduxbundlerreact.connect)('selectGrameneTaxonomy', 'selectGrameneTrees', 'selectGrameneGenomes', 'selectGrameneAPI', 'selectConfiguration', 'selectCuration', 'selectUiViewState', 'doRequestGrameneTree', 'doSetHomologyViewer', 'doSetHomologyHeight', 'doSetHomologyTbrowseViewState', 'doAcceptGrameneSuggestion', 'doReplaceGrameneFilters', $64fad37f770d2bfe$var$Homology);
9817
+ var $64fad37f770d2bfe$export$2e2bcd8739ae039 = (0, $gXNCa$reduxbundlerreact.connect)('selectGrameneTaxonomy', 'selectGrameneTrees', 'selectGrameneGenomes', 'selectGrameneAPI', 'selectConfiguration', 'selectCuration', 'selectUiViewState', 'doRequestGrameneTree', 'doSetHomologyViewer', 'doSetHomologyTree', 'doSetHomologyHeight', 'doSetHomologyTbrowseViewState', 'doAcceptGrameneSuggestion', 'doReplaceGrameneFilters', $64fad37f770d2bfe$var$Homology);
9736
9818
 
9737
9819
 
9738
9820