use of ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject in project Gemma by PavlidisLab.
the class DEDVfromEEIDGeneIDEndpoint method invokeInternal.
/**
* Reads the given <code>requestElement</code>, and sends a the response back.
*
* @param requestElement the contents of the SOAP message as DOM elements
* @param document a DOM document to be used for constructing <code>Node</code>s
* @return the response element
*/
@Override
protected Element invokeInternal(Element requestElement, Document document) {
StopWatch watch = new StopWatch();
watch.start();
this.setLocalName(DEDVfromEEIDGeneIDEndpoint.EXPERIMENT_LOCAL_NAME);
// get ee id's from request
Collection<String> eeIdResult = this.getArrayValues(requestElement, "ee_ids");
Collection<Long> eeIDLong = new HashSet<>();
for (String id : eeIdResult) eeIDLong.add(Long.parseLong(id));
// Need to get and thawRawAndProcessed the experiments.
Collection<ExpressionExperiment> eeObjs = expressionExperimentService.load(eeIDLong);
for (ExpressionExperiment ee : eeObjs) {
ee = expressionExperimentService.thawLite(ee);
}
// get gene id's from request
Collection<String> geneIdResult = this.getArrayValues(requestElement, "gene_ids");
Collection<Long> geneIDLong = new HashSet<>();
for (String id : geneIdResult) geneIDLong.add(Long.parseLong(id));
DEDVfromEEIDGeneIDEndpoint.log.debug("XML input read: " + eeIdResult.size() + " experiment ids & " + geneIdResult.size() + " gene ids");
Collection<DoubleVectorValueObject> vectors = processedExpressionDataVectorService.getProcessedDataArrays(eeObjs, geneIDLong);
// start building the wrapper
// xml is built manually here instead of using the buildWrapper method inherited from AbstractGemmaEndpoint
// log.info( "Building " + EXPERIMENT_LOCAL_NAME + " XML response" );
String elementName1 = "dedv";
String elementName2 = "geneIdList";
String elementName3 = "eeIdList";
Element responseWrapper = document.createElementNS(AbstractGemmaEndpoint.NAMESPACE_URI, DEDVfromEEIDGeneIDEndpoint.EXPERIMENT_LOCAL_NAME);
Element responseElement = document.createElementNS(AbstractGemmaEndpoint.NAMESPACE_URI, DEDVfromEEIDGeneIDEndpoint.EXPERIMENT_LOCAL_NAME + AbstractGemmaEndpoint.RESPONSE);
responseWrapper.appendChild(responseElement);
if (vectors == null || vectors.isEmpty())
return this.buildBadResponse(document, "No " + elementName1 + " result");
// of the design elements
for (DoubleVectorValueObject dedv : vectors) {
double[] convertedDEDV = dedv.getData();
// data vector string for output
String elementString1 = this.encode(convertedDEDV);
//
Collection<Long> geneidCol = dedv.getGenes();
// gene ids, space delimited for output
String elementString2 = this.encode(geneidCol.toArray());
String elementString3 = dedv.getExpressionExperiment().getId().toString();
Element e1 = document.createElement(elementName1);
e1.appendChild(document.createTextNode(elementString1));
responseElement.appendChild(e1);
Element e2 = document.createElement(elementName2);
e2.appendChild(document.createTextNode(elementString2));
responseElement.appendChild(e2);
Element e3 = document.createElement(elementName3);
e3.appendChild(document.createTextNode(elementString3));
responseElement.appendChild(e3);
}
watch.stop();
Long time = watch.getTime();
// log.info( "Finished generating result. Sending response to client." );
DEDVfromEEIDGeneIDEndpoint.log.debug("XML response for design element data vector results built in " + time + "ms.");
// log.info( "Finished generating matrix. Sending response to client." );
// naming convention for the xml file report
String filename = "dedv-";
if (geneIDLong.size() > 10)
filename = filename.concat(geneIDLong.size() + "-" + eeIdResult.size());
else {
for (String id : geneIdResult) filename = filename.concat(id + "-");
filename = filename.concat("" + eeIdResult.size());
}
this.writeReport(responseWrapper, document, filename);
return responseWrapper;
}
Aggregations