diff --git a/CHANGELOG.md b/CHANGELOG.md index 14fe05c5..674e743f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +## [0.4.11] 2023-11-29 + +### Added + +- Added 'annotation_field" config option, for external ES search +- Added redirection from Gene subentity to Gene in url + + ## [0.4.10] 2023-11-23 ### Added diff --git a/config.json.template b/config.json.template index 8abc5b85..6c878fb4 100644 --- a/config.json.template +++ b/config.json.template @@ -13,6 +13,7 @@ "externalSearchOptions": { "url": "http://0.0.0.0:80", "gene_field": "gene_id", + "annotation_field": "annotation", "query_param": "q", "field_param": "display_fields", "count_param": "max_results" diff --git a/imports/api/publications.js b/imports/api/publications.js index 16a3e58b..a3387300 100644 --- a/imports/api/publications.js +++ b/imports/api/publications.js @@ -86,6 +86,7 @@ Meteor.publish({ let url = config.externalSearchOptions.url.replace(/,+$/, "") + "/"; let paramsDict = {} let geneField = config.externalSearchOptions.gene_field ? config.externalSearchOptions.gene_field : "geneId" + let annotationField = config.externalSearchOptions.annotation_field ? config.externalSearchOptions.annotation_field : "" if (config.externalSearchOptions.query_param){ paramsDict[config.externalSearchOptions.query_param] = query.query } else { @@ -93,6 +94,9 @@ Meteor.publish({ } if (config.externalSearchOptions.field_param){ paramsDict[config.externalSearchOptions.field_param] = geneField + if (config.externalSearchOptions.annotation_field) { + paramsDict[config.externalSearchOptions.field_param] += "," + annotationField + } } if (config.externalSearchOptions.count_param){ @@ -103,9 +107,15 @@ Meteor.publish({ url = url + "?" + new URLSearchParams(paramsDict) const response = HTTP.get(url); if (response.statusCode === 200){ - geneResults = response.data.data.map(result => result._source[geneField]) + geneResults = response.data.data.map(result => { + if (config.externalSearchOptions.annotation_field){ + return {"ID": result._source[geneField], "annotationName": result._source[annotationField]} + } else { + return {"ID": result._source[geneField]} + } + }) } - transformedQuery = {genomeId: { $in: queryGenomeIds }, ID: { $in: geneResults }} + transformedQuery = {genomeId: { $in: queryGenomeIds }, $or: geneResults} } else { transformedQuery = { ...query, genomeId: { $in: queryGenomeIds } }; } @@ -120,7 +130,13 @@ Meteor.publish({ if (typeof geneId === 'undefined') { Object.assign(query, { 'subfeatures.ID': transcriptId }); } else { - Object.assign(query, { ID: geneId }); + Object.assign(query, { + $or: [ + {'ID': geneId}, + { 'subfeatures.ID': geneId }, + { 'subfeatures.protein_id': geneId }, + ], + }); } return Genes.find(query); diff --git a/imports/ui/singleGenePage/SingleGenePage.jsx b/imports/ui/singleGenePage/SingleGenePage.jsx index 39e91f62..5b5ba7dd 100644 --- a/imports/ui/singleGenePage/SingleGenePage.jsx +++ b/imports/ui/singleGenePage/SingleGenePage.jsx @@ -84,9 +84,22 @@ function geneDataTracker({ match, genomeDataCache, location }) { const geneSub = Meteor.subscribe('singleGene', { geneId }); let genes if (annotation) { - genes = Genes.find({ ID: geneId, annotationName: annotation }).fetch(); + genes = Genes.find({ + $or: [ + {'ID': geneId}, + { 'subfeatures.ID': geneId }, + { 'subfeatures.protein_id': geneId }, + ], + annotationName: annotation + }).fetch(); } else { - genes = Genes.find({ ID: geneId }).fetch(); + genes = Genes.find({ + $or: [ + {'ID': geneId}, + { 'subfeatures.ID': geneId }, + { 'subfeatures.protein_id': geneId }, + ] + }).fetch(); } const loading = !geneSub.ready(); diff --git a/package.json b/package.json index 595b0675..b93ac179 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "genoboo", - "version": "0.4.10", + "version": "0.4.11", "repository": "https://github.com/gogepp/genoboo", "description": "A portable website for browsing and querying genome sequences and annotations. Forked from genenotebook", "license": "AGPL-3.0",