Question: where to write Controller class in Galaxy Visualisation plugin
0
gravatar for sureshhewabi
2.7 years ago by
sureshhewabi20
sureshhewabi20 wrote:

Hi,

I am developing a Galaxy Visualisation plugin(new to galaxy). I have written a basic mako file and manage to show basic html with plugin But I need to call a controller class (servlet) from mako file to fetch some data time to time by calling java model classes(business logic). How can I write a controller class within galaxy and where should I put that class?

Purpose of having a controller class is, when user select something, I need to fetch some data depending on the selected data at run time using ajax call. I don't know, where to pass ajax call, if i do not have a servlet/controller class.

Thank you.

galaxy • 1.0k views
ADD COMMENTlink modified 2.7 years ago by carlfeberhard390 • written 2.7 years ago by sureshhewabi20
1

Have you seen https://wiki.galaxyproject.org/Develop/Visualizations and https://wiki.galaxyproject.org/VisualizationsRegistry ?

ADD REPLYlink written 2.7 years ago by Martin Čech ♦♦ 4.9k

Hi, I have seen then and built simple plugin according to that. In order to have a controller class, do I need to setup production server? but still, I am confused, where to write controller?

ADD REPLYlink written 2.7 years ago by sureshhewabi20

I think the purpose of the plugin system is to avoid the need of writing custom Galaxy controllers. You should be able to write a viz plugin by using DataProviders and the existing API - some details here: https://wiki.galaxyproject.org/VisualizationsRegistry/Code

If you are unable to write what you want that way maybe you do not want to write a plugin but rather a custom version of Galaxy. In that case you can find the API controllers here: https://github.com/galaxyproject/galaxy/tree/dev/lib/galaxy/webapps/galaxy/api

ADD REPLYlink written 2.7 years ago by Martin Čech ♦♦ 4.9k
1
gravatar for carlfeberhard
2.7 years ago by
carlfeberhard390
United States
carlfeberhard390 wrote:

If I understand the question correctly then Martin is right and you would get data from your datasets by making an AJAX call to the datasets API: https://wiki.galaxyproject.org/DataProviders

Other options are:

  • if the current providers don't give you what you need, you can write new providers or your own datatypes and data providers for them
  • if your using user input to significantly alter data you may want to write a tool (instead or in addition to the visualization)

Can you clarify some of the terminology here, though:

  • Are you using the terms Java/servlet/Java model classes in more general terms and you're need info about their equivalents in Galaxy: Python/Web/API Controller/SQLAlchemy Model?
  • Or are you trying to access a Java web service from inside the visualization?
ADD COMMENTlink written 2.7 years ago by carlfeberhard390
0
gravatar for sureshhewabi
2.7 years ago by
sureshhewabi20
sureshhewabi20 wrote:

Thank you for the replies,I am new to galaxy. I have anXML file and I need to visualise it. But in order to get data out of it, I need to use java library to extract data. I cannot extract all the data in one go.

For example, if user click on "Customers" button, I need to send a AJAX call to a controller then controller should call java library and read xml file and send data(Customers list). If user click on a particular Customer, I need to again go a GET request via AJAX..... and call java library again and get "Orders ".

my XML file is special type of XML(mzIdentML).

galaxy -> lib -> galaxy -> datatypes -> proteomics.py has following code:

class MzIdentML(ProteomicsXml):
file_ext = "mzid"
edam_format = "format_3247"
blurb = "XML identified peptides and proteins."
root = "MzIdentML"

galaxy -> lib -> galaxy -> datatypes -> dataproviders -> dataset.py I dont find any code related to mzIdentML here.

So do you say class MzIdentML(ProteomicsXml) is my model class and in dataset.py, I need to write a controller class (let's say mzIdentMLDataProvider) to communicate with java library to fetch data from mzIdentML file? So my AJAX should call to mzIdentMLDataProvider some function (let's say "getCustomers") which calls to my java library somehow. am I correct?

ADD COMMENTlink written 2.7 years ago by sureshhewabi20
0
gravatar for carlfeberhard
2.7 years ago by
carlfeberhard390
United States
carlfeberhard390 wrote:

It sounds like you've decorated the mzIdentML file with commerce/consumer data?

But, there is an XML dataprovider though so, you might want to try this and see if works:

  • with your instance running, go to a history with one of you mzIndentML files
  • expand that dataset and click the 'View Details' button (the circle with the 'i' in the center)
  • copy the 'History Content API ID' (it usually is a hex string)
  • go to 'http://localhost:8080/api/datasets/<the dataset id copied>?data_type=raw_data&provider=xml'

You should see your mzIdentML XML parsed into a JSON dictionary. Further, you can query using specific selectors. For example,

  • I uploaded: PAnalyzer_rosetta_2a_uniprot.mzid.gz
  • and then used: http://localhost:8080/api/datasets/da25dcb15a682136?data_type=raw_data&provider=xml&selector=SpectrumIdentificationItem
  • and only got SpectrumIdentificationItem elements.

In a similar manner, you may be able to use 'Customers' and 'Orders' and have the 'api/datasets' call be your ajax endpoint.

If you really need to parse the XML in Java, however, I guess the best solution here would be to write a tool.

(edited to correct the display of '<the dataset id copied>' above)

ADD COMMENTlink modified 2.7 years ago • written 2.7 years ago by carlfeberhard390

Hi,

Thank you for your explanation. 1) I did copy the 'History Content API ID' and and replaced <the dataset="" id="" copied=""> in url and yes, I can see file converted to JSON. 2) Secondly, I try to go to http://localhost:8080/api/datasets/da25dcb15a682136?data_type=raw_data&provider=xml&selector=SpectrumIdentificationItem URL, but I received this "'NoneType' object has no attribute 'dataset'"

In my situation, it is not just showing some content of the file as visualisation. mzIdentML file is a very complex file having inter relationships. Therefore I need to pass the mzIdentML file to a java library, do some analysis and results should be saved as JSON.

I am specifically asking, where I should write the code if I want to call by API(what is the file path)? is it galaxy -> webapps -> galaxy -> api -> datasets.py if so Do i need to create a DataProvider class? if so, where?

can you kindly tell me which files do i need to modify?

I want to visualise this with visualisation button.

ADD REPLYlink written 2.7 years ago by sureshhewabi20

Hi, sureshhewabi

The "http://localhost:8080/api/datasets/da25dcb15a682136?data_type=raw_data&provider=xml&selector=SpectrumIdentificationItem" was an example. I was hoping that you would replace the dataset id "da25dcb15a682136" with your own and "SpectrumIdentificationItem" with one of the tags you were looking for ("Customers", "Orders"). Sorry if that wasn't clear.

I think, though, considering you need to communicate with the Java library from Python, that you should consider developing a tool that extracts the data you need instead of a visualization plugin: https://wiki.galaxyproject.org/Admin/Tools/AddToolTutorial

ADD REPLYlink written 2.7 years ago by carlfeberhard390

Hi carlfeberhard,

Thank you for your help. I can now see SpectrumIdentificationItem data.

Even though that method is good enough to extract information, what I found was there is a "show" method inside galaxy -> webapps -> galaxy -> api -> datasets.py I created if condition inside show method in DatasetController class and called my own method like this:

elif data_type == 'mzidentml':
            rval = self._mzidentml_data( trans, dataset )

I created my own method inside same DatasetController class like this:

    def _mzidentml_data( self, trans, dataset, **kwargs ):
    """
    usage : http://localhost:8080/api/datasets/33b43b4e7093c91f?data_type=mzidentml
    """
    return "hii"

Now if I run http://localhost:8080/api/datasets/33b43b4e7093c91f?data_type=mzidentml link I can see "hii" word. I think therefore, I think I can call java inside this _mzidentml_data method. I am not sure whether this is the standard way.... Please kindly give me an advice. Because I don't like to go for tool, I am really focusing on visualisation

ADD REPLYlink written 2.7 years ago by sureshhewabi20
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: 167 users visited in the last hour