Question: Visualize gff3 file
0
gravatar for s.saha
3.8 years ago by
s.saha0
United Kingdom
s.saha0 wrote:

Hi All

I am a new user of Galaxy. So please bear with me, if I am asking very obvious question.

I am trying incorporate javascript and HTML5 based tool to visualize gff3 format data. The tool runs fine from a webserver (I tried with apache). I have read your visualization tutorial and followed it. Even if I try very simple display functionality, that is read a line from gff3 file and display it, I get following error,

AttributeError: 'Bunch' object has no attribute 'template_lookup'

URL: http://127.0.0.1:8080/visualization/show/Genoverse?dataset_id=2d9035b3fc152403
File '/home/shyama/workspace/galaxy-dist/eggs/WebError-0.8a-py2.7.egg/weberror/evalexception/middleware.py', line 364 in respond
  app_iter = self.application(environ, detect_start_response)
File '/home/shyama/workspace/galaxy-dist/eggs/Paste-1.7.5.1-py2.7.egg/paste/recursive.py', line 84 in __call__
  return self.application(environ, start_response)
File '/home/shyama/workspace/galaxy-dist/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpexceptions.py', line 633 in __call__
  return self.application(environ, start_response)
File '/home/shyama/workspace/galaxy-dist/lib/galaxy/web/framework/base.py', line 132 in __call__
  return self.handle_request( environ, start_response )
File '/home/shyama/workspace/galaxy-dist/lib/galaxy/web/framework/base.py', line 190 in handle_request
  body = method( trans, **kwargs )
File '/home/shyama/workspace/galaxy-dist/lib/galaxy/web/framework/__init__.py', line 98 in decorator
  return func( self, trans, *args, **kwargs )
File '/home/shyama/workspace/galaxy-dist/lib/galaxy/webapps/galaxy/controllers/visualization.py', line 824 in render
  embedded=embedded, query=kwargs, vars={}, config=config, **resources )
File '/home/shyama/workspace/galaxy-dist/lib/galaxy/web/base/pluginframework.py', line 592 in fill_template
  return trans.fill_template( template_filename, template_lookup=plugin.template_lookup, **kwargs )
AttributeError: 'Bunch' object has no attribute 'template_lookup'

Can you kindly help me with this please?

 

Thanks in advance.

Shyama

gff • 1.5k views
ADD COMMENTlink modified 3.8 years ago by carlfeberhard390 • written 3.8 years ago by s.saha0
4
gravatar for carlfeberhard
3.8 years ago by
carlfeberhard390
United States
carlfeberhard390 wrote:

Hi Shyama,

Thanks for trying out the visualization framework. It's not an obvious question at all and sorry for the frustration.

From the stack trace, it looks like the plugin is missing a template_lookup attribute. This is assigned in pluginframework.py on lines 519 to 522.

Since you probably haven't altered that code, the if statement on line 519 would get 'True' for serves_templates (one of two flags for creating template_lookup). 

The other flag checks whether you have a 'templates' directory in your base plugin directory. So, if you have a plugin directory of 'config/plugins/visualizations/Genoverse', you should also have a sub-directory named templates within that: 'config/plugins/visualizations/Genoverse/templates'. (This directory should contain the mako templates that will start your visualization.)

Is that sub-directory missing?

I'm happy to diagnose further and let me know if I can help more. Looking forward to seeing your visualization!

Carl

 

ADD COMMENTlink written 3.8 years ago by carlfeberhard390

Hi Carl

Many Thanks for your reply. Just to let to let you know, I got your reply from the galaxy-dev as well. But I will continue to reply here. 

1. No, I have not altered pluginframework.py. I see, servers_templates is assigned to False on line 517, then in 'if' , it is set to True.

2. I have created a template folder, but just figured out that, it should be 'templates', 's' was missing.

3. After fixing some js path, I can now see the base tracks. Now I need to access the gff file content. I have read your datatype, dataProvider stuff. What I really need is an URL to gff file and pass it to my code. Here is the mako template (shorten version, so that its easier to go through)....

<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>${hda.name} | ${visualization_name}</title>
</head>
<body>
<div id=genoverse></div>
<script type="text/javascript" src="/plugins/visualizations/Genoverse/static/js/genoverse.combined.js">
      {
        container : '#genoverse', // Where to inject Genoverse (css/jQuery selector)
        // If no genome supplied, it must have at least chromosomeSize, e.g.:
        // chromosomeSize : 249250621, // chromosome 1, human
        genome    : 'grch37', // see js/genomes/
        plugins   : [ 'controlPanel', 'karyotype', 'trackControls', 'resizer', 'fileDrop' ],
        tracks    : [
          Genoverse.Track.extend({
            name   : 'Peptides',
            view   : Genoverse.Track.View.Transcript.extend({
              setFeatureColor : function () {}
            }),
            height : 100,

        url    : '/database/files/000/dataset_5.dat',
            model  : Genoverse.Track.Model.extend({
              dataType : 'text',
              parseData: function (text) {
                var lines = text.split('\n');
                for (var i = 0; i < lines.length; i++) {
                       #doing something to display the data
                  }
                }
              }
            }),
          })
        ]
      }
    </script>
</body>
</html>

  So, I need a URL to replace the value of 'url' (in bold and italic). Or possibly if I have access to the text of the file (where newlines and other formatting are also available), I can access that from 'parseData' and manipulate it. 

Any suggestions, how I might be able to do that?

 

Many Thanks

Shyama

ADD REPLYlink written 3.8 years ago by s.saha0
2

Two possible ways to get raw data over the API (a URL):

 

1) Use js to join the lines produced by the line dataprovider from the datasets API

https://bitbucket.org/galaxy/galaxy-central/src/7c5d92187dfd5b92fd05e0fcab163a8a0ef89ffa/lib/galaxy/datatypes/data.py?at=default#cl-813

https://bitbucket.org/galaxy/galaxy-central/src/7c5d92187dfd5b92fd05e0fcab163a8a0ef89ffa/lib/galaxy/datatypes/dataproviders/line.py?at=default#cl-23

Note the settings (which can be passed on the query string) which can be set to preserve whitespace, new lines, and comments.

Your final call will be something like:

GET /api/datasets/{id}?data_type=raw_data&provider=line&strip_lines=False&strip_newlines=False&provide_blank=True&comment_char=None

This will return a JSON array of the lines as strings. Join them:

xhr.done( function( response ){

    fileData = response.data.join( '' );

}

 

2) use the same url as the download button uses. You can hover over that button in the browser to get the specific link and generalize it based on that. In general, it's something like: 'GET /datasets/{id}/display?to_ext={file_ext}'. This has worked for folks in the past, but it's a bit of a hack.

At this point, I'd recommend the first option. Keep in mind, you can also get a partial number of lines (or paginate the data) using 'limit' and 'offset' in the query string or, alternately, use other data providers to get the columns as sub-arrays or key-value dictionaries/JSON-objects if that would make it easier to parse.

A more complete GFF3 dataprovider has been on the list a while now: I'd like to have a dataprovider that handled GFF3's nesting capability.

ADD REPLYlink modified 3.8 years ago • written 3.8 years ago by carlfeberhard390

Hi Carl

Many Thanks. It is working now. Now I am trying to achieve little more advance stuff, I will ask you if I need any help.

Shyama 

ADD REPLYlink written 3.8 years ago by s.saha0

Please mark Carl's answer as 'accepted' so people coming later will know it helped.

ADD REPLYlink written 3.8 years ago by Martin Čech ♦♦ 4.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 69 users visited in the last hour