comparison synapse_download.xml @ 1:7a60e992bfb0

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:34:14 -0400
parents
children 93c4d2fad9af
comparison
equal deleted inserted replaced
0:83173eca36b7 1:7a60e992bfb0
1 <tool id="synapse_download" name="Synapse Download" version="1.0">
2 <description>Download Synapse Entity</description>
3 <command interpreter="python">$script_file
4 #if str( $user ) != '':
5 -u "$user"
6 #end if
7 #if str( $pass ) != '':
8 -p "$pass"
9 #end if
10 -s $synid
11 $data_type
12 -o $outfile
13 </command>
14 <inputs>
15 <param name="user" type="text" size="90" label="Username"/>
16 <param name="pass" type="text" size="90" label="Password"/>
17 <param name="synid" type="text" label="Synapse ID"/>
18 <param name="data_type" type="select" label="Data Type">
19 <option value="-e">Affy Eset</option>
20 <option value="-a">Attachment</option>
21 </param>
22 </inputs>
23 <outputs>
24 <data format="txt" name="outfile" label="${synid}" />
25 </outputs>
26 <configfiles>
27 <configfile name="script_file"><![CDATA[#!/usr/bin/env python
28 rcode = """
29 library('getopt');
30 library(affy)
31 require(synapseClient)
32
33 opt = getopt(c(
34 'user', 'u', 2, "character",
35 'pass', 'p', 2, "character",
36 'outfile', 'o', 2, "character",
37 'synid', 's', 2, "character",
38 'eset', 'e', 0, "logical",
39 'attach', 'a', 0, "logical"
40 ));
41
42 if ( !is.null(opt\$user) && !is.null(opt\$pass)) {
43 synapseLogin(username=user, password=pass)
44 }
45
46 ent <- loadEntity(opt\$synid);
47
48 if (!is.null(opt\$eset)) {
49 eset <- exprs(ent\$objects\$eset);
50 write(paste(c("PROBE", colnames(eset)), collapse="\\t"), file=opt\$outfile)
51 write.table(eset, opt\$outfile, col.names=FALSE, sep="\\t", quote=FALSE, append=TRUE);
52 }
53 if (!is.null(opt\$attach)) {
54 fpath <- file.path(ent\$cacheDir, ent\$files[[1]]);
55 file.copy(fpath, opt\$outfile, overwrite=T);
56 }
57
58 """
59
60 import tempfile
61 import os
62 import sys
63 import subprocess
64
65 h, path = tempfile.mkstemp()
66 os.write(h,rcode)
67 os.close(h)
68
69 print subprocess.check_output( ["Rscript", path] + sys.argv[1:], stderr=subprocess.STDOUT )
70 os.unlink(path)
71
72 ]]></configfile>
73 </configfiles>
74 </tool>