3
|
1 <tool id="synapse_create" name="Synapse Create" version="2.0.0">
|
0
|
2 <description>Create Synapse</description>
|
|
3 <command interpreter="python">$script_file</command>
|
|
4 <inputs>
|
|
5 <param name="user" type="text" size="90" label="Username"/>
|
|
6 <param name="pass" type="text" size="90" label="Password"/>
|
|
7 <param name="name" type="text" size="90" label="Name"/>
|
|
8 <param name="attachment" type="data" optional="true" label="Attachment"/>
|
|
9 <param name="attachment_name" type="text" size="90" optional="true" label="Attachment Name"/>
|
|
10 <param name="etype" type="select" label="Entity Type">
|
|
11 <option value="Project">Project</option>
|
|
12 <option value="Study">Study</option>
|
|
13 <option value="Data">Data</option>
|
|
14 </param>
|
|
15 <repeat name="properties" title="Properties">
|
3
|
16 <param name="name" type="select" size="90" label="Name">
|
|
17 <option value="name">Name</option>
|
|
18 <option value="parentId">ParentID</option>
|
|
19 <option value="description">Description</option>
|
|
20 <option value="species">Species</option>
|
|
21 <option value="numSamples">Number of Samples</option>
|
|
22 <option value="disease">Disease</option>
|
|
23 <option value="tissueType">Tissue Type</option>
|
|
24 </param>
|
|
25 <param name="value" type="text" size="90" label="Value">
|
|
26 <sanitizer>
|
|
27 <valid initial="string.printable">
|
|
28 <remove value="""/>
|
|
29 </valid>
|
|
30 <mapping initial="none">
|
|
31 <add source=""" target="\""/>
|
|
32 </mapping>
|
|
33 </sanitizer>
|
|
34 </param>
|
|
35 </repeat>
|
|
36
|
|
37 <repeat name="annotations" title="Annotations">
|
0
|
38 <param name="name" type="text" size="90" label="Name"/>
|
|
39 <param name="value" type="text" size="90" label="Value">
|
|
40 <sanitizer>
|
|
41 <valid initial="string.printable">
|
|
42 <remove value="""/>
|
|
43 </valid>
|
|
44 <mapping initial="none">
|
|
45 <add source=""" target="\""/>
|
|
46 </mapping>
|
|
47 </sanitizer>
|
|
48 </param>
|
|
49 </repeat>
|
|
50
|
|
51 </inputs>
|
|
52 <outputs>
|
|
53 <data format="txt" name="outfile" />
|
|
54 </outputs>
|
|
55 <configfiles>
|
|
56 <configfile name="script_file"><![CDATA[#!/usr/bin/env python
|
|
57 rcode="""
|
|
58 require(synapseClient)
|
|
59
|
3
|
60 galaxyClean <- function(x) {
|
|
61 y = gsub("__gt__", ">", x);
|
|
62 y = gsub("__lt__", "<", y );
|
|
63 y = gsub("__sq__", "'", y);
|
|
64 y = gsub("__dq__", "\\"",y);
|
|
65 y = gsub("__ob__", "[", y);
|
|
66 y = gsub("__cb__", "]", y);
|
|
67 y = gsub("__oc__", "{", y);
|
|
68 y = gsub("__cc__", "}", y);
|
|
69 y = gsub("__at__", "@", y);
|
|
70 y = gsub("__cn__", "\\n", y);
|
|
71 y = gsub("__cr__", "\\r", y);
|
|
72 y = gsub("__tc__", "\\t", y);
|
|
73 y = gsub("__pd__", "#", y);
|
|
74 y = gsub("__at__", "@", y);
|
|
75 return(y);
|
0
|
76 }
|
|
77
|
3
|
78 if (nchar("$user") && nchar("$pass")) {
|
|
79 synapseLogin(username=galaxyClean("$user"), password=galaxyClean("$pass"))
|
|
80 }
|
|
81
|
|
82
|
|
83 ent <- ${etype}( list(name=galaxyClean("${name}")) )
|
0
|
84
|
|
85 #for $a in $annotations:
|
3
|
86 annotValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
|
0
|
87 #end for
|
|
88
|
|
89 #for a in $properties:
|
3
|
90 propertyValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
|
0
|
91 #end for
|
|
92
|
|
93 ent <- createEntity(ent)
|
|
94
|
|
95 #if $attachment != 'None'
|
|
96 #if $attachment_name == '':
|
3
|
97 ent <- addFile(ent, galaxyClean("${attachment}"))
|
0
|
98 #else
|
3
|
99 ent <- addFile(ent, galaxyClean("${attachment}"), galaxyClean("${attachment_name}"))
|
0
|
100 #end if
|
|
101 #end if
|
|
102
|
|
103 ent <- storeEntity(ent)
|
|
104
|
3
|
105 write(properties(ent)\$id, file=galaxyClean("${outfile}"));
|
0
|
106
|
|
107 """
|
|
108
|
|
109
|
|
110 import tempfile
|
|
111 import os
|
|
112 import sys
|
|
113 import subprocess
|
|
114
|
|
115 h, path = tempfile.mkstemp()
|
|
116 os.write(h,rcode)
|
|
117 os.close(h)
|
|
118
|
|
119 proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], stderr=subprocess.PIPE, stdout=subprocess.PIPE )
|
|
120 (stdoutdata, stderrdata) = proc.communicate()
|
|
121 if proc.returncode:
|
|
122 sys.stderr.write(stderrdata)
|
|
123 sys.stdout.write(stdoutdata)
|
|
124 os.unlink(path)
|
|
125
|
|
126 ]]></configfile>
|
|
127 </configfiles>
|
3
|
128 <help>
|
|
129
|
|
130 Install R SynapseClient:
|
|
131 source('http://depot.sagebase.org/CRAN.R')
|
|
132 pkgInstall("synapseClient")
|
|
133
|
|
134 `To setup auto login (so you don't have to type in your password) <https://sagebionetworks.jira.com/wiki/display/SYNR/How+to+configure+automatic+login>`_
|
|
135
|
|
136 </help>
|
|
137
|
|
138 </tool> |