annotate WebServiceToolWorkflow/generateClient.py~ @ 0:e7482c82796e default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author ganjoo
date Tue, 07 Jun 2011 17:34:26 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
1 import warnings
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
2
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
3 with warnings.catch_warnings():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
4 warnings.simplefilter("ignore")
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
5 import platform
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
6
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
7 from jpype._jpackage import JPackage
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
8 from jpype import *
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
9 import os.path
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
10 import sys
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
11 import string
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
12 from edit_tool_conf import *
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
13
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
14 class ClientGenerator(object):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
15
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
16 #instantiate a client for invocation of the selected method of a Web service in workflows
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
17 def __init__(self,url,methodName,resourceName,fileName):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
18 self.methodName = methodName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
19 self.resourceName=resourceName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
20 self.Ofile = fileName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
21 #replace '__tilda__' with '~'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
22 if(url.find('__tilda__')>-1):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
23 ulist = url.split('__tilda__')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
24 url = '~'.join(ulist)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
25 self.url = url
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
26
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
27 #replace '**' with ' '
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
28 def formatString(self,string):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
29 l = string.split(' ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
30 return '**'.join(l)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
31
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
32 #generates a xml describing a client capable of invoking a Web service described
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
33 #using a WADL document. Places this xml tool under ./workflowclients/
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
34 def wadlClient(self):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
35 ##parse wadl
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
36 #javahome = os.environ.get('JAVA_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
37 #galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
38 #classpath= galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/bin'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
39 #jarpath = galaxyhome + '/tools/WebServiceToolWorkflow/ParserForWADL/lib/'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
40 #machine = platform.machine()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
41
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
42 #if machine == 'x86_64' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
43 # print 'a'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
44 # startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
45 #elif machine == 'i686' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
46 # print 'b'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
47 # startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
48 #elif machine == 'sun4u' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
49 # startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
50 #else :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
51 # print 'c'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
52 # System.exit("Could not identify machine, please specify path to libjvm.so")
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
53
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
54
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
55 pkg=JPackage('lsdis')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
56 urlToPass=java.net.URL(self.url)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
57 wadlUrl = self.url
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
58
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
59 webserviceId = self.methodName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
60 resUrl = self.resourceName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
61
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
62
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
63 urls = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
64 methods = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
65 params = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
66
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
67 #invoke the WADL parser packaged with this tool.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
68 WADLParserDriver=pkg.WADLParserDriver
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
69 wPD=WADLParserDriver()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
70 wPD.parse(urlToPass)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
71 urls = wPD.getUrl()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
72 methods = wPD.getCompleteMethodList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
73
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
74 #write into the output file information about the method and Web service to be invoked.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
75 f=open(self.Ofile,'w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
76 f.write(wadlUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
77 f.write('\n'+ resUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
78 f.write('\n'+webserviceId)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
79
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
80 #get parameters for the selected method of the Web service
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
81 i=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
82 for method in methods:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
83 f.write('\n in methods')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
84 x = str(method.getId())
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
85 y = str(urls.get(i))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
86 if x == webserviceId :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
87 f.write('\n method matched')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
88 f.write('\n y is' + y + ', resUrl is '+resUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
89 if y == resUrl :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
90 f.write('res matched')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
91 params = method.getRequest().getParams()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
92 break
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
93 i=i+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
94
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
95
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
96
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
97 galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
98
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
99 #./workflowclients/ClientCount.xml keeps the count of the clients/tools currently registered in Galaxy for Web service invocation.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
100 #read the count and increment it.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
101 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/workflowclients/ClientCount.xml','r')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
102 clientCountFile.readline()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
103 clientCountStr = clientCountFile.read(1)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
104 clientCount=string.atoi(clientCountStr)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
105 clientCount=clientCount+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
106 clientCountFile.close()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
107
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
108 clientCountFile=open(galaxyhome+'/tools/WebServiceToolWorkflow/workflowclients/ClientCount.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
109 clientCountFile.write('<count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
110 clientCountFile.write(str(clientCount))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
111 clientCountFile.write('</count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
112
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
113 #include the count in the tool's name and id to uniquely identify it.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
114 clientName = 'client_'+ str(clientCount)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
115
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
116 #create a new xml file under ./workflowclients/
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
117 clientXml=open(galaxyhome+'/tools/WebServiceToolWorkflow/workflowclients/'+clientName+'.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
118 clientXml.seek(0,0)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
119
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
120 #write the tool id, name and description
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
121 clientXml.write('<tool id="' + clientName+'" name="' + self.methodName +' ">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
122 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
123
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
124 #the workflow tool/client for a REST Web service invokes ./workflowclients/client_1.py to invoke the Web service
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
125 #write the command tag to specify the arguments passed to this client_1.py
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
126 clientXml.write(' <command interpreter="python">\n client_1.py\n'+' #if $cond_source.optional_param_source=="no":\n $output\n ' +resUrl+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
127
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
128
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
129 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
130 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
131 if param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
132 clientXml.write(' '+self.formatString(param.getName())+'\n #if $source'+str(j)+'.source'+str(j)+'_source=="user":\n $source'+str(j)+'.user_param'+str(j)+'\n #else:\n fileInput\n $source' + str(j) + '.cached_param' + str(j)+'\n #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
133 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
134
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
135 clientXml.write(' #else:\n $output\n ' +resUrl+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
136 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
137 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
138 if param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
139 clientXml.write(' '+self.formatString(param.getName())+'\n #if $source'+str(j)+'.source'+str(j)+'_source=="user":\n $source'+str(j)+'.user_param'+str(j)+'\n #else:\n fileInput\n $source' + str(j) + '.cached_param' + str(j)+'\n #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
140 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
141
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
142 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
143 if not param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
144 clientXml.write(' '+self.formatString(param.getName())+'\n #if $cond_source.source'+str(j)+'.source'+str(j)+'_source=="user":\n $cond_source.source'+str(j)+'.user_param'+str(j)+'\n #else:\n fileInput\n $cond_source.source' + str(j) + '.cached_param' + str(j)+'\n #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
145 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
146
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
147 clientXml.write(' #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
148 clientXml.write('</command>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
149
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
150 #start writing inputs
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
151 clientXml.write(' <inputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
152
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
153 #create a param for each required parameter described in the WADL. Check if defaults are specified. Create param such that
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
154 #it can either be given a value manually or the value can be taken from a previous step.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
155 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
156 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
157 if param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
158 pName = param.getName()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
159 for doc in param.getDocs():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
160 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT":
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
161 pName = doc.getInnerText()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
162
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
163 clientXml.write('<conditional name="source'+str(j)+'">\n <param name="source' + str(j)+'_source" type="select" label="'+pName+' Source"> \n <option value="cached" selected="true">Param value will be taken from previous step</option> \n <option value="user">User will enter the param value</option> \n </param>\n <when value="user">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
164 if param.getOptions().size()==0:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
165 clientXml.write(' <param format="text" size = "150" name = "user_param'+str(j)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
166 if not param.getDefault1() == None:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
167 clientXml.write('value="'+param.getDefault1()+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
168 clientXml.write('type="text" label="Enter '+pName+'" help="see tip below" />\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
169 else:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
170 clientXml.write(' <param name="user_param'+str(j)+'" type="select" label="Select '+pName+'" help="see tip below">\n' )
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
171 for option in param.getOptions():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
172 clientXml.write(' <option value="'+self.formatString(option.getName())+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
173 if option.getName() == param.getDefault1():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
174 clientXml.write('selected="true"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
175 clientXml.write('>'+option.getName()+'</option>\n ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
176 clientXml.write(' </param> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
177 clientXml.write(' </when>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
178 clientXml.write(' <when value="cached">\n <param name = "cached_param'+ str(j)+'" type="data" label="Choose the step from which to get the parameter ' + pName + '"/> \n </when></conditional>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
179 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
180
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
181 #create a conditional param for each optional parameter described in the WADL. Again the param can be given a value manually or the value can be taken from
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
182 #a previous step.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
183 clientXml.write(' <conditional name="cond_source">\n <param name="optional_param_source" type="select" label="Display Additional Parameters"> \n <option value="no" selected="true">no</option> \n <option value="yes">yes</option> \n </param> \n <when value="no"> \n </when>\n <when value="yes"> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
184
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
185 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
186 if not param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
187 pName = param.getName()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
188 for doc in param.getDocs():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
189 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT":
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
190 pName = doc.getInnerText()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
191
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
192 clientXml.write('\n<conditional name="source'+str(j)+'">\n <param name="source' + str(j)+'_source" type="select" label="'+pName+' Source"> \n <option value="cached" selected="true">Param value will be taken from previous step</option> \n <option value="user">User will enter the param value</option> \n</param>\n <when value="user">')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
193 if param.getOptions().size()==0:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
194 clientXml.write('<param format="text" size = "150" name = "user_param'+str(j)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
195 if not param.getDefault1() == None:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
196 clientXml.write('value="'+param.getDefault1()+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
197 clientXml.write('type="text" label="Enter '+pName+'" help="see tip below" />\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
198 else:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
199 clientXml.write('<param name="user_param'+str(j)+'" type="select" label="Select '+pName+'" help="see tip below">\n' )
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
200 for option in param.getOptions():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
201 clientXml.write(' <option value="'+self.formatString(option.getName())+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
202 if option.getName() == param.getDefault1():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
203 clientXml.write('selected="true"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
204 clientXml.write('>'+option.getName()+'</option>\n ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
205 clientXml.write(' </param> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
206 clientXml.write(' </when>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
207 clientXml.write('<when value="cached">\n <param name = "cached_param'+ str(j)+'" type="data" label="Choose the step from which to get the parameter ' + pName + '"/> \n </when></conditional>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
208 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
209
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
210
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
211
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
212 clientXml.write(' </when>\n </conditional>\n</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
213
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
214 #write information about each parameter in the help section
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
215 clientXml.write(' <help>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
216 clientXml.write('Replace white space with ** in all parameter values\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
217
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
218 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
219 if param.isRequired():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
220 pName = param.getName()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
221 for doc in param.getDocs():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
222 if doc.getTitle()=="prompt" or doc.getTitle()=="Prompt" or doc.getTitle()=="PROMPT":
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
223 pName = doc.getInnerText()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
224 clientXml.write('\n.. class:: infomark\n\n**TIP:** '+ pName +' type is ' + param.getType()+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
225
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
226 clientXml.write(' </help>\n</tool>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
227
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
228 #adds the newly created tool to tool_conf.xml in Galaxy under the 'Web Service Workflow Tools' section.
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
229 editor = editToolConfig()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
230 editor.addTool(clientName)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
231
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
232
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
233 def sawadlClient(self):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
234 ##parse sawadl
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
235 javahome = os.environ.get('JAVA_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
236 galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
237 classpath= galaxyhome + '/tools/WebServiceTool/lib/SAWADLParser/bin'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
238 jarpath = galaxyhome + '/tools/WebServiceTool/lib/'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
239 machine = platform.machine()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
240
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
241 #if machine == 'x86_64' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
242 # print 'a'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
243 # startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
244 #elif machine == 'i686' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
245 # print 'b'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
246 # startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
247 #elif machine == 'sun4u' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
248 # startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
249 #else :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
250 # print 'c'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
251 # System.exit("Could not identify machine, please specify path to libjvm.so")
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
252
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
253
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
254 pkg=JPackage('edu.uga.cs.lsdis.meteors.wadls')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
255 pkgModel =JPackage('org.semanticweb.owlapi.model')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
256 pkgApiBinding =JPackage('org.semanticweb.owlapi.apibinding')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
257 pkgVocab = JPackage('org.semanticweb.owlapi.vocab')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
258
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
259 DOCUMENT_IRI = "http://cs.uga.edu/~ganjoo/galaxy/EDAM.owl"
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
260
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
261 sawadlUrl = self.url
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
262
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
263 webserviceId = self.methodName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
264 resUrl = self.resourceName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
265
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
266 urls = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
267 methods = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
268 params = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
269 annotationSet = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
270
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
271 SAWADLParserDriver=pkg.SAWADLParserDriver
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
272 sawPD=SAWADLParserDriver()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
273 sawPD.parse(sawadlUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
274 urls = sawPD.getUrl()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
275 methods = sawPD.getCompleteMethodList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
276
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
277 IRI = pkgModel.IRI
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
278 OWLRDFVocabulary = pkgVocab.OWLRDFVocabulary
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
279 OWLManager = pkgApiBinding.OWLManager
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
280 OWLLiteral = pkgModel.OWLLiteral
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
281 owlOntManager = OWLManager.createOWLOntologyManager()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
282 ontology = owlOntManager.loadOntologyFromOntologyDocument(IRI.create(DOCUMENT_IRI))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
283 dataFactory = owlOntManager.getOWLDataFactory()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
284 propertyComment = dataFactory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI())
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
285
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
286 f=open(self.Ofile,'w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
287 f.write(sawadlUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
288 f.write('\n'+ resUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
289 f.write('\n'+webserviceId)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
290
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
291
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
292 i=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
293 for method in methods:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
294 x = str(method.getName())
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
295 y = str(urls.get(i))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
296 if x == webserviceId :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
297 f.write('method matched')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
298 if y == resUrl :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
299 f.write('res matched')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
300 params = method.getRequest().getParamList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
301 break
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
302 i=i+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
303
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
304
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
305
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
306
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
307 ##generate client's xml
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
308 galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
309
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
310 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','r')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
311 clientCountFile.readline()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
312 clientCountStr = clientCountFile.read(1)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
313 clientCount=string.atoi(clientCountStr)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
314 clientCount=clientCount+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
315 clientCountFile.close()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
316
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
317 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
318 clientCountFile.write('<count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
319 clientCountFile.write(str(clientCount))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
320 clientCountFile.write('</count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
321
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
322
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
323
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
324
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
325 clientName = 'client_'+ str(clientCount)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
326
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
327 clientXml=open(galaxyhome+'/tools/WebServiceToolWorkflow/workflowclients/'+clientName+'.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
328 clientXml.seek(0,0)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
329
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
330 clientXml.write('<tool id="' + clientName+'" name="' + self.methodName +'">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
331 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
332
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
333
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
334 clientXml.write(' <command interpreter="python">\n #client_1.py \n'+' $output \n ' +resUrl+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
335 ##write such that the parameters passed to client1.py(change name to clientName.py) are dependent on a for loop
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
336
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
337
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
338 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
339 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
340 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE':
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
341 clientXml.write(' '+self.formatString(param.getName())+'\n#if $source'+str(j)+'.source'+str(j)+'_source=="user" $source'+str(j)+'.user_param'+str(j)+' #else $source' + str(j) + '.cached_param' + str(j)+' #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
342 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
343 clientXml.write('#if $cond_source.optional_param_source=="yes"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
344
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
345 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
346 if not param.getRequired()=='true' and not param.getRequired()=='True' and not param.getRequired()=='TRUE':
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
347 clientXml.write(' '+self.formatString(param.getName())+'\n#if $cond_source.source'+str(j)+'.source'+str(j)+'_source=="user" $cond_source.source'+str(j)+'.user_param'+str(j)+' #else $cond_source.source' + str(j) + '.cached_param' + str(j)+' #end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
348 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
349
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
350 clientXml.write('#else \n#end if\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
351 clientXml.write('</command>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
352
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
353 ##write inputs depending on required or not. if not required den dont display
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
354 ##if required- den check default value, and if options exist.Depending on that
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
355 ##decide the type of parameter and options
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
356 clientXml.write(' <inputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
357
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
358
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
359 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
360 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
361 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE':
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
362 clientXml.write('<conditional name="source'+str(j)+'">\n <param name="source' + str(j)+'_source" type="select" label="'+param.getName()+' Source"> \n <option value="cached" selected="true">Param value will be taken from previous step</option> \n <option value="user">User will enter the param value</option> \n </param>\n <when value="user">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
363 if param.getOptionvalue().size()==0:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
364 clientXml.write(' <param format="text" size = "150" name = "user_param'+str(j)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
365 if not param.getDefault1() == None:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
366 clientXml.write('value="'+param.getDefault1()+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
367 clientXml.write('type="text" label="Enter '+param.getName()+'" help="see tip below" />\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
368 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
369 else:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
370 clientXml.write(' <param name="user_param'+str(j)+'" type="select" label="Select '+param.getName()+'" help="see tip below">\n' )
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
371 for option in param.getOptionvalue():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
372 clientXml.write(' <option value="'+self.formatString(option)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
373 if option == param.getDefault1():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
374 clientXml.write('selected="true"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
375 clientXml.write('>'+option+'</option>\n ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
376 clientXml.write(' </param> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
377 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
378 clientXml.write(' </when>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
379 clientXml.write(' <when value="cached">\n <param name = "cached_param'+ str(j)+'" type="data" label="Choose the step from which to get the parameter ' + param.getName() + '"/> \n </when></conditional>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
380
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
381 clientXml.write(' <conditional name="cond_source">\n <param name="optional_param_source" type="select" label="Display Additional Parameters"> \n <option value="no" selected="true">no</option> \n <option value="yes">yes</option> \n </param> \n <when value="no"> \n </when>\n <when value="yes"> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
382
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
383 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
384 if not param.getRequired()=='true' and not param.getRequired()=='True' and not param.getRequired()=='TRUE':
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
385 clientXml.write('<conditional name="source'+str(j)+'">\n <param name="source' + str(j)+'_source" type="select" label="'+param.getName()+' Source"> \n <option value="cached" selected="true">Param value will be taken from previous step</option> \n <option value="user">User will enter the param value</option> \n </param>\n <when value="user">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
386 if param.getOptionvalue().size()==0:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
387 clientXml.write(' <param format="text" size = "150" name = "user_param'+str(j)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
388 if not param.getDefault1() == None:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
389 clientXml.write('value="'+param.getDefault1()+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
390 clientXml.write('type="text" label="Enter '+param.getName()+'" help="see tip below" />\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
391 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
392 else:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
393 clientXml.write(' <param name="user_param'+str(j)+'" type="select" label="Select'+param.getName()+'" help="see tip below">\n' )
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
394 for option in param.getOptionvalue():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
395 clientXml.write(' <option value="'+self.formatString(option)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
396 if option == param.getDefault1():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
397 clientXml.write('selected="true"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
398 clientXml.write('>'+option+'</option>\n ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
399 clientXml.write(' </param> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
400 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
401 clientXml.write(' </when>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
402 clientXml.write(' <when value="cached">\n <param name = "cached_param'+ str(j)+'" type="data" label="Choose the step from which to get the parameter ' + param.getName() + '"/> \n </when></conditional>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
403
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
404 clientXml.write(' </when>\n </conditional>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
405
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
406 clientXml.write('</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
407
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
408 clientXml.write(' <help>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
409 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
410 if param.getRequired()=='true' or param.getRequired()=='True' or param.getRequired()=='TRUE':
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
411 clientXml.write('\n.. class:: infomark\n\n**TIP:** About '+ param.getName() +': type is ' + param.getType())
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
412
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
413 modelRef = sawPD.getCompleteModelReference(param)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
414 if not modelRef is None:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
415 paramClass = dataFactory.getOWLClass(IRI.create(modelRef));
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
416 annotationSet = paramClass.getAnnotations(ontology,propertyComment)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
417 for annotation in annotationSet:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
418 if isinstance(annotation.getValue(),OWLLiteral):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
419 val = annotation.getValue()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
420 if val.isOWLStringLiteral() and not val.isOWLTypedLiteral():
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
421 print 'val.getLiteral()=' + val.getLiteral()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
422 clientXml.write(', description from ontology is "' + val.getLiteral()+'"')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
423 break
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
424 clientXml.write('\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
425 clientXml.write(' </help>\n</tool>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
426 editor = editToolConfig()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
427 editor.addTool(clientName)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
428
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
429 ##later add help feature
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
430
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
431 def wsdlClient(self):
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
432 ##parse wadl
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
433 javahome = os.environ.get('JAVA_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
434 galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
435 classpath= galaxyhome + '/tools/WebServiceTool/WodenWSDLParser/bin'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
436 jarpath = galaxyhome + '/tools/WebServiceTool/WodenWSDLParser/lib/'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
437 machine = platform.machine()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
438
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
439 if machine == 'x86_64' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
440 print 'a'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
441 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
442 elif machine == 'i686' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
443 print 'b'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
444 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
445 elif machine == 'sun4u' :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
446 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
447 else :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
448 print 'c'
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
449 System.exit("Could not identify machine, please specify path to libjvm.so")
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
450
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
451
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
452 pkg=JPackage('lsdis')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
453 wsdlUrl = self.url
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
454
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
455 webserviceId = self.methodName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
456 resUrl = self.resourceName
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
457
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
458 urls = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
459 methods = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
460 params = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
461 paramTypes = []
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
462
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
463 WSDLParserDriver =pkg.WSDLParserDriver
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
464 wPD=WSDLParserDriver()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
465 wPD.parse(wsdlUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
466 methods = wPD.getCompleteMethodList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
467 urls = wPD.getUrl()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
468
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
469 f=open(self.Ofile,'w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
470 f.write(wsdlUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
471 f.write('\n'+ resUrl)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
472 f.write('\n'+webserviceId)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
473
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
474
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
475 i=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
476 for method in methods:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
477 x = str(method.getName().getLocalPart())
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
478 if x == webserviceId :
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
479 wPD.getParameters(x)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
480 f.write('method matched')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
481 paramTypes = wPD.getParamTypeList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
482 params = wPD.getParamList()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
483 break
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
484 i=i+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
485
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
486
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
487
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
488
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
489 ##generate client's xml
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
490 galaxyhome=os.environ.get('GALAXY_HOME')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
491
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
492 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','r')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
493 clientCountFile.readline()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
494 clientCountStr = clientCountFile.read(1)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
495 clientCount=string.atoi(clientCountStr)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
496 clientCount=clientCount+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
497 clientCountFile.close()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
498
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
499 clientCountFile=open(galaxyhome+'/tools/WebServiceTool/clients/ClientCount.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
500 clientCountFile.write('<count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
501 clientCountFile.write(str(clientCount))
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
502 clientCountFile.write('</count> \n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
503
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
504
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
505
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
506
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
507 clientName = 'client_'+ str(clientCount)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
508
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
509 clientXml=open(galaxyhome+'/tools/WebServiceTool/clients/'+clientName+'.xml','w')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
510 clientXml.seek(0,0)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
511
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
512 clientXml.write('<tool id="' + clientName+'" name="' + self.methodName +'">\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
513 clientXml.write(' <description> Client for method: '+self.methodName+' , Web service: '+self.url+' </description>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
514
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
515
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
516 clientXml.write(' <command interpreter="python">\n client_1.py \n'+' $output \n ' +resUrl+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
517 ##write such that the parameters passed to client1.py(change name to clientName.py) are dependent on a for loop
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
518
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
519 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
520 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
521 clientXml.write(' '+self.formatString(param)+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
522 clientXml.write(' $param' + str(j)+'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
523 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
524 clientXml.write('</command>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
525
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
526 ##write inputs depending on required or not. if not required den dont display
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
527 ##if required- den check default value, and if options exist.Depending on that
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
528 ##decide the type of parameter and options
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
529 clientXml.write(' <inputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
530
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
531 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
532 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
533 clientXml.write('<param format="text" size = "150" name = "param'+str(j)+'" ')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
534 clientXml.write('type="text" label="'+param+'" help="see tip below" />\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
535 j=j+1
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
536
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
537
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
538
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
539 clientXml.write('</inputs>\n <outputs>\n <data format="tabular" name="output" />\n </outputs>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
540
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
541 clientXml.write(' <help>\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
542
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
543 j=0
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
544 for param in params:
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
545 clientXml.write('\n.. class:: infomark\n\n**TIP:** '+ param +' type is ' + paramTypes[j] +'\n')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
546
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
547 clientXml.write(' </help>\n</tool>')
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
548 editor = editToolConfig()
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
549 editor.addTool(clientName)
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
550
e7482c82796e Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
ganjoo
parents:
diff changeset
551 ##later add help feature