changeset 0:a9793e52a3ef draft

Uploaded
author bernhardlutz
date Sun, 23 Mar 2014 09:27:27 -0400
parents
children 954a489c1606
files rest_tool.py rest_tool.xml test-data/bsp_graph.gml~ tool_dependencies.xml
diffstat 4 files changed, 128 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rest_tool.py	Sun Mar 23 09:27:27 2014 -0400
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# Aufruf convert_graph.py --type type --id id  --outformat format
+
+import sys, os
+import networkx as nx
+import argparse
+import json
+
+from xgmml_networkx import XGMMLParserHelper, XGMMLWriter
+from networkx.readwrite import json_graph
+
+#supported graph_types
+output_types = ["tsv", "csv", "png", "json", "txt", "xml", "sdf", "asnt", "asnb", "jsonp"]
+
+def main(args):
+    
+if __name__ == "__main__":
+    
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--type', type=str,
+        help="That you want BioAssay Compund ...")
+    parser.add_argument('--id', type=str,
+        help="Specify the format of the input graph")
+    parser.add_argument('--outformat', type=str,
+        help="Specify the format of the output", choices = output_types)
+    if len(sys.argv) < 6:
+        print "Too few arguments..."
+        parser.print_help()
+        exit(1)
+    args = parser.parse_args()
+    main( args )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rest_tool.xml	Sun Mar 23 09:27:27 2014 -0400
@@ -0,0 +1,43 @@
+<tool id="rest_tool" name="Fetch Data from pubchem" version="0.1.0">
+    <description>Fetch pubchem data</description>
+    <version_command>echo "0.1.0"</version_command>
+    <requirements>
+        <requirement type="set_environment">REST_TOOL_SCRIPT_PATH</requirement>
+    </requirements>
+    <command>
+        python \$GRAPHCONVERTER_SCRIPT_PATH/rest_tool.py --id $id --type $input_type --outformat $output_format
+    </command>
+
+    <inputs>
+        <param format="txt" name="id" type="text" label="Specify the ID" />
+        <param name="input_type" multiple="false" type="select" label="Input Type">
+            <option value="bioassay">BioAssay</option>
+            <option value="compound">Compound</option>
+        </param>
+        <param name="output_format" type="select" label="Output Format">
+                <option value="tsv">tsv</option>
+                <option value="csv">csv</option>
+                <option value="txt">txt</option>
+                <option value="png">png</option>
+                <option value="json">json</option>
+        </param>
+    </inputs>
+    <outputs>
+        <data format="csv" name="output">
+            <change_format>
+                <when input="output_format" value="tsv" format="tsv" />
+                <when input="output_format" value="png" format="png" />
+                <when input="output_format" value="csv" format="csv" />
+                <when input="output_format" value="txt" format="txt" />
+                <when input="output_format" value="json" format="json" />
+            </change_format>
+        </data>
+    </outputs>
+    <tests>
+    </tests>
+    <help>
+**What it does**
+
+This tool fetches data from pubchem
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/bsp_graph.gml~	Sun Mar 23 09:27:27 2014 -0400
@@ -0,0 +1,49 @@
+    Creator "yFiles"  
+    Version 2.2  
+    graph  
+    [ hierarchic  1  
+      directed  1  
+      node  
+      [ id  0  
+        graphics  
+        [ x 200.0     
+          y 0.0  
+        ]  
+        LabelGraphics  
+        [ text  "January" ]  
+      ]  
+      node  
+      [ id  1  
+        graphics  
+        [ x 425.0  
+          y 75.0  
+        ]  
+        LabelGraphics  
+        [ text  "December"  ]  
+      ]  
+      edge  
+      [ source  1  
+        target  0  
+        graphics  
+        [ Line  
+          [ point  
+            [ x 425.0  
+              y 75.0  
+            ]  
+            point  
+            [ x 425.0  
+              y 0.0  
+            ]  
+            point  
+            [ x 200.0  
+              y 0.0  
+            ]  
+          ]  
+        ]  
+        LabelGraphics  
+        [ text  "Happy New Year!"  
+          model "six_pos"  
+          position  "head"  
+        ]  
+      ]  
+    ]  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Sun Mar 23 09:27:27 2014 -0400
@@ -0,0 +1,5 @@
+<tool_dependency>
+    <set_environment version="1.0">
+        <environment_variable name="REST_TOOL_SCRIPT_PATH" action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable>
+    </set_environment>
+</tool_dependency>