From 49098e6d59d19ec01a2112d361c7d73d385005db Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 12 Mar 2024 10:17:48 -0400 Subject: [PATCH] Add jsonParse to jexl --- packages/core/util/jexl.ts | 1 + .../__snapshots__/jbrowseModel.test.ts.snap | 33 +++++++++++++++++++ test_data/volvox/config.json | 18 ++++++++++ test_data/volvox/volvox.sort.gff3 | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/packages/core/util/jexl.ts b/packages/core/util/jexl.ts index 1e6b41728f..ec6949be42 100644 --- a/packages/core/util/jexl.ts +++ b/packages/core/util/jexl.ts @@ -75,6 +75,7 @@ export default function (/* config?: any*/): JexlNonBuildable { ) j.addFunction('toLowerCase', (s: string) => s.toLowerCase()) j.addFunction('toUpperCase', (s: string) => s.toUpperCase()) + j.addFunction('jsonParse', (s: string) => JSON.parse(s)) j.addFunction('trim', (s: string) => s.trim()) j.addFunction('trimEnd', (s: string) => s.trimEnd()) j.addFunction('trimStart', (s: string) => s.trimStart()) diff --git a/products/jbrowse-web/src/__snapshots__/jbrowseModel.test.ts.snap b/products/jbrowse-web/src/__snapshots__/jbrowseModel.test.ts.snap index 4febd03643..73a26131de 100644 --- a/products/jbrowse-web/src/__snapshots__/jbrowseModel.test.ts.snap +++ b/products/jbrowse-web/src/__snapshots__/jbrowseModel.test.ts.snap @@ -2106,6 +2106,39 @@ exports[`JBrowse model creates with non-empty snapshot 1`] = ` "trackId": "volvox_sv", "type": "AlignmentsTrack", }, + { + "adapter": { + "gffLocation": { + "internetAccountId": undefined, + "internetAccountPreAuthorization": undefined, + "locationType": "UriLocation", + "uri": "volvox.sort.gff3", + }, + "type": "Gff3Adapter", + }, + "assemblyNames": [ + "volvox", + ], + "category": [ + "Miscellaneous", + ], + "displays": [ + { + "displayId": "gff3_genes-LinearBasicDisplay", + "type": "LinearBasicDisplay", + }, + { + "displayId": "gff3_genes-LinearArcDisplay", + "type": "LinearArcDisplay", + }, + ], + "formatDetails": { + "feature": "jexl:{table:jsonParse(feature.table)}", + }, + "name": "GFF3 genes", + "trackId": "gff3_genes", + "type": "FeatureTrack", + }, { "adapter": { "gffGzLocation": { diff --git a/test_data/volvox/config.json b/test_data/volvox/config.json index 0d93cea6a9..0e1d4a7fda 100644 --- a/test_data/volvox/config.json +++ b/test_data/volvox/config.json @@ -1076,6 +1076,24 @@ } } }, + { + "type": "FeatureTrack", + "trackId": "gff3_genes", + "assemblyNames": ["volvox"], + "name": "GFF3 genes", + "formatDetails": { + "feature": "jexl:{table:jsonParse(feature.table)}" + }, + "category": ["Miscellaneous"], + "adapter": { + "type": "Gff3Adapter", + "gffLocation": { + "uri": "volvox.sort.gff3", + "locationType": "UriLocation" + } + } + }, + { "type": "FeatureTrack", "trackId": "gff3tabix_genes", diff --git a/test_data/volvox/volvox.sort.gff3 b/test_data/volvox/volvox.sort.gff3 index 30f55ef28d..b28d4b0dc8 100644 --- a/test_data/volvox/volvox.sort.gff3 +++ b/test_data/volvox/volvox.sort.gff3 @@ -2,7 +2,7 @@ # multi-exon gene - several linked CDSs # single exon gene - one CDS only ##gff-version 3 -ctgA example contig 1 50001 . . . Name=ctgA;multivalue=val1,val2,val3 +ctgA example contig 1 50001 . . . Name=ctgA;multivalue=val1,val2,val3;table=%5B%7B%22name%22%3A%22hello1%22%2C%22value%22%3A1%7D%2C%7B%22name%22%3A%22hello2%22%2C%22value%22%3A2%7D%2C%7B%22name%22%3A%22hello3%22%2C%22value%22%3A3%7D%2C%7B%22name%22%3A%22hello4%22%2C%22value%22%3A4%7D%2C%7B%22name%22%3A%22hello5%22%2C%22value%22%3A5%7D%5D ctgA example BAC 1000 20000 . . . ID=b101.2;Name=b101.2;Note=Fingerprinted BAC with end reads ctgA example SNP 1000 1000 0.987 . . ID=FakeSNP1;Name=FakeSNP;Note=This is a fake SNP that should appear at 1000 with length 1 ctgA example clone_start 1000 1500 . + . Parent=b101.2