Skip to content

Commit

Permalink
blast results : add .values { }
Browse files Browse the repository at this point in the history
this relates to upload-table.js, and to transient.js : showFeatures() -> .pushFeature(), and to backend tableUpload().
dataset.js : tableUpload() : data.features.forEach : include feature.values if defined.
blast-results-view.js : extend columnsKeyString to cover all columns (after pos,end).
didReceiveAttrs(): use this.registerDataPipe to connect validateData().
dataFeatures() : place the remainder of the columns, after the required/standard columns name/chr/pos/end, into feature.values.

blast-results.js : move store,auth here from blast-results-view.js.
blast-results.hbs : pass registerDataPipe to blast-results-view.
upload-table.js : submitFile() : .validateData() may be defined via .dataPipe.
  • Loading branch information
Don-Isdale committed Jun 10, 2021
1 parent 922a918 commit e62a521
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
8 changes: 6 additions & 2 deletions backend/common/models/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,16 @@ module.exports = function(Dataset) {
if (feature.end !== undefined) {
value.push(feature.end);
}
array_features.push({
let f = {
name: feature.name,
value,
value_0: feature.val,
blockId: blocks_by_name[feature.block]
});
};
if (feature.values) {
f.values = feature.values;
}
array_features.push(f);
});
// create new features
return models.Feature.create(array_features);
Expand Down
41 changes: 35 additions & 6 deletions frontend/app/components/panel/upload/blast-results-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ const tableHeight = 500; // pixels
* This also aligns with createTable() : colHeaders below.
*/
const columnsKeyString = [
'name', 'chr', 'pcIdentity', 'lengthOfHspHit', 'numMismatches', 'numGaps', 'queryStart', 'queryEnd', 'pos', 'end'
'name', // query ID
'chr', // subject ID
'pcIdentity', // % identity
'lengthOfHspHit', // length of HSP (hit)
'numMismatches', // # mismatches
'numGaps', // # gaps
'queryStart', // query start
'queryEnd', // query end
'pos', // subject start
'end', // subject end
'eValue', // e-value
'score', // score
'queryLength', // query length
'subjectLength', // subject length
];
/** Identify the columns of dataFeatures and dataMatrix.
*/
Expand All @@ -43,11 +56,6 @@ const t_view = 0;
*/
export default Component.extend({

/** Similar comment to data-csv.js applies re. store (user could select server via GUI).
* store is used by upload-table.js : getDatasetId() and submitFile()
*/
store : alias('apiServers.primaryServer.store'),
auth: service('auth'),
transient : service('data/transient'),

/*--------------------------------------------------------------------------*/
Expand All @@ -61,12 +69,18 @@ export default Component.extend({

didReceiveAttrs() {
this._super(...arguments);

let promise = this.get('search.promise');
if (promise) {
promise.catch(() => {
this.set('statusMessage', 'The search did not complete');
});
}

/** not clear yet where addDataset functionality will end up, so wire this up for now. */
this.registerDataPipe({
validateData: () => this.validateData()
});
},

/*--------------------------------------------------------------------------*/
Expand Down Expand Up @@ -121,6 +135,21 @@ export default Component.extend({
if (row[c_end] !== undefined) {
feature.end = Number(row[c_end]);
}
// place the remainder of the columns into feature.values
feature.values = row.reduce((v, c, i) => {
switch (i) {
case c_name:
case c_chr:
case c_pos:
case c_end:
break;
default:
v[columnsKeyString[i]] = c;
break;
}
return v;
}, {});

return feature;
});
dLog('dataFeatures', features.length, features[0]);
Expand Down
13 changes: 12 additions & 1 deletion frontend/app/components/panel/upload/blast-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ const dLog = console.debug;
* /Feature/dnaSequenceSearch
*/
export default Component.extend({
/*--------------------------------------------------------------------------*/
// support for upload-table

/** Similar comment to data-csv.js applies re. store (user could select server via GUI).
* store is used by upload-table.js : getDatasetId() and submitFile()
*/
store : alias('apiServers.primaryServer.store'),
auth: service('auth'), // used by upload-table.js : submitFile()

/*--------------------------------------------------------------------------*/

apiServers: service(),
blockService : service('data/block'),
queryParams: service('query-params'),
Expand Down Expand Up @@ -150,7 +161,7 @@ export default Component.extend({
*/
unviewDataset(datasetName) {
let
store = this.get('apiServers').get('primaryServer').get('store'),
store = this.get('store'),
replacedDataset = store.peekRecord('dataset', datasetName);
if (replacedDataset) {
let
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
{{panel/upload/blast-results-view
viewDataset=viewDataset
search=search data=data active=active tableVisible=tableVisible tableModal=tableModal
registerDataPipe=(action (mut this.dataPipe))
}}
{{/ember-wormhole}}

Expand Down
4 changes: 3 additions & 1 deletion frontend/app/utils/panel/upload-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export default {
that.set('nameWarning', null);
var table = that.get('table');
// 1. Check data and get cleaned copy
that.validateData()
let validateData = (that.validateData && (() => that.validateData())) ||
(that.dataPipe.validateData && (() => that.dataPipe.validateData()));
validateData()
.then((features) => {
if (features.length > 0) {
// 2. Get new or selected dataset name
Expand Down

0 comments on commit e62a521

Please sign in to comment.