gramene-search 1.6.27 → 1.6.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gramene-search",
3
- "version": "1.6.27",
3
+ "version": "1.6.29",
4
4
  "description": "search wrapper for gramene",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -43,7 +43,6 @@
43
43
  "querystringify": "^2.2.0",
44
44
  "react": "^17.0.2",
45
45
  "react-bootstrap": "^2.7.2",
46
- "react-bootstrap-typeahead": "^6.4.1",
47
46
  "react-debounce-input": "^3.2.5",
48
47
  "react-dom": "17.0.2",
49
48
  "react-ga4": "^2.1.0",
@@ -478,6 +478,43 @@ const grameneOrthologs = {
478
478
  selectGrameneOrthologs: state => state.grameneOrthologs
479
479
  };
480
480
 
481
+ const grameneParalogs = {
482
+ name: 'grameneParalogs',
483
+ getReducer: () => {
484
+ const initialState = {};
485
+ return (state = initialState, {type, payload}) => {
486
+ let newState;
487
+ switch (type) {
488
+ case 'GRAMENE_PARALOGS_REQUESTED':
489
+ if (!state.hasOwnProperty(payload)) {
490
+ newState = Object.assign({}, state);
491
+ newState[payload] = [];
492
+ return newState;
493
+ }
494
+ break;
495
+ case 'GRAMENE_PARALOGS_RECEIVED':
496
+ return Object.assign({}, state, payload);
497
+ }
498
+ return state;
499
+ }
500
+ },
501
+ doRequestParalogs: (geneId,supertree,taxon_id) => ({dispatch, store}) => {
502
+ const paralogs = store.selectGrameneParalogs();
503
+ if (!paralogs.hasOwnProperty(geneId)) {
504
+ dispatch({type: 'GRAMENE_PARALOGS_REQUESTED', payload: geneId});
505
+ const API = store.selectGrameneAPI();
506
+ const q= supertree ? `supertree_attr_s:${supertree}` : `homology__within_species_paralog:${geneId}`;
507
+ fetch(`${API}/search?q=${q}&rows=100&fq=taxon_id:${taxon_id}`)
508
+ .then(res => res.json())
509
+ .then(res => {
510
+ let newParalogs = {};
511
+ newParalogs[geneId] = res.response.docs.map(d => d.id);
512
+ dispatch({type: 'GRAMENE_PARALOGS_RECEIVED', payload: newParalogs})
513
+ })
514
+ }
515
+ },
516
+ selectGrameneParalogs: state => state.grameneParalogs
517
+ };
481
518
 
482
519
  // function selectFacetIDs(store, field) {
483
520
  // const path = `grameneGenes.data.facet_counts.facet_fields.${field}`;
@@ -534,4 +571,4 @@ const grameneOrthologs = {
534
571
  // });
535
572
 
536
573
 
537
- export default [grameneSuggestions, grameneSearch, grameneMaps, grameneTaxonomy, grameneTaxDist, grameneOrthologs, curatedGenes, grameneGermplasm, grameneGeneAttribs, expressionSamples, expressionStudies];
574
+ export default [grameneSuggestions, grameneSearch, grameneMaps, grameneTaxonomy, grameneTaxDist, grameneOrthologs, grameneParalogs, curatedGenes, grameneGermplasm, grameneGeneAttribs, expressionSamples, expressionStudies];
@@ -1,9 +1,6 @@
1
1
  import React, { useRef, useEffect, useState } from 'react'
2
2
  import {connect} from "redux-bundler-react";
3
3
  import {Tabs, Tab, Form, Row, Col} from 'react-bootstrap';
4
- import { Typeahead } from 'react-bootstrap-typeahead'; // ES2015
5
- // Import as a module in your JS
6
- import 'react-bootstrap-typeahead/css/Typeahead.css';
7
4
  import BAR, {haveBAR} from "gramene-efp-browser";
8
5
 
9
6
  function DynamicIframe(props) {
@@ -63,28 +60,29 @@ const Detail = props => {
63
60
  }, [props.expressionStudies]);
64
61
 
65
62
  let paralogs_url;
66
- let gene_url = `https://dev.gramene.org/static/atlasWidget.html?genes=${gene.atlas_id || gene._id}&experiment=${atlasExperiment}&localAPI=${isLocal}`;
63
+ let gene_url = `https://dev.gramene.org/static/atlasWidget.html?genes=${gene.atlas_id || gene._id}&localAPI=${isLocal}`;
67
64
  let paralogs = [];
68
- if (gene.homology && gene.homology.homologous_genes && gene.homology.homologous_genes.within_species_paralog) {
69
- paralogs = gene.homology.homologous_genes.within_species_paralog;
65
+ if (props.grameneParalogs && props.grameneParalogs[gene._id]) {
66
+ paralogs = props.grameneParalogs[gene._id];
67
+ } else {
68
+ props.doRequestParalogs(gene._id, gene.homology.supertree, gene.taxon_id);
70
69
  }
70
+ // if (gene.homology && gene.homology.homologous_genes && gene.homology.homologous_genes.within_species_paralog) {
71
+ // paralogs = gene.homology.homologous_genes.within_species_paralog;
72
+ // }
71
73
  if (paralogs.length > 1 && atlasExperiment) {
72
74
  paralogs_url= `https://dev.gramene.org/static/atlasWidget.html?genes=${paralogs.join(' ')}&experiment=${atlasExperiment}&localAPI=${isLocal}`;
73
75
  }
74
- const ref = useRef(null);
75
- const ref2 = useRef(null);
76
76
  return <Tabs>
77
77
  {paralogs_url &&
78
78
  <Tab tabClassName="gxa" eventKey="paralogs" title={`Paralogs`} key="gxaparalogs">
79
- <Typeahead clearButton size='sm'
80
- id="experiment-selector"
81
- ref={ref}
82
- labelKey="experiment"
83
- onChange={(exps) => {if (exps.length > 0) {setAtlasExperiment(exps[0]._id);setTimeout(() => ref.current?.clear(), 2000)}}}
84
- placeholder="Choose an experiment..."
85
- options={atlasExperimentList}
86
- labelKey={(experiment) => `${experiment.type}: ${experiment.description || experiment._id}`}
87
- />
79
+ <Form.Select aria-label='experiment selector'
80
+ placeholder='Select experiment'
81
+ onChange={(e) => setAtlasExperiment(e.target.value)}>
82
+ { atlasExperimentList.map((e,idx) =>
83
+ <option key={idx} value={e._id}>{e.type}: {e.description || e._id}</option>
84
+ )}
85
+ </Form.Select>
88
86
  <DynamicIframe url={paralogs_url}/>
89
87
  </Tab>
90
88
  }
@@ -96,15 +94,6 @@ const Detail = props => {
96
94
  {/* checked={isLocal}*/}
97
95
  {/* onChange={handleLocalAPIChange}*/}
98
96
  {/*/>*/}
99
- <Typeahead clearButton size='sm'
100
- id="experiment-selector2"
101
- ref={ref}
102
- labelKey="experiment"
103
- onChange={(exps) => {if (exps.length > 0) {setAtlasExperiment(exps[0]._id);setTimeout(() => ref.current?.clear(), 2000)}}}
104
- placeholder="Choose an experiment..."
105
- options={atlasExperimentList}
106
- labelKey={(experiment) => `${experiment.type}: ${experiment.description || experiment._id}`}
107
- />
108
97
  <DynamicIframe url={gene_url}/>
109
98
  </Tab>
110
99
  {haveBAR(gene) &&
@@ -114,8 +103,9 @@ const Detail = props => {
114
103
  };
115
104
 
116
105
  export default connect(
117
- //'selectParalogExpression',
106
+ 'selectGrameneParalogs',
118
107
  'selectExpressionStudies',
108
+ 'doRequestParalogs',
119
109
  //'doRequestParalogExpression',
120
110
  Detail
121
111
  );
@@ -57,6 +57,14 @@ class Homology extends React.Component {
57
57
  name: `Paralogs of ${this.gene.name}`
58
58
  }))
59
59
  }
60
+ searchSupertree() {
61
+ this.props.doReplaceGrameneFilters(suggestionToFilters({
62
+ category: 'Gene Tree',
63
+ fq_field: 'supertree_attr_s',
64
+ fq_value: this.gene.homology.supertree,
65
+ name: this.gene.homology.supertree
66
+ }))
67
+ }
60
68
  orthologList() {
61
69
  return this.orthoParaList('ortholog');
62
70
  }
@@ -112,6 +120,14 @@ class Homology extends React.Component {
112
120
  handleClick: this.filterParalogs.bind(this)
113
121
  });
114
122
  }
123
+ if (this.gene.homology.supertree) {
124
+ x.push({
125
+ name: `Supertree`,
126
+ category: `Gene Tree`,
127
+ count: this.gene.homology.supertree,
128
+ handleClick: this.searchSupertree.bind(this)
129
+ })
130
+ }
115
131
  return x;
116
132
  }
117
133
  links() {