use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class ExpressionExperimentSetController method create.
public Collection<ExpressionExperimentSetValueObject> create(Collection<ExpressionExperimentSetValueObject> entities) {
Collection<Long> eeSetIds = new HashSet<>();
for (ExpressionExperimentSetValueObject ees : entities) {
if (ees.getExpressionExperimentIds() == null || ees.getExpressionExperimentIds().isEmpty()) {
throw new IllegalArgumentException("No expression experiment ids provided. Cannot save an empty set.");
}
ExpressionExperimentSet newEESet = this.create(ees);
eeSetIds.add(newEESet.getId());
}
return this.expressionExperimentSetService.loadValueObjectsByIds(eeSetIds);
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class GeneCoexpressionSearchEndpoint 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) {
try {
StopWatch watch = new StopWatch();
watch.start();
setLocalName(LOCAL_NAME);
String queryGeneId = getNodeValue(requestElement, "query_gene_id");
String pairQueryGeneId = getOptionalNodeValue(requestElement, "pair_query_gene_id");
String stringency = getNodeValue(requestElement, "stringency");
Collection<Gene> queryGenes = new LinkedList<>();
Gene queryGene = geneService.findByNCBIId(Integer.parseInt(queryGeneId));
if (queryGene == null) {
String msg = "Query gene with id [" + queryGeneId + "] cannot be found.";
return buildBadResponse(document, msg);
}
queryGenes.add(queryGene);
if (pairQueryGeneId != null) {
Gene queryGene2 = geneService.findByNCBIId(Integer.parseInt(pairQueryGeneId));
if (queryGene2 == null) {
String msg = "Query gene with id [" + pairQueryGeneId + "] cannot be found.";
return buildBadResponse(document, msg);
}
queryGenes.add(queryGene2);
}
Collection<ExpressionExperimentSet> eeSets = expressionExperimentSetService.findByName("All mouse");
// .load(5662l); // uses 'All mouse' by default.
ExpressionExperimentSet eeSet = eeSets.iterator().next();
Collection<BioAssaySet> experiments = eeSet.getExperiments();
Collection<Long> inputEeIds = new ArrayList<>();
for (BioAssaySet e : experiments) {
inputEeIds.add(e.getId());
}
CoexpressionMetaValueObject metaVO;
if (pairQueryGeneId == null) {
metaVO = geneCoexpressionSearchService.coexpressionSearch(inputEeIds, EntityUtils.getIds(queryGenes), Integer.valueOf(stringency), MAX_RESULTS, false);
} else {
metaVO = geneCoexpressionSearchService.coexpressionSearch(inputEeIds, EntityUtils.getIds(queryGenes), Integer.valueOf(stringency), MAX_RESULTS, true);
}
Collection<CoexpressionValueObjectExt> coexpressedGenes = metaVO.getResults();
if (coexpressedGenes.isEmpty()) {
String msg = "No coexpressed genes found.";
return buildBadResponse(document, msg);
}
Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
responseWrapper.appendChild(responseElement);
for (CoexpressionValueObjectExt cvo : coexpressedGenes) {
Element item = document.createElement("CoexpressionSearchResult");
Element foundGeneElement = document.createElement("found_gene_id");
foundGeneElement.appendChild(document.createTextNode(cvo.getFoundGene().getNcbiId() == null ? "" : cvo.getFoundGene().getNcbiId().toString()));
item.appendChild(foundGeneElement);
Element numExperimentsElement = document.createElement("num_experiments_tested");
numExperimentsElement.appendChild(document.createTextNode(cvo.getNumTestedIn().toString()));
item.appendChild(numExperimentsElement);
Element numCoexpressedElement = document.createElement("num_experiments_coexpressed");
numCoexpressedElement.appendChild(document.createTextNode(String.valueOf(cvo.getSupportingExperiments().size())));
item.appendChild(numCoexpressedElement);
Element gemmaURL = document.createElement("gemma_details_url");
gemmaURL.appendChild(document.createTextNode(Settings.getBaseUrl() + "searchCoexpression.html?g=" + queryGene.getId() + "," + cvo.getFoundGene().getId() + "&s=" + stringency + "&t=2&q&a=5662&an=All%20mouse"));
item.appendChild(gemmaURL);
responseElement.appendChild(item);
}
watch.stop();
Long time = watch.getTime();
if (time > 1000) {
log.info("XML response for " + coexpressedGenes.size() + " results built in " + time + "ms.");
}
return responseWrapper;
} catch (Exception e) {
return buildBadResponse(document, e.getMessage());
}
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class SessionListManagerImpl method getExperimentIdsInSet.
@Override
public Collection<Long> getExperimentIdsInSet(Long id) {
// secure
ExpressionExperimentSet eeSet = expressionExperimentSetService.load(id);
// Not secure.
Collection<BioAssaySet> datasets = eeSet.getExperiments();
Collection<Long> eeids = new HashSet<>();
for (BioAssaySet ee : datasets) {
eeids.add(ee.getId());
}
return eeids;
}
Aggregations