annotate synapse_query.xml @ 2:a104cc98359c

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:34:37 -0400
parents
children 93c4d2fad9af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
a104cc98359c Uploaded
kellrott
parents:
diff changeset
1 <tool id="synapse_query" name="Synapse Query" version="1.0">
a104cc98359c Uploaded
kellrott
parents:
diff changeset
2 <description>Query Synapse</description>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
3 <command interpreter="python">$script_file
a104cc98359c Uploaded
kellrott
parents:
diff changeset
4 #if str( $user ) != '':
a104cc98359c Uploaded
kellrott
parents:
diff changeset
5 -u "$user"
a104cc98359c Uploaded
kellrott
parents:
diff changeset
6 #end if
a104cc98359c Uploaded
kellrott
parents:
diff changeset
7
a104cc98359c Uploaded
kellrott
parents:
diff changeset
8 #if str( $pass ) != '':
a104cc98359c Uploaded
kellrott
parents:
diff changeset
9 -p "$pass"
a104cc98359c Uploaded
kellrott
parents:
diff changeset
10 #end if
a104cc98359c Uploaded
kellrott
parents:
diff changeset
11 -o $outfile
a104cc98359c Uploaded
kellrott
parents:
diff changeset
12 </command>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
13 <inputs>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
14 <param name="user" type="text" size="90" label="Username"/>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
15 <param name="pass" type="text" size="90" label="Password"/>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
16 <param name="query" type="text" area="True" size="5x35" label="Query">
a104cc98359c Uploaded
kellrott
parents:
diff changeset
17 <sanitizer>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
18 <valid initial="string.printable">
a104cc98359c Uploaded
kellrott
parents:
diff changeset
19 <remove value="&quot;"/>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
20 </valid>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
21 <mapping initial="none">
a104cc98359c Uploaded
kellrott
parents:
diff changeset
22 <add source="&quot;" target="&apos;"/>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
23 </mapping>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
24 </sanitizer>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
25 </param>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
26 </inputs>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
27 <outputs>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
28 <data format="txt" name="outfile" />
a104cc98359c Uploaded
kellrott
parents:
diff changeset
29 </outputs>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
30 <configfiles>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
31 <configfile name="script_file"><![CDATA[#!/usr/bin/env python
a104cc98359c Uploaded
kellrott
parents:
diff changeset
32 rcode="""
a104cc98359c Uploaded
kellrott
parents:
diff changeset
33 library('getopt');
a104cc98359c Uploaded
kellrott
parents:
diff changeset
34 library(affy)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
35 require(synapseClient)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
36
a104cc98359c Uploaded
kellrott
parents:
diff changeset
37 opt = getopt(c(
a104cc98359c Uploaded
kellrott
parents:
diff changeset
38 'user', 'u', 2, "character",
a104cc98359c Uploaded
kellrott
parents:
diff changeset
39 'pass', 'p', 2, "character",
a104cc98359c Uploaded
kellrott
parents:
diff changeset
40 'outfile', 'o', 2, "character"
a104cc98359c Uploaded
kellrott
parents:
diff changeset
41 ));
a104cc98359c Uploaded
kellrott
parents:
diff changeset
42
a104cc98359c Uploaded
kellrott
parents:
diff changeset
43 query <- "${query}";
a104cc98359c Uploaded
kellrott
parents:
diff changeset
44 cat(query)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
45 if ( !is.null(opt\$user) && !is.null(opt\$pass)) {
a104cc98359c Uploaded
kellrott
parents:
diff changeset
46 synapseLogin(username=user, password=pass)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
47 }
a104cc98359c Uploaded
kellrott
parents:
diff changeset
48
a104cc98359c Uploaded
kellrott
parents:
diff changeset
49 query.out <- synapseQuery(query);
a104cc98359c Uploaded
kellrott
parents:
diff changeset
50 write.table(query.out, quote=F, file=opt\$outfile, row.name=F, sep="\\t")
a104cc98359c Uploaded
kellrott
parents:
diff changeset
51
a104cc98359c Uploaded
kellrott
parents:
diff changeset
52 """
a104cc98359c Uploaded
kellrott
parents:
diff changeset
53 import tempfile
a104cc98359c Uploaded
kellrott
parents:
diff changeset
54 import os
a104cc98359c Uploaded
kellrott
parents:
diff changeset
55 import sys
a104cc98359c Uploaded
kellrott
parents:
diff changeset
56 import subprocess
a104cc98359c Uploaded
kellrott
parents:
diff changeset
57
a104cc98359c Uploaded
kellrott
parents:
diff changeset
58 h, path = tempfile.mkstemp()
a104cc98359c Uploaded
kellrott
parents:
diff changeset
59 os.write(h,rcode)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
60 os.close(h)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
61
a104cc98359c Uploaded
kellrott
parents:
diff changeset
62 proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], stderr=subprocess.PIPE, stdout=subprocess.PIPE )
a104cc98359c Uploaded
kellrott
parents:
diff changeset
63 (stdoutdata, stderrdata) = proc.communicate()
a104cc98359c Uploaded
kellrott
parents:
diff changeset
64 if proc.returncode:
a104cc98359c Uploaded
kellrott
parents:
diff changeset
65 sys.stderr.write(stderrdata)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
66 sys.stdout.write(stdoutdata)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
67 os.unlink(path)
a104cc98359c Uploaded
kellrott
parents:
diff changeset
68
a104cc98359c Uploaded
kellrott
parents:
diff changeset
69
a104cc98359c Uploaded
kellrott
parents:
diff changeset
70 ]]></configfile>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
71 </configfiles>
a104cc98359c Uploaded
kellrott
parents:
diff changeset
72 </tool>