use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class DifferentialExpressionProbeResultEndpoint 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();
setLocalName(LOCAL_NAME);
// taxon input
Collection<String> taxonInput = getSingleNodeValue(requestElement, "taxon_id");
String taxonId = "";
for (String id : taxonInput) {
taxonId = id;
}
Taxon taxon = taxonService.load(Long.parseLong(taxonId));
if (taxon == null) {
String msg = "No taxon with id, " + taxonId + ", can be found.";
return buildBadResponse(document, msg);
}
// gene ids input
Collection<String> geneInput = getArrayValues(requestElement, "gene_ids");
Collection<Long> geneIDLong = new HashSet<Long>();
for (String id : geneInput) geneIDLong.add(Long.parseLong(id));
Collection<Gene> rawGeneCol = geneService.loadThawed(geneIDLong);
if (rawGeneCol.isEmpty()) {
String msg = "None of the gene id's can be found.";
return buildBadResponse(document, msg);
}
Collection<Gene> geneCol = retainGenesInCorrectTaxon(rawGeneCol, taxon);
if (geneCol == null || geneCol.isEmpty()) {
String msg = "Input genes do not match input taxon.";
return buildBadResponse(document, msg);
}
// expression experiment set id input
Collection<String> analysisInput = getSingleNodeValue(requestElement, "expression_experiment_set_id");
String analysisId = "";
for (String id : analysisInput) {
analysisId = id;
}
ExpressionExperimentSet ees = expressionExperimentSetService.load(Long.parseLong(analysisId));
if (ees == null) {
String msg = "No matching expression experiment set can be found for id, " + analysisId;
return buildBadResponse(document, msg);
}
if (!(ees.getTaxon().getId()).equals(taxon.getId())) {
String msg = "Expression experiment set " + analysisId + " does not match input taxon " + taxon.getCommonName();
return buildBadResponse(document, msg);
}
Collection<ExpressionExperiment> eeCol = getExperiments(ees);
Collection<BioAssaySet> bioAssaySets = new HashSet<BioAssaySet>();
bioAssaySets.addAll(eeCol);
// threshold input
Collection<String> thresholdInput = getSingleNodeValue(requestElement, "threshold");
String threshold = "";
for (String id : thresholdInput) {
threshold = id;
}
log.info("XML input read: " + geneInput.size() + " gene ids, & taxon id " + taxonId + ", & expression experiment set id " + analysisId + ", and threshold " + threshold);
Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
responseWrapper.appendChild(responseElement);
for (Gene gene : geneCol) {
Map<ExpressionExperimentValueObject, List<DifferentialExpressionValueObject>> results = differentialExpressionResultService.find(gene, EntityUtils.getIds(bioAssaySets), Double.parseDouble(threshold), null);
for (ExpressionExperimentValueObject ee : results.keySet()) {
// main call to the DifferentialExpressionAnalysisService to retrieve
// DifferentialExpressionAnalysisResultSet collection
Collection<DifferentialExpressionValueObject> parCol = results.get(ee);
// check that a DifferentialExpressionAnalysisResult is not null
if (parCol == null || parCol.isEmpty()) {
log.error("No probe analysis results can be found for gene: " + gene.getOfficialSymbol() + " & experiment: " + ee);
buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), null);
} else
buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), parCol);
}
}
watch.stop();
Long time = watch.getTime();
log.info("XML response for differential expression probe results built in " + time + "ms.");
return responseWrapper;
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class ExpressionExperimentManipulatingCLI method experimentsFromEeSet.
private void experimentsFromEeSet(String optionValue) {
if (StringUtils.isBlank(optionValue)) {
throw new IllegalArgumentException("Please provide an eeset name");
}
ExpressionExperimentSetService expressionExperimentSetService = this.getBean(ExpressionExperimentSetService.class);
Collection<ExpressionExperimentSet> sets = expressionExperimentSetService.findByName(optionValue);
if (sets.size() > 1) {
throw new IllegalArgumentException("More than on EE set has name '" + optionValue + "'");
} else if (sets.size() == 0) {
throw new IllegalArgumentException("No EE set has name '" + optionValue + "'");
}
ExpressionExperimentSet set = sets.iterator().next();
this.expressionExperiments = new HashSet<>(set.getExperiments());
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceImpl method remove.
@Override
@Transactional
public void remove(Long id) {
final ExpressionExperiment ee = this.load(id);
if (!securityService.isEditable(ee)) {
throw new SecurityException("Error performing 'ExpressionExperimentService.remove(ExpressionExperiment expressionExperiment)' --> " + " You do not have permission to edit this experiment.");
}
// Remove subsets
Collection<ExpressionExperimentSubSet> subsets = this.getSubSets(ee);
for (ExpressionExperimentSubSet subset : subsets) {
expressionExperimentSubSetService.remove(subset);
}
// Remove differential expression analyses
Collection<DifferentialExpressionAnalysis> diffAnalyses = this.differentialExpressionAnalysisDao.findByInvestigation(ee);
for (DifferentialExpressionAnalysis de : diffAnalyses) {
this.differentialExpressionAnalysisDao.remove(de);
}
// remove any sample coexpression matrices
this.sampleCoexpressionAnalysisDao.removeForExperiment(ee);
// Remove PCA
Collection<PrincipalComponentAnalysis> pcas = this.principalComponentAnalysisService.findByExperiment(ee);
for (PrincipalComponentAnalysis pca : pcas) {
this.principalComponentAnalysisService.remove(pca);
}
/*
* Delete any expression experiment sets that only have this one ee in it. If possible remove this experiment
* from other sets, and update them. IMPORTANT, this section assumes that we already checked for gene2gene
* analyses!
*/
Collection<ExpressionExperimentSet> sets = this.expressionExperimentSetService.find(ee);
for (ExpressionExperimentSet eeSet : sets) {
if (eeSet.getExperiments().size() == 1 && eeSet.getExperiments().iterator().next().equals(ee)) {
AbstractService.log.info("Removing from set " + eeSet);
this.expressionExperimentSetService.remove(// remove the set because in only contains this experiment
eeSet);
} else {
AbstractService.log.info("Removing " + ee + " from " + eeSet);
eeSet.getExperiments().remove(ee);
// update set to not reference this experiment.
this.expressionExperimentSetService.update(eeSet);
}
}
this.expressionExperimentDao.remove(ee);
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class ExpressionExperimentSetServiceImpl method findIds.
@Override
@Transactional(readOnly = true)
public Collection<Long> findIds(BioAssaySet bioAssaySet) {
Collection<Long> ids = new ArrayList<>();
Collection<ExpressionExperimentSet> eesets = this.expressionExperimentSetDao.find(bioAssaySet);
for (ExpressionExperimentSet eeset : eesets) {
ids.add(eeset.getId());
}
return ids;
}
use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.
the class AclAdviceTest method testExpressionExperimentAcls.
/*
* Test of EE ACLs and also SecurityNotInherited on EE set.
*/
@Test
public void testExpressionExperimentAcls() {
ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
aclTestUtils.checkEEAcls(ee);
/*
* Make public, and then add a factor and factorvalue.
*/
securityService.makePublic(ee);
ExperimentalFactor ef = ExperimentalFactor.Factory.newInstance();
VocabCharacteristic cat = VocabCharacteristic.Factory.newInstance();
cat.setCategory("foo");
cat.setCategoryUri("bar");
ef.setName("TESTING ACLS");
ef.setCategory(cat);
ef.setType(FactorType.CATEGORICAL);
ef = expressionExperimentService.addFactor(ee, ef);
FactorValue fv = FactorValue.Factory.newInstance(ef);
fv.setValue("ack");
fv = FactorValue.Factory.newInstance(ef);
fv.setValue("adddck");
expressionExperimentService.addFactorValue(ee, fv);
securityService.makePrivate(ee);
aclTestUtils.checkEEAcls(ee);
/*
* Now associate with ee set, remove the set and then the ee, make sure things are done correctly!
*/
ExpressionExperimentSet ees = ExpressionExperimentSet.Factory.newInstance();
ees.getExperiments().add(ee);
ees.setName(this.randomName());
persisterHelper.persist(ees);
// make sure the ACL for objects are there (throws an exception if not).
Acl eeacl = aclService.readAclById(new AclObjectIdentity(ee));
aclService.readAclById(new AclObjectIdentity(ees));
assertNull(eeacl.getParentAcl());
expressionExperimentSetService.remove(ees);
// make sure ACL for ees is gone
aclTestUtils.checkDeletedAcl(ees);
// make sure the ACL for ee is still there
aclTestUtils.checkHasAcl(ee);
expressionExperimentService.remove(ee);
aclTestUtils.checkDeleteEEAcls(ee);
}
Aggregations