0
|
1 <tool id="synapse_create" name="Synapse Create" version="1.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">
|
|
16 <param name="name" type="text" size="90" label="Name"/>
|
|
17 <param name="value" type="text" size="90" label="Value">
|
|
18 <sanitizer>
|
|
19 <valid initial="string.printable">
|
|
20 <remove value="""/>
|
|
21 </valid>
|
|
22 <mapping initial="none">
|
|
23 <add source=""" target="\""/>
|
|
24 </mapping>
|
|
25 </sanitizer>
|
|
26 </param>
|
|
27 </repeat>
|
|
28
|
|
29 <repeat name="annotations" title="Annotations">
|
|
30 <param name="name" type="text" size="90" label="Name"/>
|
|
31 <param name="value" type="text" size="90" label="Value"/>
|
|
32 </repeat>
|
|
33
|
|
34 </inputs>
|
|
35 <outputs>
|
|
36 <data format="txt" name="outfile" />
|
|
37 </outputs>
|
|
38 <configfiles>
|
|
39 <configfile name="script_file"><![CDATA[#!/usr/bin/env python
|
|
40 rcode="""
|
|
41 require(synapseClient)
|
|
42
|
|
43 if (nchar("$user") > 0 && nchar("$pass") > 0) {
|
|
44 synapseLogin(username="$user", password="$pass")
|
|
45 }
|
|
46
|
|
47 ent <- ${etype}( list(name="${name}") )
|
|
48
|
|
49 #for $a in $annotations:
|
|
50 annotValue(ent, "${a.name}") <- "${a.value}"
|
|
51 #end for
|
|
52
|
|
53 #for a in $properties:
|
|
54 propertyValue(ent, "${a.name}") <- "${a.value}"
|
|
55 #end for
|
|
56
|
|
57 ent <- createEntity(ent)
|
|
58
|
|
59 #if $attachment != 'None'
|
|
60 #if $attachment_name == '':
|
|
61 ent <- addFile(ent, "${attachment}")
|
|
62 #else
|
|
63 ent <- addFile(ent, "${attachment}", "${attachment_name}")
|
|
64 #end if
|
|
65 #end if
|
|
66
|
|
67 ent <- storeEntity(ent)
|
|
68
|
|
69 write(properties(ent)\$id, file="${outfile}");
|
|
70
|
|
71 """
|
|
72
|
|
73
|
|
74 import tempfile
|
|
75 import os
|
|
76 import sys
|
|
77 import subprocess
|
|
78
|
|
79 h, path = tempfile.mkstemp()
|
|
80 os.write(h,rcode)
|
|
81 os.close(h)
|
|
82
|
|
83 proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], stderr=subprocess.PIPE, stdout=subprocess.PIPE )
|
|
84 (stdoutdata, stderrdata) = proc.communicate()
|
|
85 if proc.returncode:
|
|
86 sys.stderr.write(stderrdata)
|
|
87 sys.stdout.write(stdoutdata)
|
|
88 os.unlink(path)
|
|
89
|
|
90 ]]></configfile>
|
|
91 </configfiles>
|
|
92 </tool>
|