eweitz / ideogram

Chromosome visualization for the web
https://eweitz.github.io/ideogram
Other
294 stars 71 forks source link

Issue with custom organism bandfiles #307

Closed NicoNekoru closed 2 years ago

NicoNekoru commented 2 years ago

Using the band file cicer-arietinum.json in ./data/bands/cicer-arietinum.json

{
  "chrBands": [
    "1   1 48359943 1 48359943 gpos50", 
    "2   1 36634854 1 36634854 gpos50", 
    "3   1 39989001 1 39989001 gpos50", 
    "4   1 49191682 1 49191682 gpos50", 
    "5   1 48169137 1 48169137 gpos50", 
    "6   1 59463898 1 59463898 gpos50", 
    "7   1 48961560 1 48961560 gpos50", 
    "8   1 16477302 1 16477302 gpos50"
  ]
}

And the ideogram config

var config = {
    organism: 'cicer-arietinum',
    orientation: 'vertical',
    dataDir: './data/bands/',
    rotatable: false,
    showBandLabels: true,
    showNonNuclearChromosomes: false,
    container: '.ideogram-container',
    debug: true
}

I get the error

Uncaught (in promise) TypeError: Cannot create property 'chrIndex' on string '1'
    at ql.ac [as getChromosomeModel] (chromosome-model.js:176:7)
    at li (init.js:31:21)
    at ql.hi [as initDrawChromosomes] (init.js:85:5)
    at ql.Jr [as finishInit] (finish-init.js:91:8)
    at ql.ii [as writeContainer] (write-container.js:113:8)
    at init.js:234:10

with no Ideogram displayed. When logging (chr, bands, chrName, ) in the getChromosomeModel function before chr = getChrModelScaffold(chr, bands, chrName, ideo); I get the output

{} undefined '1' 

and when logging chr after the getChrModelScaffold I get

1

as described in the error.
If I do not provide dataDir the output instead becomes

{} undefined {name: 'Ca1', length: 48359943, type: 'nuclear'} 

which is the expected output and also creates the ideogram with expected behavior

Issue seems to stem from when organism has no bandsArray AND a string array of chromosome names for ideogram.config.chromosomes like

> ideogram.bandsArray
{3827: undefined}
> ideogram.config.chromosomes
{3827: (8) ['1', '2', '3', '4', '5', '6', '7', '8']}

instead of

> ideogram.bandsArray
{3827: undefined}
> ideogram.config.chromosomes
{"3827": [
    {...},
    {...},
    {...},
    {...},
    {...},
    {...},
    {...},
    {...},
]}

or

> ideogram.bandsArray
{3827: [
    [{…}]
    [{…}]
    [{…}]
    [{…}]
    [{…}]
    [{…}]
    [{…}]
    [{…}]
]}
> ideogram.config.chromosomes
{3827: (8) ['1', '2', '3', '4', '5', '6', '7', '8']}