Skip to content

Commit

Permalink
Merge pull request #893 from BV-BRC/beta
Browse files Browse the repository at this point in the history
Prod update Oct 17 2024
  • Loading branch information
olsonanl authored Oct 17, 2024
2 parents 615621f + 35dbb3a commit 2c281bf
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p3-web",
"version": "3.40.2",
"version": "3.41.1",
"private": true,
"scripts": {
"start": "node ./bin/p3-web",
Expand Down
5 changes: 4 additions & 1 deletion public/js/p3/widget/AdvancedSearchFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,10 @@ define([], function () {
},
{
field: 'segment', type: 'str', facet: true, facet_hidden: false, search: true
}
},
{
field: 'additional_metadata', type: 'str', facet: true, facet_hidden: false, search: true
},
],
'subsystem': [
{
Expand Down
4 changes: 3 additions & 1 deletion public/js/p3/widget/SFVTGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ define([
sf_category: {label: 'SF Category', field: 'sf_category', hidden: false},
segments: {label: 'Reference Positions', field: 'segments', hidden: false},
source_strain: {label: 'Source Strain', field: 'source_strain', hidden: false},
product: {label: 'Product', field: 'product', hidden: false},

additional_metadata: {label: 'Additional Metadata', field: 'additional_metadata', hidden: true},
segment: {label: 'Segment', field: 'segment', hidden: true},
subtype: {label: 'Subtype', field: 'subtype', hidden: true},
comments: {label: 'Comments', field: 'comments', hidden: true},
comments: {label: 'Comments', field: 'comments', hidden: true}
//feature_type: {label: 'Evidence', field: 'feature_type', hidden: false}
},
startup: function () {
Expand Down
114 changes: 105 additions & 9 deletions public/js/p3/widget/search/SFVTSearch.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define([
'dojo/_base/declare', 'dojo/_base/lang', 'dojo/store/Memory', 'dojo/text!./templates/SFVTSearch.html', 'dojo/query',
'./TextInputEncoder', './SearchBase', './FacetStoreBuilder', './PathogenGroups', '../../util/PathJoin', 'dojo/request/xhr',
'dijit/Dialog', 'dojo/on'
'dijit/Dialog', 'dojo/on', 'dojo/when', 'dojo/dom-construct'
], function (
declare, lang, Memory, template, query,
TextInputEncoder, SearchBase, storeBuilder, pathogenGroupStore, PathJoin, xhr,
Dialog, on
Dialog, on, when, domConstruct
) {

const influenzaSegmentMapping = {
Expand All @@ -22,6 +22,10 @@ define([
'NS2': '8'
};

const otherPathogenGroups = {
'10244': 'Monkeypox virus'
};

function sanitizeInput(str) {
return str.replace(/\(|\)|\.|\*|\||\[|\]/g, '');
}
Expand All @@ -42,6 +46,7 @@ define([
segmentOptions: ['11320'],
sfvtSequenceErrorMessage: 'There are too many Sequence Feature hits. Please refine Sequence Feature Variant Type Sequence pattern to narrow down the results.',
sfvtMaxLimit: 300,
mpoxGeneProductMapping: {},

startup: function () {
let sfvtSeqSearchButton = query('#sfvt-seq-search')[0];
Expand Down Expand Up @@ -80,12 +85,23 @@ define([
postCreate: function () {
this.inherited(arguments);

this.additionalMetadataNode.addOption([
{
value: 'Clade I',
label: 'Clade I'
}, {
value: 'Clade II',
label: 'Clade II'
}
]);
storeBuilder('sequence_feature', 'taxon_id').then(lang.hitch(this, (store) => {
// Display correct names based on taxon id
for (let item of store.data) {
const taxon = pathogenGroupStore.data.find(pathogen => pathogen.id == item.id);
if (taxon) {
item.name = taxon.name;
} else if (otherPathogenGroups[item.id]) {
item.name = otherPathogenGroups[item.id];
}
}
this.pathogenGroupNode.store = store;
Expand All @@ -103,6 +119,27 @@ define([
});
}
}));

// Retrieve product values for gene
let self = this;
when(xhr.post(PathJoin(window.App.dataAPI, '/sequence_feature/'), {
handleAs: 'json',
headers: {
Accept: 'application/solr+json',
'Content-Type': 'application/solrquery+x-www-form-urlencoded',
'X-Requested-With': null,
Authorization: (window.App.authorizationToken || '')
},
data: 'q=taxon_id:10244&fl=gene,product&group=true&group.field=gene'
}), function (response) {
if (response && response.grouped && response.grouped.gene) {
response.grouped.gene.groups.forEach(group => {
const gene = group.groupValue;
const product = group.doclist.docs[0].product;
self.mpoxGeneProductMapping[gene] = product;
});
}
});
},

onPathogenChange: function () {
Expand All @@ -118,6 +155,10 @@ define([
this.subtypeNNode.reset();
this.geneNode.set('options', []);
this.geneNode.reset();
this.additionalMetadataNode.set('value', []);
this.additionalMetadataNode._updateSelection();
//this.additionalMetadataNode.set('options', []);
//this.additionalMetadataNode.reset();

//Update virus type multi select values with selected pathogen
const condition = 'taxon_id:' + taxonId;
Expand Down Expand Up @@ -150,33 +191,79 @@ define([
}));

storeBuilder('sequence_feature', 'gene', condition).then(lang.hitch(this, (store) => {
let geneOptions = []
let geneOptions = [];
for (let item of store.data) {
const segmentNo = influenzaSegmentMapping[item.name];
geneOptions.push(
{
value: item.name,
label: segmentNo ? `${segmentNo} / ${item.name}` : item.name
});
if (taxonId === this.defaultTaxonId) { // Influenza
const segmentNo = influenzaSegmentMapping[item.name];
geneOptions.push(
{
value: item.name,
label: segmentNo ? `${segmentNo} / ${item.name}` : item.name
});
} else {
const product = this.mpoxGeneProductMapping[item.name];
geneOptions.push(
{
value: item.name,
label: product ? `${item.name} - ${product}` : item.name
});
}
}

geneOptions.sort((a, b) => a.label.localeCompare(b.label));

this.geneNode.addOption(geneOptions);
}));

const customFilters = query('.customFilter');
if (this.segmentOptions.includes(taxonId)) {
const options = query('#options1')[0];
customFilters.forEach(function (container) {
domConstruct.place(container, options, 'last');
});

query('.proteinOptions').style('display', 'none');
query('.segmentOptions').style('display', 'block');
} else {
const options = query('#options2')[0];
customFilters.forEach(function (container) {
domConstruct.place(container, options, 'last');
});

query('.segmentOptions').style('display', 'none');
query('.proteinOptions').style('display', 'block');
}

// Specific monkeypox option
if (taxonId === '10244') {
/*storeBuilder('sequence_feature', 'additional_metadata', condition).then(lang.hitch(this, (store) => {
let metadataOptions = [];
for (let item of store.data) {
metadataOptions.push({
value: item.name,
label: item.name
});
}
this.additionalMetadataNode.addOption(metadataOptions);
}));*/

query('.monkeypox').style('display', 'block');
} else {
query('.monkeypox').style('display', 'none');
}

query('.sfvtOptions').style('display', 'block');
query('#pathogenInfoDiv').style('display', 'none');
},

buildDefaultColumns: function () {
const taxonId = this.pathogenGroupNode.value;

// Reorganize table columns for Monkeypox virus
return taxonId === '10244' ? '-source_strain,additional_metadata' : '';
},

buildFilter: async function () {
this.sfvtSequenceMessage.innerHTML = '';

Expand Down Expand Up @@ -250,6 +337,15 @@ define([
sfQueryArr.push(`in(sf_category,(${sequenceFeatureTypeValue.join(',')}))`);
}

const additionalMetadataValue = this.additionalMetadataNode.get('value');
if (additionalMetadataValue.length === 1) {
filterArr.push(`eq(additional_metadata,"${TextInputEncoder(sanitizeInput(additionalMetadataValue[0]))}")`);
sfQueryArr.push(`eq(additional_metadata,${TextInputEncoder(sanitizeInput(additionalMetadataValue[0]))})`);
} else if (additionalMetadataValue.length > 1) {
filterArr.push(`or(${additionalMetadataValue.map(v => `eq(additional_metadata,"${TextInputEncoder(sanitizeInput(v))}")`)})`);
sfQueryArr.push(`in(additional_metadata,(${additionalMetadataValue.join(',')}))`);
}

/*const startValue = parseInt(this.aaCoordinatesStartNode.get('value'));
if (!isNaN(startValue)) {
// gt
Expand Down
6 changes: 6 additions & 0 deletions public/js/p3/widget/search/SearchBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ define([
},
buildFilter: function () {
},
buildDefaultColumns: function () {
},
_buildAdvancedQuery: function () {
return Object.keys(this._Searches).map((idx) => {
const col = this._Searches[idx]
Expand Down Expand Up @@ -143,11 +145,15 @@ define([

const query = this.buildQuery();
const filter = await this.buildFilter();
const defaultColumns = this.buildDefaultColumns();

let url = this.resultUrlBase + query + this.resultUrlHash;
if (filter) {
url += '&filter=' + filter;
}
if (defaultColumns) {
url += '&defaultColumns=' + defaultColumns;
}
Topic.publish('/navigate', { href: url });
}
})
Expand Down
30 changes: 25 additions & 5 deletions public/js/p3/widget/search/templates/SFVTSearch.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.dojoxCheckedMultiSelectWrapper {
width: 100%;
height: 100% !important;
max-height: 250px;
}
</style>
<div class="appTemplate">
Expand Down Expand Up @@ -54,21 +55,24 @@ <h3>${searchAppName}</h3>
data-dojo-attach-point="virusTypeNode" multiple style="height: 100%"></select>
</div>
</div>-->
<div class="appFieldLong" style="display: flex;">
<div class="appFieldLong" style="display: flex;" id="options1">
<div style="box-sizing: border-box;margin-right: 50px;min-width: 120px;">
<div class="headerrow segmentOptions">
<label class="appBoxLabel">Segment / Protein</label>
</div>
<div class="headerrow proteinOptions">
<label class="appBoxLabel">Gene - Protein</label>
</div>
<div class="appRow">
<div class="appFieldLong">
<select data-dojo-type="dojox/form/CheckedMultiSelect" name="genes"
data-dojo-props="disabled:false"
data-dojo-attach-event="onChange: onSegmentChange"
data-dojo-attach-point="geneNode" multiple style="height: 100%"></select>
data-dojo-attach-point="geneNode" multiple style="height: 100%;"></select>
</div>
</div>
</div>
<div style="flex: 1; box-sizing: border-box;">
<div id="sequenceFeatureType" class="customFilter" style="flex: 1; box-sizing: border-box;">
<div class="headerrow">
<label class="appBoxLabel">Sequence Feature Type</label>
</div>
Expand All @@ -81,7 +85,21 @@ <h3>${searchAppName}</h3>
</div>
</div>
</div>
<div id="cladeType" class="monkeypox customFilter" style="flex: 1; box-sizing: border-box;">
<div class="headerrow ">
<label class="appBoxLabel">Clade</label>
</div>
<div class="appRow monkeypox">
<div class="appFieldLong">
<select data-dojo-type="dojox/form/CheckedMultiSelect" name="additional_metadata"
data-dojo-props="disabled:false"
data-dojo-attach-point="additionalMetadataNode" multiple
style="height: 100%"></select>
</div>
</div>
</div>
</div>
<div class="appFieldLong" style="display: flex;" id="options2"></div>
<div class="headerrow subtypeOptions" style="display: none;">
<label class="appBoxLabel">Subtype</label>
</div>
Expand Down Expand Up @@ -114,7 +132,8 @@ <h3>${searchAppName}</h3>
<div class="appFieldLong">
<div data-dojo-type="dijit/form/TextBox" data-dojo-props="placeHolder:'eg. *RERE*'"
data-dojo-attach-point="sfvtSequenceNode" name="sfvtSequence" style="width: 500px"></div>
<div class="warning" data-dojo-attach-point="sfvtSequenceMessage" style="font-size: 0.9em"></div>
<div class="warning" data-dojo-attach-point="sfvtSequenceMessage"
style="font-size: 0.9em"></div>
</div>
</div>
<!--<div class="headerrow">
Expand All @@ -141,7 +160,8 @@ <h3>${searchAppName}</h3>
<div class="appSubmissionArea sfvtOptions" style="display: none;">
<div style="margin-top: 10px; text-align:center;">
<div data-dojo-type="dijit/form/Button"
data-dojo-attach-event="onClick: onReset">Reset</div>
data-dojo-attach-event="onClick: onReset">Reset
</div>
<div data-dojo-attach-point="submitButton"
type="submit" data-dojo-type="dijit/form/Button">Search
</div>
Expand Down
3 changes: 2 additions & 1 deletion public/js/p3/widget/viewer/Taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ define([
}

// SFVT
if (this.taxonomy.lineage_names.includes('Influenza A virus')) {
if (this.taxonomy.lineage_names.includes('Influenza A virus') ||
this.taxonomy.lineage_names.includes('Monkeypox virus')) {
if (!this.sfvt) {
this.viewer.addChild(this.sfvt);
}
Expand Down
2 changes: 0 additions & 2 deletions views/pages/team.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
<li>Roshni Bhattacharya</li>
<li>Anna Capria</li>
<li>Mehmet Kuscuoglu</li>
<li>Jian Lu</li>
<li>Catherine Macken</li>
<li>Lucy Stewart</li>
<li>Gene Tan</li>
<li>Christian Zmasek</li>
Expand Down

0 comments on commit 2c281bf

Please sign in to comment.