Skip to content

Commit d22d68a

Browse files
committed
Search against RNAcentral
1 parent ab3cc98 commit d22d68a

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

src/containers/SequenceSearch/components/Results/index.jsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class Results extends React.Component {
2424
}
2525
}
2626

27+
submitToRnacentral(event) {
28+
event.preventDefault();
29+
const state = store.getState();
30+
state.rnacentral = true;
31+
if (state.sequence) {
32+
store.dispatch(actionCreators.onClearResult());
33+
store.dispatch(actionCreators.onSubmit(state.sequence, []));
34+
}
35+
}
36+
2737
render() {
2838
let h3Style = {
2939
color: this.props.customStyle && this.props.customStyle.h3Color ? this.props.customStyle.h3Color : "#666",
@@ -128,28 +138,31 @@ class Results extends React.Component {
128138
this.props.jobId && (this.props.status === "loading" || this.props.status === "success" || this.props.status === "partial_success") && [
129139
<div className="small-12 columns" key={`results-div`}>
130140
<h3 style={h3Style}>Similar sequences: { this.props.status === "loading" ? <i className="animated infinite flash">...</i> : <small>{ this.props.hitCount }</small> } { this.props.hits > 1000 ? <small>of { this.props.hits } <a href="https://test.rnacentral.org/help/sequence-search" style={{borderBottomStyle: "none"}} target="_blank"><i className="icon icon-generic icon-help" style={{fontSize: "70%"}}></i></a></small> : "" }</h3>
131-
<div className="small-3 columns">
132-
{ this.props.entries && this.props.entries.length ?
133-
<Facets
134-
facets={ this.props.facets }
135-
selectedFacets={ this.props.selectedFacets }
136-
toggleFacet={ this.toggleFacet }
137-
ordering={ this.props.ordering }
138-
textSearchError={ this.props.textSearchError }
139-
hideFacet={ this.props.hideFacet}
140-
customStyle={ this.props.customStyle }
141-
/> : ''}
142-
</div>
143-
<div className="small-9 columns">
144-
<section>
145-
{ this.props.entries.map((entry, index) => (
146-
<ul key={`${entry}_${index}`}><Hit entry={entry} alignmentsCollapsed={this.props.alignmentsCollapsed} onToggleAlignmentsCollapsed={this.onToggleAlignmentsCollapsed} customStyle={this.props.customStyle} databases={this.props.databases} exactMatchUrsId={exactMatchUrsId}/></ul>
147-
)) }
148-
<div className="small-12 columns">
149-
{this.props.status === "loading" ? <i className="animated infinite flash">...</i> : (this.props.status === "success" || this.props.status === "partial_success") && (this.props.entries.length < this.props.hitCount) && (<a className="button small" onClick={this.props.onLoadMore} target="_blank">Load more</a>)}
141+
{
142+
this.props.entries && this.props.entries.length ? <div>
143+
<div className="small-3 columns">
144+
<Facets
145+
facets={ this.props.facets }
146+
selectedFacets={ this.props.selectedFacets }
147+
toggleFacet={ this.toggleFacet }
148+
ordering={ this.props.ordering }
149+
textSearchError={ this.props.textSearchError }
150+
hideFacet={ this.props.hideFacet}
151+
customStyle={ this.props.customStyle }
152+
/>
150153
</div>
151-
</section>
152-
</div>
154+
<div className="small-9 columns">
155+
<section>
156+
{ this.props.entries.map((entry, index) => (
157+
<ul key={`${entry}_${index}`}><Hit entry={entry} alignmentsCollapsed={this.props.alignmentsCollapsed} onToggleAlignmentsCollapsed={this.onToggleAlignmentsCollapsed} customStyle={this.props.customStyle} databases={this.props.databases} exactMatchUrsId={exactMatchUrsId}/></ul>
158+
)) }
159+
<div className="small-12 columns">
160+
{this.props.status === "loading" ? <i className="animated infinite flash">...</i> : (this.props.status === "success" || this.props.status === "partial_success") && (this.props.entries.length < this.props.hitCount) && (<a className="button small" onClick={this.props.onLoadMore} target="_blank">Load more</a>)}
161+
</div>
162+
</section>
163+
</div>
164+
</div> : this.props.rnacentral ? <div>No results.</div> : <div>The query sequence did not match any {this.props.databases} sequences. You can <a href="#" onClick={this.submitToRnacentral}>try to search against RNAcentral</a>.</div>
165+
}
153166
</div>
154167
]
155168
}
@@ -174,6 +187,7 @@ function mapStateToProps(state) {
174187
jobList: state.jobList,
175188
infernalEntries: state.infernalEntries,
176189
exactMatch: state.exactMatch,
190+
rnacentral: state.rnacentral,
177191
};
178192
}
179193

src/reducers/rootReducer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const rootReducer = function (state = initialState, action) {
149149
}
150150

151151
case actions.UPDATE_JOB_ID:
152-
return Object.assign({}, state, {jobId: action.data});
152+
return Object.assign({}, state, {jobId: action.data, rnacentral: false});
153153

154154
case actions.CLEAR_JOB_ID:
155155
return Object.assign({}, state, {jobId: null, sequence: ""});
@@ -213,6 +213,7 @@ const rootReducer = function (state = initialState, action) {
213213
infernalStatus: "notSubmitted",
214214
infernalEntries: [],
215215
fileUpload: false,
216+
rnacentral: false,
216217
});
217218

218219
case actions.EXAMPLE_SEQUENCE:
@@ -234,6 +235,7 @@ const rootReducer = function (state = initialState, action) {
234235
infernalStatus: "notSubmitted",
235236
infernalEntries: [],
236237
fileUpload: false,
238+
rnacentral: false,
237239
});
238240

239241
case actions.CLEAR_SEQUENCE:
@@ -256,6 +258,7 @@ const rootReducer = function (state = initialState, action) {
256258
infernalEntries: [],
257259
fileUpload: false,
258260
exactMatch: null,
261+
rnacentral: false,
259262
});
260263

261264
case actions.FILE_UPLOAD:

src/store/initialState.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ let initialState = {
1313
hits: null,
1414
fileUpload: false,
1515
exactMatch: null,
16+
rnacentral: false,
1617

1718
// nhmmer search
1819
status: statusChoices.notSubmitted,

0 commit comments

Comments
 (0)