annotate synapse_create.xml @ 1:7a60e992bfb0

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:34:14 -0400
parents 83173eca36b7
children 93c4d2fad9af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
1 <tool id="synapse_create" name="Synapse Create" version="1.0">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
2 <description>Create Synapse</description>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
3 <command interpreter="python">$script_file</command>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
4 <inputs>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
5 <param name="user" type="text" size="90" label="Username"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
6 <param name="pass" type="text" size="90" label="Password"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
7 <param name="name" type="text" size="90" label="Name"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
8 <param name="attachment" type="data" optional="true" label="Attachment"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
9 <param name="attachment_name" type="text" size="90" optional="true" label="Attachment Name"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
10 <param name="etype" type="select" label="Entity Type">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
11 <option value="Project">Project</option>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
12 <option value="Study">Study</option>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
13 <option value="Data">Data</option>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
14 </param>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
15 <repeat name="properties" title="Properties">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
16 <param name="name" type="text" size="90" label="Name"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
17 <param name="value" type="text" size="90" label="Value">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
18 <sanitizer>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
19 <valid initial="string.printable">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
20 <remove value="&quot;"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
21 </valid>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
22 <mapping initial="none">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
23 <add source="&quot;" target="\&quot;"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
24 </mapping>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
25 </sanitizer>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
26 </param>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
27 </repeat>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
28
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
29 <repeat name="annotations" title="Annotations">
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
30 <param name="name" type="text" size="90" label="Name"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
31 <param name="value" type="text" size="90" label="Value"/>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
32 </repeat>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
33
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
34 </inputs>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
35 <outputs>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
36 <data format="txt" name="outfile" />
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
37 </outputs>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
38 <configfiles>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
39 <configfile name="script_file"><![CDATA[#!/usr/bin/env python
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
40 rcode="""
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
41 require(synapseClient)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
42
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
43 if (nchar("$user") > 0 && nchar("$pass") > 0) {
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
44 synapseLogin(username="$user", password="$pass")
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
45 }
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
46
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
47 ent <- ${etype}( list(name="${name}") )
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
48
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
49 #for $a in $annotations:
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
50 annotValue(ent, "${a.name}") <- "${a.value}"
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
51 #end for
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
52
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
53 #for a in $properties:
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
54 propertyValue(ent, "${a.name}") <- "${a.value}"
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
55 #end for
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
56
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
57 ent <- createEntity(ent)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
58
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
59 #if $attachment != 'None'
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
60 #if $attachment_name == '':
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
61 ent <- addFile(ent, "${attachment}")
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
62 #else
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
63 ent <- addFile(ent, "${attachment}", "${attachment_name}")
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
64 #end if
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
65 #end if
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
66
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
67 ent <- storeEntity(ent)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
68
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
69 write(properties(ent)\$id, file="${outfile}");
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
70
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
71 """
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
72
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
73
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
74 import tempfile
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
75 import os
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
76 import sys
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
77 import subprocess
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
78
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
79 h, path = tempfile.mkstemp()
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
80 os.write(h,rcode)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
81 os.close(h)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
82
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
83 proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], stderr=subprocess.PIPE, stdout=subprocess.PIPE )
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
84 (stdoutdata, stderrdata) = proc.communicate()
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
85 if proc.returncode:
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
86 sys.stderr.write(stderrdata)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
87 sys.stdout.write(stdoutdata)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
88 os.unlink(path)
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
89
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
90 ]]></configfile>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
91 </configfiles>
83173eca36b7 Uploaded
kellrott
parents:
diff changeset
92 </tool>