// Determine the URI of the labeled artifact and retrieve it
labeledArtifactURI = "http://${hostname}/api/v2/artifacts/${labeledArtifactLIMSID}"
labeledArtifact = GLSRestApiUtils.httpGET(labeledArtifactURI, username, password)
// Gather its reagent labels
reagentLabels = labeledArtifact.'reagent-label'.@name
if (!reagentLabels) {
println "No labels found"
return
}
// Build a query URI for possibly multiple reagent labels and execute it
queryParameters = reagentLabels.collect { "name=${it.replace(' ', '+')}" }.join('&')
reagentTypesURI = "http://${hostname}/api/v2/reagenttypes/"
reagentTypeQueryURI = reagentTypesURI + '?' + queryParameters
reagentTypeLinks = GLSRestApiUtils.httpGET(reagentTypeQueryURI, username, password)
// For each reagent type found, retrieve it
reagentTypeLinks.'reagent-type'[email protected] {
reagentType = GLSRestApiUtils.httpGET(it, username, password)
reagentTypeName = reagentType.@name
reagentLabels.remove(reagentTypeName)
index = reagentType.'special-type'.'attribute'.find { it.@name = 'Sequence' }?.@value
// Output the result
println "Label: $reagentTypeName"
println "Index: $index"
}
// If there are reagent labels that found no matches
if (reagentLabels) {
unmatchedLabels = reagentLabels.join(',')
println "No reagent types found for labels: $unmatchedLabels"
}Label: Index 1
Index: ATCACG<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
<name>SAM-1-Index 1</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<parent-process
uri="http://yourIPaddress/api/v2/processes/AMR-RCX-110819-151-25"
limsid="AMR-RCX-110819-151-25"/>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
<value>A:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
<reagent-label name="Index 1" />
</art:artifact>Â 

def toLabel = GLSRestApiUtils.httpGET(artifactToLabelURI, username, password)
println '*** Before labeling'
println GLSRestApiUtils.nodeToXmlString(toLabel)
println
new Node(toLabel, 'reagent-label', [name: 'Index 1'])
println '*** After labeling'
println GLSRestApiUtils.nodeToXmlString(toLabel)
println
GLSRestApiUtils.httpPUT(toLabel, toLabel.@uri, username, password)*** Before labeling
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
<name>Sample-1</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
<value>A:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
</art:artifact>
*** After labeling
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
<name>Sample-1</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
<value>A:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
<reagent-label name="Index 1" />
</art:artifact>


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<prx:process xmlns:prx="http://genologics.com/ri/processexecution">
<type>Demultiplex</type>
<technician uri="http://yourIPaddress/api/v2/researchers/4"/>
<input-output-map>
<input uri="http://yourIPaddress/api/v2/artifacts/2-424"/>
</input-output-map>
</prx:process><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<prc:process xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:prc="http://genologics.com/ri/process"
uri="http://yourIPaddress/api/v2/processes/DMX-RCX-110816-24-95"
limsid="DMX-RCX-110816-24-95">
<type uri="http://yourIPaddress/api/v2/processtypes/38">Demultiplex</type>
<date-run>2011-08-12</date-run>
<technician uri="http://yourIPaddress/api/v2/researchers/4">
<first-name>RC</first-name>
<last-name>RC</last-name>
</technician>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/2-424?state=335"
uri="http://yourIPaddress/api/v2/artifacts/2-424?state=324" limsid="2-424">
<parent-process
uri="http://yourIPaddress/api/v2/processes/PSA-RCX-110812-122-221"
limsid="PSA-RCX-110812-122-221" />
</input>
<output uri="http://yourIPaddress/api/v2/artifacts/92-163?state=339"
output-generation-type="PerReagentLabel" output-type="ResultFile"
limsid="92-163" />
</input-output-map>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/2-424?state=335"
uri="http://yourIPaddress/api/v2/artifacts/2-424?state=324" limsid="2-424">
<parent-process
uri="http://yourIPaddress/api/v2/processes/PSA-RCX-110812-122-221"
limsid="PSA-RCX-110812-122-221" />
</input>
<output uri="http://yourIPaddress/api/v2/artifacts/92-164?state=336"
output-generation-type="PerReagentLabel" output-type="ResultFile"
limsid="92-164" />
</input-output-map>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/2-424?state=335"
uri="http://yourIPaddres/api/v2/artifacts/2-424?state=324" limsid="2-424">
<parent-process
uri="http://yourIPaddress/api/v2/processes/PSA-RCX-110812-122-221"
limsid="PSA-RCX-110812-122-221" />
</input>
<output uri="http://yourIPaddress/api/v2/artifacts/92-162?state=338"
output-generation-type="PerReagentLabel" output-type="ResultFile"
limsid="92-162" />
</input-output-map>
</prc:process>Â <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/92-163?state=339" limsid="92-163">
<name>Results for SAM-3 - Index 3</name>
<type>ResultFile</type>
<output-type>ResultFile</output-type>
<parent-process
uri="http://yourIPaddress/api/v2/processes/DMX-RCX-110816-24-95"
limsid="DMX-RCX-110816-24-95" />
<qc-flag>UNKNOWN</qc-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A104"
limsid="RCY1A104" />
<reagent-label name="Index 3" />
</art:artifact>Â <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
<name>Sample-1</name>
<type>Analyte</type>
<output-type>Analyte</output-type>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
<value>A:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
<reagent-label name="Index 1" />
</art:artifact>// Create the required URIs
containerToPoolUri = "http://${hostname}/api/v2/containers/${containerLIMSID}"
researcherURI = "http://${hostname}/api/v2/researchers/1"
// Find the artifacts to pool in the given container
containerToPool = GLSRestApiUtils.httpGET(containerToPoolUri, username, password)
artifactURIsToPool = containerToPool.'placement'.@uri
def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
// Create a new container using the Markup Builder
def containerDoc = builder.bind {
mkp.xmlDeclaration()
mkp.declareNamespace(con: 'http://genologics.com/ri/container')
mkp.declareNamespace(udf: 'http://genologics.com/ri/userdefined')
'con:container'{
'name'("Pooled contents from ${containerToPool.name.text()}")
'type'(uri:"http://${hostname}/api/v2/containertypes/2", name:"Tube")
}
}
// Post the new container to the API
containerNode = GLSRestApiUtils.xmlStringToNode(containerDoc.toString())
container = GLSRestApiUtils.httpPOST(containerNode, "http://${hostname}/api/v2/containers", username, password)
// Create a new Pool Samples process using the StreamingMarkupBuilder
processDoc = new StreamingMarkupBuilder().bind {
mkp.declareNamespace(prx: 'http://genologics.com/ri/processexecution')
'prx:process'{
'type'('Pool Samples')
'technician'(uri:researcherURI)
'input-output-map'(shared:'true') {
artifactURIsToPool.each { 'input'(uri:it) }
'output'(type:'Analyte') {
'location' {
'container'(uri:container.@uri)
'value'('1:1')
}
}
}
}
}
// Post the Pool Samples process to the API
processNode = GLSRestApiUtils.xmlStringToNode(processDoc.toString())
returnNode = GLSRestApiUtils.httpPOST(processNode, "http://${hostname}/api/v2/processes", username, password)
println GLSRestApiUtils.nodeToXmlString(returnNode)<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<prc:process xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:prc="http://genologics.com/ri/process"
uri="http://yourIPaddress/api/v2/processes/PSA-RCX-110812-122-221"
limsid="PSA-RCX-110812-122-221">
<type uri="http://yourIPaddress/api/v2/processtypes/37">Pool Samples</type>
<date-run>2011-08-12</date-run>
<technician uri="http://yourIPaddress/api/v2/researchers/4">
<first-name>RC</first-name>
<last-name>RC</last-name>
</technician>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/RCY1A104PA1?state=319"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A104PA1?state=315"
limsid="RCY1A104PA1" />
<output uri="http://yourIPaddress/api/v2/artifacts/2-424?state=316"
output-generation-type="PerAllInputs" output-type="Sample" limsid="2-424" />
</input-output-map>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/RCY1A105PA1?state=317"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A105PA1?state=314"
limsid="RCY1A105PA1" />
<output uri="http://yourIPaddress/api/v2/artifacts/2-424?state=316"
output-generation-type="PerAllInputs" output-type="Sample" limsid="2-424" />
</input-output-map>
<input-output-map>
<input post-process-uri="http://yourIPaddress/api/v2/artifacts/RCY1A103PA1?state=318"
uri="http://yourIPaddress/api/v2/artifacts/RCY1A103PA1?state=310"
limsid="RCY1A103PA1" />
<output uri="http://yourIPaddress/api/v2/artifacts/2-424?state=316"
output-generation-type="PerAllInputs" output-type="Sample" limsid="2-424" />
</input-output-map>
</prc:process>
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
uri="http://yourIPaddress/api/v2/artifacts/2-424?state=316" limsid="2-424">
<name>Pool of SAM-1 - Index 1 + SAM-2 - Index 2 + SAM-3 - Index 3</name>
<type>Analyte</type>
<output-type>Sample</output-type>
<parent-process
uri="http://yourIPaddress/api/v2/processes/PSA-RCX-110812-122-221"
limsid="PSA-RCX-110812-122-221" />
<volume unit="uL">0.0</volume>
<qc-flag>UNKNOWN</qc-flag>
<location>
<container uri="http://yourIPaddress/api/v2/containers/27-16"
limsid="27-16" />
<value>1:1</value>
</location>
<working-flag>true</working-flag>
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A104"
limsid="RCY1A104" />
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A105"
limsid="RCY1A105" />
<sample uri="http://yourIPaddress/api/v2/samples/RCY1A103"
limsid="RCY1A103" />
<reagent-label name="Index 1" />
<reagent-label name="Index 2" />
<reagent-label name="Index 3" />
</art:artifact>Â 