comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/edit_tool_conf.py @ 0:049760c677de default tip

Galaxy WSExtensions added successfully
author uga-galaxy-group
date Tue, 05 Jul 2011 19:34:18 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:049760c677de
1 '''
2 @author Chaitanya Guttula, Sumedha Ganjoo
3 @see LICENSE (MIT style license file).
4 '''
5
6 import os
7
8 '''
9 Open the toolconf.xml file and adds the tool under 'Web Service Workflow Tools' that has been passed to it.
10
11 '''
12 class editToolConfig(object):
13 def addTool(self,toolName):
14 galaxyhome=os.environ.get('GALAXY_HOME')
15 f1=open(galaxyhome+'/tool_conf.xml','r')
16 f1.seek(0,0)
17 f2=open(galaxyhome+'/tool_conf_backup.xml','w')
18 f2.seek(0,0)
19
20 ##first copy everything upto WebServiceTool1.xml into another file f2
21 line = f1.readline()
22 f2.write(line)
23
24 lineStripped=line.lstrip()
25 lineStripped=lineStripped.rstrip()
26
27 #add the workflow Web service invocation tool under Web Service Workflow Tools section
28 while not lineStripped == '<section name="Select Web Service Workflow Tool" id="WebServiceWorkflow">':
29 line = f1.readline()
30 f2.write(line)
31 lineStripped = line.lstrip()
32 lineStripped=lineStripped.rstrip()
33 else:
34 print line
35
36 ## add new tool to f2
37 f2.write(' <tool file="WebServiceToolWorkflow_REST_SOAP/workflowclients/'+toolName + '.xml"/>\n')
38
39 ## copy rest of f1 into f2
40 while not lineStripped == '</toolbox>':
41 line = f1.readline()
42 f2.write(line)
43 lineStripped = line.lstrip()
44 lineStripped=lineStripped.rstrip()
45 else:
46 print line
47
48 ##close f1 and f2
49 f1.close()
50 f2.close()
51
52 ##interchange modes of f1 and f2
53 f1=open(galaxyhome+'/tool_conf.xml','w')
54 f1.seek(0,0)
55 f2=open(galaxyhome+'/tool_conf_backup.xml','r')
56 f2.seek(0,0)
57
58 line = f2.readline()
59 f1.write(line)
60
61 lineStripped=line.lstrip()
62
63 ##write entire f2 into f1 (reverse roles)
64 while not lineStripped == '</toolbox>':
65 line = f2.readline()
66 f1.write(line)
67 lineStripped = line.lstrip()
68 lineStripped=lineStripped.rstrip()
69 else:
70 print line
71
72 f1.close()
73 f2.close()