<?xml version="1.0" encoding="UTF-8"?>
<maxdQL version="0.1" name="GEOseries2platform" >
	<description>parses output from GEOseries and returns the samples as a comma-separated list of the samples</description>

	<arguments type="user">
		<var 
			name="ExperimentName" 
			comment="the name of the experiment" 
		/>
		
	</arguments>

	<pfunction id="nameLister" comment="returns the id of the first labelled extract" method="text" >
		<![CDATA[
			 
			 $comma ="";
			 $string="";
			 foreach ($input as $linkKey => $linkResult)
			 {
				 foreach ($linkResult["ArrayType"]["Name"] as $key => $value )
				 {
				 	$string .= $comma . $value;
				 	$comma = ",";
				 }
			 }
			 $output = $string; 
			 
		]]>
	</pfunction>

	<query id="1" 
	       name="Linker" 
	       comment= "link ArrayType to Gene"
	       type="maxdBrowse" 
	       >
		<names uref="user" name="ExperimentName"  />
		<action>link</action>
		<table>Experiment</table>
		<desiredTable>ArrayType</desiredTable>
		<attributes>yes</attributes>
		<format>array</format>
		<linkVersion>02</linkVersion>
	</query>

	<query id="2" 
	       name="commaIt" 
	       comment="generates output" 
	       type="export" 
	       format="text" 
	       >
	       <seriesHeader pref="nameLister" processResultID="1" />

	</query>

</maxdQL>
