Repository 'synapse_interface'
hg clone https://radegast.galaxyproject.org/repos/kellrott/synapse_interface

Changeset 4:2925d82b84fc (2012-10-25)
Previous changeset 2:a104cc98359c (2012-07-24) Next changeset 5:f798da48a30d (2013-07-22)
Commit message:
Uploaded
added:
synapse_interface/._synapse_create.xml
synapse_interface/._synapse_download.xml
synapse_interface/._synapse_query.xml
synapse_interface/synapse_create.xml
synapse_interface/synapse_download.xml
synapse_interface/synapse_query.xml
removed:
synapse_create.xml
synapse_download.xml
synapse_query.xml
b
diff -r a104cc98359c -r 2925d82b84fc synapse_create.xml
--- a/synapse_create.xml Tue Jul 24 17:34:37 2012 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,92 +0,0 @@
-<tool id="synapse_create" name="Synapse Create" version="1.0">
- <description>Create 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="name" type="text" size="90" label="Name"/>
- <param name="attachment" type="data" optional="true" label="Attachment"/>
- <param name="attachment_name" type="text" size="90" optional="true" label="Attachment Name"/>
- <param name="etype" type="select" label="Entity Type">
- <option value="Project">Project</option>
- <option value="Study">Study</option>
- <option value="Data">Data</option>
- </param>
- <repeat name="properties" title="Properties">
- <param name="name" type="text" size="90" label="Name"/>
- <param name="value" type="text" size="90" label="Value">
- <sanitizer>
- <valid initial="string.printable">
- <remove value="&quot;"/>
- </valid>
- <mapping initial="none">
- <add source="&quot;" target="\&quot;"/>
- </mapping>
- </sanitizer>
- </param>
- </repeat>
-
- <repeat name="annotations" title="Annotations">
- <param name="name" type="text" size="90" label="Name"/>
- <param name="value" type="text" size="90" label="Value"/>
- </repeat>
-
- </inputs>
- <outputs>
- <data format="txt" name="outfile" />
- </outputs>
- <configfiles>
-         <configfile name="script_file"><![CDATA[#!/usr/bin/env python
-rcode="""
-require(synapseClient)
-
-if (nchar("$user") > 0 && nchar("$pass") > 0) {
- synapseLogin(username="$user", password="$pass")
-}
-
-ent <- ${etype}( list(name="${name}") )
-
-#for $a in $annotations:
-annotValue(ent, "${a.name}") <- "${a.value}"
-#end for
-
-#for a in $properties:
-propertyValue(ent, "${a.name}") <- "${a.value}"
-#end for
-
-ent <- createEntity(ent)
-
-#if $attachment != 'None' 
-#if $attachment_name == '':
-ent <- addFile(ent, "${attachment}")
-#else
-ent <- addFile(ent, "${attachment}", "${attachment_name}")
-#end if
-#end if
-
-ent <- storeEntity(ent)
-
-write(properties(ent)\$id, file="${outfile}");
-
-"""
-
-
-import tempfile
-import os
-import sys
-import subprocess
-
-h, path = tempfile.mkstemp()
-os.write(h,rcode)
-os.close(h)
-
-proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], 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>
-</tool>
b
diff -r a104cc98359c -r 2925d82b84fc synapse_download.xml
--- a/synapse_download.xml Tue Jul 24 17:34:37 2012 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,74 +0,0 @@
-<tool id="synapse_download" name="Synapse Download" version="1.0">
- <description>Download Synapse Entity</description>
- <command interpreter="python">$script_file
-#if str( $user ) != '':
-  -u "$user"
-#end if
-#if str( $pass ) != '':
-  -p "$pass"
-#end if    
--s $synid
-$data_type
--o $outfile
- </command>
- <inputs>
- <param name="user" type="text" size="90" label="Username"/>
- <param name="pass" type="text" size="90" label="Password"/>
- <param name="synid" type="text" label="Synapse ID"/>
- <param name="data_type" type="select" label="Data Type">
- <option value="-e">Affy Eset</option>
- <option value="-a">Attachment</option>
- </param> 
- </inputs>
- <outputs>
- <data format="txt" name="outfile" label="${synid}" />
- </outputs>
- <configfiles>
-         <configfile name="script_file"><![CDATA[#!/usr/bin/env python
-rcode = """
-library('getopt');
-library(affy)
-require(synapseClient)
-
-opt = getopt(c(
- 'user', 'u', 2, "character",
- 'pass', 'p', 2, "character",
- 'outfile', 'o', 2, "character",
- 'synid', 's', 2, "character",
- 'eset', 'e', 0, "logical",
- 'attach', 'a', 0, "logical"
-));
-
-if ( !is.null(opt\$user) && !is.null(opt\$pass)) {
- synapseLogin(username=user, password=pass)
-}
-
-ent <- loadEntity(opt\$synid);
-
-if (!is.null(opt\$eset)) {
- eset <- exprs(ent\$objects\$eset);
- write(paste(c("PROBE", colnames(eset)), collapse="\\t"), file=opt\$outfile)
- write.table(eset, opt\$outfile, col.names=FALSE, sep="\\t", quote=FALSE, append=TRUE);
-}
-if (!is.null(opt\$attach)) {
- fpath <- file.path(ent\$cacheDir, ent\$files[[1]]);
- file.copy(fpath, opt\$outfile, overwrite=T);
-}
-
-"""
-
-import tempfile
-import os
-import sys
-import subprocess
-
-h, path = tempfile.mkstemp()
-os.write(h,rcode)
-os.close(h)
-
-print subprocess.check_output( ["Rscript", path] + sys.argv[1:], stderr=subprocess.STDOUT )
-os.unlink(path)
-
-]]></configfile>
- </configfiles>
-</tool>
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/._synapse_create.xml
b
Binary file synapse_interface/._synapse_create.xml has changed
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/._synapse_download.xml
b
Binary file synapse_interface/._synapse_download.xml has changed
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/._synapse_query.xml
b
Binary file synapse_interface/._synapse_query.xml has changed
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/synapse_create.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/synapse_interface/synapse_create.xml Thu Oct 25 02:39:06 2012 -0400
[
@@ -0,0 +1,138 @@
+<tool id="synapse_create" name="Synapse Create" version="2.0.0">
+ <description>Create 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="name" type="text" size="90" label="Name"/>
+ <param name="attachment" type="data" optional="true" label="Attachment"/>
+ <param name="attachment_name" type="text" size="90" optional="true" label="Attachment Name"/>
+ <param name="etype" type="select" label="Entity Type">
+ <option value="Project">Project</option>
+ <option value="Study">Study</option>
+ <option value="Data">Data</option>
+ </param>
+ <repeat name="properties" title="Properties">
+ <param name="name" type="select" size="90" label="Name">
+ <option value="name">Name</option>
+ <option value="parentId">ParentID</option>
+ <option value="description">Description</option>
+ <option value="species">Species</option>
+ <option value="numSamples">Number of Samples</option>
+ <option value="disease">Disease</option>
+ <option value="tissueType">Tissue Type</option>
+ </param>
+ <param name="value" type="text" size="90" label="Value">
+ <sanitizer>
+ <valid initial="string.printable">
+ <remove value="&quot;"/>
+ </valid>
+ <mapping initial="none">
+ <add source="&quot;" target="\&quot;"/>
+ </mapping>
+ </sanitizer>
+ </param>
+ </repeat>
+
+ <repeat name="annotations" title="Annotations">
+ <param name="name" type="text" size="90" label="Name"/>
+ <param name="value" type="text" size="90" label="Value">
+ <sanitizer>
+ <valid initial="string.printable">
+ <remove value="&quot;"/>
+ </valid>
+ <mapping initial="none">
+ <add source="&quot;" target="\&quot;"/>
+ </mapping>
+ </sanitizer>
+ </param>
+ </repeat>
+
+ </inputs>
+ <outputs>
+ <data format="txt" name="outfile" />
+ </outputs>
+ <configfiles>
+         <configfile name="script_file"><![CDATA[#!/usr/bin/env python
+rcode="""
+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"))
+}
+
+
+ent <- ${etype}( list(name=galaxyClean("${name}")) )
+
+#for $a in $annotations:
+annotValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
+#end for
+
+#for a in $properties:
+propertyValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
+#end for
+
+ent <- createEntity(ent)
+
+#if $attachment != 'None' 
+#if $attachment_name == '':
+ent <- addFile(ent, galaxyClean("${attachment}"))
+#else
+ent <- addFile(ent, galaxyClean("${attachment}"), galaxyClean("${attachment_name}"))
+#end if
+#end if
+
+ent <- storeEntity(ent)
+
+write(properties(ent)\$id, file=galaxyClean("${outfile}"));
+
+"""
+
+
+import tempfile
+import os
+import sys
+import subprocess
+
+h, path = tempfile.mkstemp()
+os.write(h,rcode)
+os.close(h)
+
+proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], 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) &lt;https://sagebionetworks.jira.com/wiki/display/SYNR/How+to+configure+automatic+login&gt;`_ 
+
+ </help>
+
+</tool>
\ No newline at end of file
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/synapse_download.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/synapse_interface/synapse_download.xml Thu Oct 25 02:39:06 2012 -0400
[
@@ -0,0 +1,92 @@
+<tool id="synapse_download" name="Synapse Download" version="2.0.0">
+ <description>Download Synapse Entity</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="synid" type="text" label="Synapse ID"/>
+ <param name="data_type" type="select" label="Data Type">
+ <option value="e">Affy Eset</option>
+ <option value="a">Attachment</option>
+ </param> 
+ </inputs>
+ <outputs>
+ <data format="txt" name="outfile" label="${synid}" />
+ </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"))
+}
+
+
+cat("Loading...")
+ent <- loadEntity("$synid");
+cat("Done\n")
+
+if ("e" == "$data_type") {
+ eset <- exprs(ent\$objects\$eset);
+ write(paste(c("PROBE", colnames(eset)), collapse="\\t"), file="$outfile")
+ write.table(eset, "$outfile", col.names=FALSE, sep="\\t", quote=FALSE, append=TRUE);
+}
+if ("a" == "$data_type") {
+ fpath <- file.path(ent\$cacheDir, ent\$files[[1]]);
+ file.copy(fpath, "$outfile", overwrite=T);
+}
+
+"""
+
+import tempfile
+import os
+import sys
+import subprocess
+
+h, path = tempfile.mkstemp()
+os.write(h,rcode)
+os.close(h)
+
+cmd_args = ["R", "CMD", "BATCH", path ] 
+proc = subprocess.Popen(cmd_args, stderr=subprocess.PIPE)
+stdout, stderr = proc.communicate()
+if proc.poll() != 0:
+ sys.stderr.write(stderr)
+os.unlink(path)
+]]></configfile>
+ </configfiles>
+ <help>
+
+This tool current supports two types of data from Synapse: Affy eset data and attachment files.
+For Affy eset data, it will attempt to turn the eset into a table and write a tab separated file. For attachment files, it will 
+save the first attached file as the output.
+
+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) &lt;https://sagebionetworks.jira.com/wiki/display/SYNR/How+to+configure+automatic+login&gt;`_ 
+
+ </help>
+</tool>
\ No newline at end of file
b
diff -r a104cc98359c -r 2925d82b84fc synapse_interface/synapse_query.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/synapse_interface/synapse_query.xml Thu Oct 25 02:39:06 2012 -0400
[
@@ -0,0 +1,94 @@
+<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="&quot;"/>
+ </valid>
+ <mapping initial="none">
+ <add source="&quot;" target="&apos;"/>
+ </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) &lt;https://sagebionetworks.jira.com/wiki/display/SYNR/How+to+configure+automatic+login&gt;`_ 
+
+Example Query:
+
+select * from entity where parentId=="syn300013"
+
+ </help>
+
+</tool>
\ No newline at end of file
b
diff -r a104cc98359c -r 2925d82b84fc synapse_query.xml
--- a/synapse_query.xml Tue Jul 24 17:34:37 2012 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,72 +0,0 @@
-<tool id="synapse_query" name="Synapse Query" version="1.0">
- <description>Query Synapse</description>
- <command interpreter="python">$script_file
-#if str( $user ) != '':
-  -u "$user"
-#end if    
-
-#if str( $pass ) != '':
-  -p "$pass"
-#end if    
--o $outfile
- </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="&quot;"/>
- </valid>
- <mapping initial="none">
- <add source="&quot;" target="&apos;"/>
- </mapping>
- </sanitizer>
- </param>
- </inputs>
- <outputs>
- <data format="txt" name="outfile" />
- </outputs>
- <configfiles>
-         <configfile name="script_file"><![CDATA[#!/usr/bin/env python
-rcode="""
-library('getopt');
-library(affy)
-require(synapseClient)
-
-opt = getopt(c(
- 'user', 'u', 2, "character",
- 'pass', 'p', 2, "character",
- 'outfile', 'o', 2, "character"
-));
-
-query <- "${query}";
-cat(query)
-if ( !is.null(opt\$user) && !is.null(opt\$pass)) {
- synapseLogin(username=user, password=pass)
-}
-
-query.out <- synapseQuery(query);
-write.table(query.out, quote=F, file=opt\$outfile, row.name=F, sep="\\t")
-
-"""
-import tempfile
-import os
-import sys
-import subprocess
-
-h, path = tempfile.mkstemp()
-os.write(h,rcode)
-os.close(h)
-
-proc = subprocess.Popen( ["Rscript", path] + sys.argv[1:], 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>
-</tool>