Mercurial > repos > kellrott > synapse_interface
view synapse_query.xml @ 3:93c4d2fad9af
Fixing bugs and bad code
author | Kyle Ellrott <kellrott@gmail.com> |
---|---|
date | Wed, 24 Oct 2012 23:31:13 -0700 |
parents | a104cc98359c |
children |
line wrap: on
line source
<tool id="synapse_query" name="Synapse Query" version="1.0"> <description>Query Synapse</description> <command interpreter="python">$script_file</command> <inputs> <param name="user" type="text" size="90" label="Username"/> <param name="pass" type="text" size="90" label="Password"/> <param name="query" type="text" area="True" size="5x35" label="Query"/> <!-- <sanitizer> <valid initial="string.printable"> <remove value="""/> </valid> <mapping initial="none"> <add source=""" target="'"/> </mapping> </sanitizer> </param> --> </inputs> <outputs> <data format="tabular" name="outfile" /> </outputs> <configfiles> <configfile name="script_file"><![CDATA[#!/usr/bin/env python rcode=""" library(affy) require(synapseClient) galaxyClean <- function(x) { y = gsub("__gt__", ">", x); y = gsub("__lt__", "<", y ); y = gsub("__sq__", "'", y); y = gsub("__dq__", "\\"",y); y = gsub("__ob__", "[", y); y = gsub("__cb__", "]", y); y = gsub("__oc__", "{", y); y = gsub("__cc__", "}", y); y = gsub("__at__", "@", y); y = gsub("__cn__", "\\n", y); y = gsub("__cr__", "\\r", y); y = gsub("__tc__", "\\t", y); y = gsub("__pd__", "#", y); y = gsub("__at__", "@", y); return(y); } if (nchar("$user") && nchar("$pass")) { synapseLogin(username=galaxyClean("$user"), password=galaxyClean("$pass")) } query <- galaxyClean("${query}"); cat(query) query.out <- synapseQuery(query); write.table(query.out, quote=F, file="$outfile", row.name=F, sep="\\t") """ import tempfile import os import sys import subprocess h, path = tempfile.mkstemp(dir="/tmp") os.write(h,rcode) os.close(h) proc = subprocess.Popen( ["Rscript", path], stderr=subprocess.PIPE, stdout=subprocess.PIPE ) (stdoutdata, stderrdata) = proc.communicate() if proc.returncode: sys.stderr.write(stderrdata) sys.stdout.write(stdoutdata) os.unlink(path) ]]></configfile> </configfiles> <help> Install R SynapseClient:: source('http://depot.sagebase.org/CRAN.R') pkgInstall("synapseClient") `To setup auto login (so you don't have to type in your password) <https://sagebionetworks.jira.com/wiki/display/SYNR/How+to+configure+automatic+login>`_ Example Query: select * from entity where parentId=="syn300013" </help> </tool>