diff 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
line wrap: on
line diff
--- a/synapse_create.xml	Tue Jul 24 17:34:37 2012 -0400
+++ b/synapse_create.xml	Wed Oct 24 23:31:13 2012 -0700
@@ -1,4 +1,4 @@
-<tool id="synapse_create" name="Synapse Create" version="1.0">
+<tool id="synapse_create" name="Synapse Create" version="2.0.0">
 	<description>Create Synapse</description>
 	<command interpreter="python">$script_file</command>
 	<inputs>
@@ -13,6 +13,28 @@
 			<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>
@@ -26,11 +48,6 @@
 			</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" />
@@ -40,33 +57,52 @@
 rcode="""
 require(synapseClient)
 
-if (nchar("$user") > 0 && nchar("$pass") > 0) {
-	synapseLogin(username="$user", password="$pass")
+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);
 }
 
-ent <- ${etype}( list(name="${name}") )
+if (nchar("$user") && nchar("$pass")) {
+	synapseLogin(username=galaxyClean("$user"), password=galaxyClean("$pass"))
+}
+
+
+ent <- ${etype}( list(name=galaxyClean("${name}")) )
 
 #for $a in $annotations:
-annotValue(ent, "${a.name}") <- "${a.value}"
+annotValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
 #end for
 
 #for a in $properties:
-propertyValue(ent, "${a.name}") <- "${a.value}"
+propertyValue(ent, galaxyClean("${a.name}")) <- galaxyClean("${a.value}")
 #end for
 
 ent <- createEntity(ent)
 
 #if $attachment != 'None' 
 #if $attachment_name == '':
-ent <- addFile(ent, "${attachment}")
+ent <- addFile(ent, galaxyClean("${attachment}"))
 #else
-ent <- addFile(ent, "${attachment}", "${attachment_name}")
+ent <- addFile(ent, galaxyClean("${attachment}"), galaxyClean("${attachment_name}"))
 #end if
 #end if
 
 ent <- storeEntity(ent)
 
-write(properties(ent)\$id, file="${outfile}");
+write(properties(ent)\$id, file=galaxyClean("${outfile}"));
 
 """
 
@@ -89,4 +125,14 @@
 
 ]]></configfile>
 	</configfiles>
-</tool>
+		<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