@@ -45,9 +45,8 @@ import {parseVariantCacheIndex} from './variant-cache-worker';
4545 * possible completely offline (i.e. a progressive web component) -- but only
4646 * once caches are populated.
4747 */
48- export async function initCaches ( ideo ) {
48+ export async function initCaches ( config ) {
4949
50- const config = ideo . config ;
5150 if ( ! config . useCache ) return ;
5251
5352 const organism = config . organism ;
@@ -60,31 +59,35 @@ export async function initCaches(ideo) {
6059 // resolves a Promise, whereas the others return upon completing their
6160 // respective initializations.
6261 const cachePromise = Promise . all ( [
63- cacheFactory ( 'gene' , organism , ideo , cacheDir ) ,
64- cacheFactory ( 'paralog' , organism , ideo , cacheDir ) ,
65- cacheFactory ( 'interaction' , organism , ideo , cacheDir ) ,
66- cacheFactory ( 'synonym' , organism , ideo , cacheDir ) ,
62+ cacheFactory ( 'gene' , organism , config , cacheDir ) ,
63+ cacheFactory ( 'paralog' , organism , config , cacheDir ) ,
64+ cacheFactory ( 'interaction' , organism , config , cacheDir ) ,
65+ cacheFactory ( 'synonym' , organism , config , cacheDir ) ,
6766 ] ) ;
6867
6968 if ( config . showGeneStructureInTooltip ) {
70- cacheFactory ( 'geneStructure' , organism , ideo , cacheDir ) ;
71- cacheFactory ( 'protein' , organism , ideo , cacheDir ) ;
72- cacheFactory ( 'tissue' , organism , ideo , cacheDir ) ;
73- cacheFactory ( 'variant' , organism , ideo , cacheDir ) ;
69+ cacheFactory ( 'geneStructure' , organism , config , cacheDir ) ;
70+ cacheFactory ( 'protein' , organism , config , cacheDir ) ;
71+ cacheFactory ( 'tissue' , organism , config , cacheDir ) ;
72+ if ( config . showVariantInTooltip ) {
73+ cacheFactory ( 'variant' , organism , config , cacheDir ) ;
74+ }
7475 }
7576
7677 return cachePromise ;
7778
7879 } else {
79- cacheFactory ( 'gene' , organism , ideo , cacheDir ) ;
80- cacheFactory ( 'paralog' , organism , ideo , cacheDir ) ;
81- cacheFactory ( 'interaction' , organism , ideo , cacheDir ) ;
80+ cacheFactory ( 'gene' , organism , config , cacheDir ) ;
81+ cacheFactory ( 'paralog' , organism , config , cacheDir ) ;
82+ cacheFactory ( 'interaction' , organism , config , cacheDir ) ;
8283 if ( config . showGeneStructureInTooltip ) {
83- cacheFactory ( 'geneStructure' , organism , ideo , cacheDir ) ;
84- cacheFactory ( 'protein' , organism , ideo , cacheDir ) ;
85- cacheFactory ( 'synonym' , organism , ideo , cacheDir ) ;
86- cacheFactory ( 'tissue' , organism , ideo , cacheDir ) ;
87- cacheFactory ( 'variant' , organism , ideo , cacheDir ) ;
84+ cacheFactory ( 'geneStructure' , organism , config , cacheDir ) ;
85+ cacheFactory ( 'protein' , organism , config , cacheDir ) ;
86+ cacheFactory ( 'synonym' , organism , config , cacheDir ) ;
87+ cacheFactory ( 'tissue' , organism , config , cacheDir ) ;
88+ if ( config . showVariantInTooltip ) {
89+ cacheFactory ( 'variant' , organism , config , cacheDir ) ;
90+ }
8891 }
8992 }
9093}
@@ -140,14 +143,14 @@ const allCacheProps = {
140143 }
141144} ;
142145
143- function setGeneCache ( parsedCache , ideo ) {
146+ function setGeneCache ( parsedCache ) {
144147 const [
145148 interestingNames , nameCaseMap , namesById , fullNamesById ,
146149 idsByName , lociByName , lociById
147150 //, sortedAnnots
148151 ] = parsedCache ;
149152
150- ideo . geneCache = {
153+ Ideogram . geneCache = {
151154 interestingNames, // Array ordered by general or scholarly interest
152155 nameCaseMap, // Maps of lowercase gene names to proper gene names
153156 namesById,
@@ -159,46 +162,46 @@ function setGeneCache(parsedCache, ideo) {
159162 } ;
160163}
161164
162- function setParalogCache ( parsedCache , ideo ) {
165+ function setParalogCache ( parsedCache ) {
163166 const paralogsByName = parsedCache ;
164167 // Array of paralog Ensembl IDs by (uppercase) gene name
165- ideo . paralogCache = { paralogsByName} ;
168+ Ideogram . paralogCache = { paralogsByName} ;
166169}
167170
168- function setInteractionCache ( parsedCache , ideo ) {
171+ function setInteractionCache ( parsedCache ) {
169172 const interactionsByName = parsedCache ;
170- ideo . interactionCache = interactionsByName ;
173+ Ideogram . interactionCache = interactionsByName ;
171174}
172175
173- function setGeneStructureCache ( parsedCache , ideo ) {
176+ function setGeneStructureCache ( parsedCache ) {
174177 const featuresByGene = parsedCache ;
175- ideo . geneStructureCache = featuresByGene ;
178+ Ideogram . geneStructureCache = featuresByGene ;
176179}
177180
178- function setProteinCache ( parsedCache , ideo ) {
179- ideo . proteinCache = parsedCache ;
181+ function setProteinCache ( parsedCache ) {
182+ Ideogram . proteinCache = parsedCache ;
180183}
181184
182- function setSynonymCache ( parsedCache , ideo ) {
183- ideo . synonymCache = parsedCache ;
185+ function setSynonymCache ( parsedCache ) {
186+ Ideogram . synonymCache = parsedCache ;
184187}
185188
186- function setTissueCache ( parsedCache , ideo ) {
187- ideo . tissueCache = parsedCache ;
189+ function setTissueCache ( parsedCache ) {
190+ Ideogram . tissueCache = parsedCache ;
188191}
189192
190- function setVariantCache ( parsedCache , ideo ) {
191- ideo . variantCache = parsedCache ;
193+ function setVariantCache ( parsedCache ) {
194+ Ideogram . variantCache = parsedCache ;
192195}
193196
194- async function cacheFactory ( cacheName , orgName , ideo , cacheDir = null ) {
197+ async function cacheFactory ( cacheName , orgName , config , cacheDir = null ) {
195198
196199 const cacheProps = allCacheProps [ cacheName ] ;
197- const debug = ideo . config . debug ;
200+ const debug = config . debug ;
198201
199202 /**
200- * Fetch cached gene data, transform it usefully, and set it as ideo prop
201- */
203+ * Fetch cached gene data, transform it usefully, and set it as Ideogram prop
204+ */
202205 const startTime = performance . now ( ) ;
203206 let perfTimes = { } ;
204207
@@ -211,7 +214,6 @@ async function cacheFactory(cacheName, orgName, ideo, cacheDir=null) {
211214 // Skip initialization if cache is already populated
212215 if ( Ideogram [ staticProp ] && Ideogram [ staticProp ] [ orgName ] ) {
213216 // Simplify chief use case, i.e. for single organism
214- ideo [ staticProp ] = Ideogram [ staticProp ] [ orgName ] ;
215217 return ;
216218 }
217219
@@ -233,8 +235,8 @@ async function cacheFactory(cacheName, orgName, ideo, cacheDir=null) {
233235 // cacheWorker.postMessage(message);
234236 // cacheWorker.addEventListener('message', event => {
235237 // [parsedCache, perfTimes] = event.data;
236- cacheProps . fn ( parsedCache , ideo , orgName ) ;
237- Ideogram [ staticProp ] [ orgName ] = ideo [ staticProp ] ;
238+ cacheProps . fn ( parsedCache , orgName ) ;
239+ Ideogram [ staticProp ] [ orgName ] = Ideogram [ staticProp ] ;
238240
239241 if ( debug ) {
240242 console . timeEnd ( `${ cacheName } Cache total` ) ;
0 commit comments