changeset 6:9cc475dcd0f2 draft

planemo upload commit ad5f1c5a1a71d7fa2bc8bac408856aa80b0fc2a3
author proteore
date Tue, 18 Dec 2018 10:03:50 -0500
parents 7fbd66f985b7
children 6c95f1b88627
files README.rst reactome_analysis.py reactome_analysis.xml template.html test-data/ID_Converter_FKW_Lacombe_et_al_2017_OK.txt test-data/Reactome_Analysis_Tools.html test-data/Reactome_Analysis_Tools_invalid_ID.txt
diffstat 3 files changed, 61 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/reactome_analysis.py	Tue Apr 10 04:35:05 2018 -0400
+++ b/reactome_analysis.py	Tue Dec 18 10:03:50 2018 -0500
@@ -43,9 +43,7 @@
     trash = []
     if identifiers[1] == "list":
         ids = "\n".join(id_valid(identifiers[0].split())[0])
-        #print(ids)
-        #print("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids)
-        json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids).read()
+        json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/\?pageSize\=1\&page\=1" % ids).read()
         if len(id_valid(identifiers[0].split())[1]) > 0:
             trash = id_valid(identifiers[0].split())[1]
     elif identifiers[1] == "file":
@@ -57,15 +55,16 @@
             else:
                 idens = [x.split("\t")[int(identifiers[3].replace("c", ""))-1] for x in mq]
             ids = "\n".join(id_valid(idens)[0])
-            #print(ids)
-            #print("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids)
-            json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids).read()
+            json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/\?pageSize\=1\&page\=1 2> stderr" % ids).read()
             if len(id_valid(idens)[1]) > 0:
                 trash = id_valid(idens)[1]
-    print(json_string)
+    #print(json_string)
+    j = json.loads(json_string)
+    print ("Identifiers not found: " + str(j["identifiersNotFound"]))
+    print ("Pathways found: " + str(j["pathwaysFound"]))
     return json_string, trash
 
-def write_output(filename, json_string, trash_file, trash):
+def write_output(filename, json_string, species, trash_file, trash):
     """
     Replace json result in template and print to output
     """
@@ -74,6 +73,7 @@
     try: 
         for line in template:
             if "{token}" in line:
+                line = line.replace("{species}", species)
                 line = line.replace("{token}", json.loads(json_string)["summary"]["token"])
             output.write(line)
     except ValueError:
@@ -82,7 +82,7 @@
     output.close()
     
     if trash:
-        print(trash)
+        #print(trash)
         trash_out = open(trash_file, "w")
         trash_out.write("\n".join(trash))
         trash_out.close()
@@ -92,10 +92,11 @@
     argument = parser.add_argument("--json", nargs="+", required=True)
     argument = parser.add_argument("--output", default="output.html")
     argument = parser.add_argument("--trash", default="trash.txt")
+    argument = parser.add_argument("--species", default="48887")
     args = parser.parse_args()
     filename = args.output
     json_string, trash = data_json(args.json)
-    write_output(filename, json_string, args.trash, trash)
+    write_output(filename, json_string, args.species, args.trash, trash)
 
 if __name__ == "__main__":
     options()
--- a/reactome_analysis.xml	Tue Apr 10 04:35:05 2018 -0400
+++ b/reactome_analysis.xml	Tue Dec 18 10:03:50 2018 -0500
@@ -1,27 +1,31 @@
-<tool id="reactome_analysis" name="Reactome" version="0.1.0">
-    <description>queries web service and display pathways
-    </description>
+<tool id="reactome_analysis" name="Query Reactome pathway database" version="2018.12.12">
+    <description></description>
     <requirements>
     </requirements>
     <stdio>
         <exit_code range="1:" />
     </stdio>
     <command><![CDATA[
+
+        python $__tool_directory__/reactome_analysis.py 
         #if $opt.input == "text"
-            python $__tool_directory__/reactome_analysis.py --json "$opt.list" "list" --output "$output" --trash "$trash"
+        --json "$opt.list" "list" 
         #else if $opt.input == "file"
-            python $__tool_directory__/reactome_analysis.py --json "$opt.file" "file" $opt.header $opt.ncol --output "$output" --trash "$trash"
+        --json "$opt.file" "file" "$opt.header" "$opt.ncol" 
         #end if
+        --output "$output" 
+        --trash "$trash"
+        --species "$species"
         
     ]]></command>
     <inputs>
         <conditional name="opt">
-            <param name="input" type="select" label="Input identifiers (Uniprot accession number (e.g. P01023), Entrez gene ID (e.g.7157) or gene name (e.g. AQP7)" multiple="False" >
+            <param name="input" type="select" label="Input IDs (UniProt Accession number, Entrez Gene ID or Gene Name" multiple="False" >
                 <option value="text">Copy/paste your list of IDs </option>
-		        <option value="file" selected="true">Input file containing your identifiers</option>
+		        <option value="file" selected="true">Input file containing your IDs</option>
             </param>
             <when value="text" >
-                <param name="list" type="text" label="Enter list of identifiers" help="IDs must be separated by space into the form field, for example: P31946 P62258">
+                <param name="list" type="text" label="Enter list of IDs" help="IDs must be separated by a space into the form field, for example: P31946 P62258">
                     <sanitizer>
                         <valid initial="string.printable">
                             <remove value="&apos;"/>
@@ -33,17 +37,21 @@
                 </param>
             </when>
             <when value="file" >
-                <param name="file" type="data" format="txt, tabular" label="Input file containing your identifiers" help="Input file is a tab-delimited file with at least one contain containing identifier" />
-                <param name="header" type="boolean" checked="true" truevalue="true" falsevalue="false" label="Does your input file contain header?" />
-		        <param type="text" name="ncol" value="c1" label="Please specify the column number where are your IDs (e.g : Enter c1 for column n°1)" />
+                <param name="file" type="data" format="txt, tabular" label="Input file containing your IDs" help="Input file is a tab-delimited file with at least one contain containing identifier" />
+                <param name="header" type="boolean" checked="true" truevalue="true" falsevalue="false" label="Does file contain header?" />
+		        <param type="text" name="ncol" value="c1" label="Column number of IDs (e.g : Enter c1 for column n°1)" />
             </when>
-            
         </conditional>
+        <param name="species" type="select" label="Species">
+            <option value="48887">Human (Homo sapiens)</option>
+            <option value="48892">Mouse (Mouse musculus)</option>
+            <option value="48895">Rat (Rattus norvegicus)</option>
+        </param>
     </inputs>
     <outputs>
         <data name="output" format="html" label="" />
         <data name="trash" format="tabular" hidden="true" label="Invalid id not send to reactome">
-            <discover_datasets pattern="(Reactome_Analysis_Tools_invalid_ID).txt" ext="txt" visible="false" assign_primary_output="false"/>
+            <discover_datasets pattern="(Reactome_Analysis_Tools_invalid_ID).txt" ext="tabular" visible="false" assign_primary_output="false"/>
         </data>
     </outputs>
     <tests>
@@ -59,11 +67,30 @@
         </test>
     </tests>
     <help><![CDATA[
-Reactome software provides service of creating diagram representing the relations between the biological processes. This tool allows linking to Reactome web service with pre-loaded data from a list of IDs, a file containing IDs or from a column of a complexed file.
+
+**Description**
+
+This tool allows to map your gene/protein list to the Reactome pathway browser (visualize and interact with biological pathways) via a web service with pre-loaded data from your list of IDs
+
+-----
+
+**Input** 
+
+A list of gene/protein IDs. List of IDs can be entered either in a copy/paste manner or by selecting a file with your IDs. 
 
-**For the rows that have more than 1 ID, only the first one is taken into account.**
+ID types allowed are: UniProt accNumber (e.g. O75391), Entrez gene ID (e.g. 8086) and gene name (e.g. TP53, NUP58...). If you have other type of ID, please use the ID_Converter tool of ProteoRE.
+
+-----
+
+**Parameters**
 
-**Supported IDs: Uniprot accession number (e.g. P01023), Entrez gene ID (e.g.7157), gene name (e.g. AQP7). If there is any ID containing invalid characters, it will be removed from the queue and placed in "Invalid identifiers" file.**
+"Select species": can be Human (Homo sapiens), Mouse (Mouse musculus) or Rat (Rattus norvegicus)
+
+-----
+
+**Output**
+
+To access results, click on the "View data" icon (from the item created in your history panel), then click on the "Analyze" button in the central panel will directly display the results in the Reactome pathway browser.  
 
 -----
 
@@ -71,17 +98,19 @@
 
 **Authors** 
 
-Fabregat et al. 2017 PMID: 29145629 (https://www.ncbi.nlm.nih.gov/pubmed/29145629)
+Fabregat et al., The Reactome Pathway Knowledgebase. Nucleic Acids Res. 2018. 46(D1):D649-D655. doi: 10.1093/nar/gkx1132. PubMed PMID: 29145629
 
-Milacic et al. 2012 PMID:24213504 (https://www.ncbi.nlm.nih.gov/pubmed/24243840)
+-----
 
 .. class:: infomark
 
 **Galaxy integration**
 
-T.P. Lien Nguyen, Florence Combes, Yves Vandenbrouck CEA, INSERM, CNRS, Grenoble-Alpes University, BIG Institute, FR
+T.P. Lien Nguyen, Florence Combes, Yves Vandenbrouck - CEA, INSERM, CNRS, Grenoble-Alpes University, BIG Institute, FR
 
-Sandra Dérozier, Olivier Rué, Christophe Caron, Valentin Loux INRA, Paris-Saclay University, MAIAGE Unit,Migale Bioinformatics platform,
+Sandra Dérozier, Olivier Rué, Christophe Caron, Valentin Loux - INRA, Paris-Saclay University, MAIAGE Unit, Migale Bioinformatics platform, FR
+
+This work has been partially funded through the French National Agency for Research (ANR) IFB project.
 
 Contact support@proteore.org for any questions or concerns about the Galaxy implementation of this tool.
     ]]></help>
--- a/template.html	Tue Apr 10 04:35:05 2018 -0400
+++ b/template.html	Tue Dec 18 10:03:50 2018 -0500
@@ -35,7 +35,7 @@
 
     <p>Please click the button to execute the analysis:</p>
 
-    <form action="http://www.reactome.org/PathwayBrowser/#/DTAB=AN&ANALYSIS={token}" target="_blank">
+    <form action="http://www.reactome.org/PathwayBrowser/#/SPECIES={species}&DTAB=AN&ANALYSIS={token}" target="_blank">
     
     <button>Analyse</button>