igvteam / igv-notebook

Module for embedding igv.js in an IPython notebook
MIT License
59 stars 13 forks source link

load custom reference genome #5

Closed arpanda closed 2 years ago

arpanda commented 2 years ago

am trying to load a custom reference genome. But getting an error.

Here my test code.

import igv_notebook

genome = {
    'reference': {
      "id": "TestGenome",
      "name": "Test1)",
      "fastaURL": "{local fasta path}",
      "indexURL": "{local fasta index path}",
    }
}

igv_notebook.init()
#igv_notebook.loadGenome(genome)

b = igv_notebook.Browser({"genome": "hg19"})
b = igv_notebook.Browser.loadGenome(genome)

I learnt about the loadGenome from igv.js, looks like its not working. Any suggestion to fix it.

Thanks Arijit

jrobinso commented 2 years ago

There's not enough information there to help. Did you read the documentation in this repository's README? What error are you getting?

jrobinso commented 2 years ago

BTW there is no "loadGenome" python function, please review the README. Also the examples in this repository.

arpanda commented 2 years ago

For the igv_notebook.loadGenome(genome), the error is

AttributeError: module 'igv_notebook' has no attribute 'loadGenome'

and for b = igv_notebook.Browser.loadGenome(genome), the error is

AttributeError: type object 'Browser' has no attribute 'loadGenome'

I was trying to follow this documentation.

My main goal is to load a custom reference genome from a fasta file. but not sure how to do it using igv_notebook.

I also tried this

import igv_notebook

igv_notebook.init()

b = igv_notebook.Browser(
    {"reference": 
      {
        "id": "TestGenome",
         "fastaURL": "fasta_file.fna",
         "indexURL": "fasta_file.fna.fai",
      }
    }   
)

and giving this below error:

image

is it because of local path? Thanks

jrobinso commented 2 years ago

The documentation you reference is for igv.js, there is no loadGenome function in igv-notebook. Your second example is the correct way to do this. See the README section on URLs and Paths. I will try your case and create an example but it might be tomorrow before I can do this.

jrobinso commented 2 years ago

I've added example notebooks for defining a custom reference for Jupyter and Colab, see the examples directory. Be sure you understand the use of "path" and "url" fields as explained in the README. If using Jupyter Notebook or Lab you can use URLs if the files in are in the directory tree relative where you started the server. If using Colab you musth use paths.