Custom tool output displaying

Hi everybody,
finally I managed to load my custom tool into Galaxy. What I need is give as input the ID of a gene and retrieve some data to be stored/displayed in a table.
Now my python code is storing this table in a tab file but I’m not able to display it in Galaxy.

That’s my xml file for the tool:

<tool id="get_pheno" name="Get phenotypes" version="0.1.0">
  <description>for a gene from IMPC</description>
    <requirement type="package" version="3.8">python</requirement>
	<requirement type="package" version="2.18.4">requests</requirement>
	<requirement type="package" version="0.8.9">tabulate</requirement>
	<requirement type="package" version='8.0.1'>IPython</requirement>
  <command><![CDATA[python3 '${__tool_directory__}/' '$input' '$output']]></command>
	  <param name="input" type='text' label='Input gene:'/>
    <data format="tabular" name="output" label='${} on ${input}' />

This tool retrieves a list of phenotypes related to a gene entered by the user. The input must be an MGI id.


I tried substituting “data” with “output” but it’s not workning.
How can I get the output as a table?
I already tried to read some documentation but I didn’t find anything useful for me.
Thank you for the help

Hi @Andrea_Furlani

The GTN tool development tutorials would be a good place to review/learn: Galaxy Training!

I already checked those slides but the output part it’s quite incomplete respect to the input part:

If you look the slides about output I already used both the options they indicated and in my code they are not working

Try using Planemo

The current XML has a few problems it could help uncover. One simple example: single quotes instead of double around a requirement version.

As a quick solution, maybe try using the ToolFactory tool instead? You could use it directly (only) or create the wrapper that way and then compare it to what you have now.

ToolFactory is itself a tool – one that creates other tools, and it makes use of Planeno. See the tutorials for the how-to. It is available to install from the Main Toolshed: It isn’t hosted on public Galaxy servers for security reasons but it would be fine to install/use in your own private Galaxy server that isn’t exposed to the internet publically.

Thank you but I would prefer to not use external tools to program mine, also because this script it’s only a test, later my tool will be way more complex so I’m not sure I can use Planemo or ToolFactory.
Is there any way to better understand where is the error? Because watching other tools I can’t understand where is the difference… I setted the output in the xml file as the other tools and my python code it’s both printing the result (so I can actually see that I have the correct one in the info tab) and saving it in a tab file but I’m not able in any way to have it visible in the “view data” tab

How do you know that the tool even works? Here we established that you already have version conflicts:Galaxy local python Module Not Found Error
And because the tool will be executed in the background in a conda environment you need to execute python instead of python3.

Try to make a simple working “test” tool first. Your XML could be something like:

<tool id="my_first_test" name="test tool">
    <requirement type="package" version="3.8">python</requirement>

 python '${__tool_directory__}/' -i $input -o $output
	  <param name="input" type="text" label="Test input" />
    <data format="tabular" name="output" label="test output" />


And the python code (of top of my head):

import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='')
parser.add_argument('-i', dest='input', type=str, help='', required=True)
parser.add_argument('-o', dest='output', type=str, help='', required=True)
args = parser.parse_args()

with open(args.output, "a") as out:

And let’s go from there

Is there any way to better understand where is the error?

Is the ouput at this moment green or red?

I managed to solve the error and now the tool is running fine (at the end of the job it is green).
I know that it is working in the correct way because if I print the result I can see the list in the “edit attributes” tab.

Here’s the code of my python script:

import sys
import requests
import tabulate
from IPython.display import HTML, display

impc_api_url = ""
impc_api_search_url = f"{impc_api_url}/genes"
impc_api_gene_bundle_url = f"{impc_api_url}/geneBundles"

# 1-Given a gene id, retrieve all the phenotypes related to it (id and name)
def stop_err(msg):

def main():


        mgi_accession_id = str(sys.argv[1])

        gene_url = f"{impc_api_search_url}/{mgi_accession_id}"
        gene_data = requests.get(gene_url).json()

        p_list = gene_data['significantMpTermNames']
        textfile = open("", "w+")
        for element in p_list:
            textfile.write(element + "\t")

    except Exception as ex:
        stop_err('Error running\n' + str(ex))


if __name__ == "__main__":

You are not giving galaxy the output file, it should be:

textfile = open(sys.argv[2], "w+")

Or! you do this:

<data format="tabular" name="output" from_work_dir="" label='${} on ${input}' />

Thank you very much for the reply, I’m going to give a try with both the solutions