annotate synapse_create.xml @ 3:93c4d2fad9af

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