Mercurial > repos > kellrott > synapse_interface
comparison synapse_create.xml @ 3:93c4d2fad9af
Fixing bugs and bad code
| author | Kyle Ellrott <kellrott@gmail.com> |
|---|---|
| date | Wed, 24 Oct 2012 23:31:13 -0700 |
| parents | 83173eca36b7 |
| children |
comparison
equal
deleted
inserted
replaced
| 2:a104cc98359c | 3:93c4d2fad9af |
|---|---|
| 1 <tool id="synapse_create" name="Synapse Create" version="1.0"> | 1 <tool id="synapse_create" name="Synapse Create" version="2.0.0"> |
| 2 <description>Create Synapse</description> | 2 <description>Create Synapse</description> |
| 3 <command interpreter="python">$script_file</command> | 3 <command interpreter="python">$script_file</command> |
| 4 <inputs> | 4 <inputs> |
| 5 <param name="user" type="text" size="90" label="Username"/> | 5 <param name="user" type="text" size="90" label="Username"/> |
| 6 <param name="pass" type="text" size="90" label="Password"/> | 6 <param name="pass" type="text" size="90" label="Password"/> |
| 11 <option value="Project">Project</option> | 11 <option value="Project">Project</option> |
| 12 <option value="Study">Study</option> | 12 <option value="Study">Study</option> |
| 13 <option value="Data">Data</option> | 13 <option value="Data">Data</option> |
| 14 </param> | 14 </param> |
| 15 <repeat name="properties" title="Properties"> | 15 <repeat name="properties" title="Properties"> |
| 16 <param name="name" type="select" size="90" label="Name"> | |
| 17 <option value="name">Name</option> | |
| 18 <option value="parentId">ParentID</option> | |
| 19 <option value="description">Description</option> | |
| 20 <option value="species">Species</option> | |
| 21 <option value="numSamples">Number of Samples</option> | |
| 22 <option value="disease">Disease</option> | |
| 23 <option value="tissueType">Tissue Type</option> | |
| 24 </param> | |
| 25 <param name="value" type="text" size="90" label="Value"> | |
| 26 <sanitizer> | |
| 27 <valid initial="string.printable"> | |
| 28 <remove value="""/> | |
| 29 </valid> | |
| 30 <mapping initial="none"> | |
| 31 <add source=""" target="\""/> | |
| 32 </mapping> | |
| 33 </sanitizer> | |
| 34 </param> | |
| 35 </repeat> | |
| 36 | |
| 37 <repeat name="annotations" title="Annotations"> | |
| 16 <param name="name" type="text" size="90" label="Name"/> | 38 <param name="name" type="text" size="90" label="Name"/> |
| 17 <param name="value" type="text" size="90" label="Value"> | 39 <param name="value" type="text" size="90" label="Value"> |
| 18 <sanitizer> | 40 <sanitizer> |
| 19 <valid initial="string.printable"> | 41 <valid initial="string.printable"> |
| 20 <remove value="""/> | 42 <remove value="""/> |
| 24 </mapping> | 46 </mapping> |
| 25 </sanitizer> | 47 </sanitizer> |
| 26 </param> | 48 </param> |
| 27 </repeat> | 49 </repeat> |
| 28 | 50 |
| 29 <repeat name="annotations" title="Annotations"> | |
| 30 <param name="name" type="text" size="90" label="Name"/> | |
| 31 <param name="value" type="text" size="90" label="Value"/> | |
| 32 </repeat> | |
| 33 | |
| 34 </inputs> | 51 </inputs> |
| 35 <outputs> | 52 <outputs> |
| 36 <data format="txt" name="outfile" /> | 53 <data format="txt" name="outfile" /> |
| 37 </outputs> | 54 </outputs> |
| 38 <configfiles> | 55 <configfiles> |
| 39 <configfile name="script_file"><![CDATA[#!/usr/bin/env python | 56 <configfile name="script_file"><![CDATA[#!/usr/bin/env python |
| 40 rcode=""" | 57 rcode=""" |
| 41 require(synapseClient) | 58 require(synapseClient) |
| 42 | 59 |
| 43 if (nchar("$user") > 0 && nchar("$pass") > 0) { | 60 galaxyClean <- function(x) { |
| 44 synapseLogin(username="$user", password="$pass") | 61 y = gsub("__gt__", ">", x); |
| 62 y = gsub("__lt__", "<", y ); | |
| 63 y = gsub("__sq__", "'", y); | |
| 64 y = gsub("__dq__", "\\"",y); | |
| 65 y = gsub("__ob__", "[", y); | |
| 66 y = gsub("__cb__", "]", y); | |
| 67 y = gsub("__oc__", "{", y); | |
| 68 y = gsub("__cc__", "}", y); | |
| 69 y = gsub("__at__", "@", y); | |
| 70 y = gsub("__cn__", "\\n", y); | |
| 71 y = gsub("__cr__", "\\r", y); | |
| 72 y = gsub("__tc__", "\\t", y); | |
| 73 y = gsub("__pd__", "#", y); | |
| 74 y = gsub("__at__", "@", y); | |
| 75 return(y); | |
| 45 } | 76 } |
| 46 | 77 |
| 47 ent <- ${etype}( list(name="${name}") ) | 78 if (nchar("$user") && nchar("$pass")) { |
| 79 synapseLogin(username=galaxyClean("$user"), password=galaxyClean("$pass")) | |
| 80 } | |
| 81 | |
| 82 | |
| 83 ent <- ${etype}( list(name=galaxyClean("${name}")) ) | |
| 48 | 84 |
| 49 #for $a in $annotations: | 85 #for $a in $annotations: |
| 50 annotValue(ent, "${a.name}") <- "${a.value}" | 86 annotValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}") |
| 51 #end for | 87 #end for |
| 52 | 88 |
| 53 #for a in $properties: | 89 #for a in $properties: |
| 54 propertyValue(ent, "${a.name}") <- "${a.value}" | 90 propertyValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}") |
| 55 #end for | 91 #end for |
| 56 | 92 |
| 57 ent <- createEntity(ent) | 93 ent <- createEntity(ent) |
| 58 | 94 |
| 59 #if $attachment != 'None' | 95 #if $attachment != 'None' |
| 60 #if $attachment_name == '': | 96 #if $attachment_name == '': |
| 61 ent <- addFile(ent, "${attachment}") | 97 ent <- addFile(ent, galaxyClean("${attachment}")) |
| 62 #else | 98 #else |
| 63 ent <- addFile(ent, "${attachment}", "${attachment_name}") | 99 ent <- addFile(ent, galaxyClean("${attachment}"), galaxyClean("${attachment_name}")) |
| 64 #end if | 100 #end if |
| 65 #end if | 101 #end if |
| 66 | 102 |
| 67 ent <- storeEntity(ent) | 103 ent <- storeEntity(ent) |
| 68 | 104 |
| 69 write(properties(ent)\$id, file="${outfile}"); | 105 write(properties(ent)\$id, file=galaxyClean("${outfile}")); |
| 70 | 106 |
| 71 """ | 107 """ |
| 72 | 108 |
| 73 | 109 |
| 74 import tempfile | 110 import tempfile |
| 87 sys.stdout.write(stdoutdata) | 123 sys.stdout.write(stdoutdata) |
| 88 os.unlink(path) | 124 os.unlink(path) |
| 89 | 125 |
| 90 ]]></configfile> | 126 ]]></configfile> |
| 91 </configfiles> | 127 </configfiles> |
| 128 <help> | |
| 129 | |
| 130 Install R SynapseClient: | |
| 131 source('http://depot.sagebase.org/CRAN.R') | |
| 132 pkgInstall("synapseClient") | |
| 133 | |
| 134 `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>`_ | |
| 135 | |
| 136 </help> | |
| 137 | |
| 92 </tool> | 138 </tool> |
