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