use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SearchServiceImpl method characteristicExpressionExperimentSearch.
private Collection<SearchResult> characteristicExpressionExperimentSearch(final SearchSettings settings) {
Collection<SearchResult> results = new HashSet<>();
// this is a collection because of the API
Collection<Class<?>> classToSearch = new ArrayList<>(1);
// for characteristicService; could add
// findByUri(Class<?>...)
// order matters.
Queue<Class<?>> orderedClassesToSearch = new LinkedList<>();
orderedClassesToSearch.add(ExpressionExperiment.class);
orderedClassesToSearch.add(FactorValue.class);
orderedClassesToSearch.add(BioMaterial.class);
orderedClassesToSearch.add(Treatment.class);
Collection<SearchResult> characterSearchResults = new HashSet<>();
while (characterSearchResults.size() < SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS && !orderedClassesToSearch.isEmpty()) {
classToSearch.clear();
classToSearch.add(orderedClassesToSearch.poll());
// We handle the OR clauses here.
String[] subclauses = settings.getQuery().split(" OR ");
for (String subclause : subclauses) {
/*
* Note that the AND is applied only within one entity type. The fix would be to apply AND at this
* level.
*/
Collection<SearchResult> classResults = this.characteristicSearchWithChildren(classToSearch, subclause);
if (!classResults.isEmpty()) {
String msg = "Found " + classResults.size() + " " + classToSearch.iterator().next().getSimpleName() + " results from characteristic search.";
if (characterSearchResults.size() >= SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS) {
msg += " Total found > " + SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS + ", will not search for more entities.";
}
SearchServiceImpl.log.info(msg);
}
characterSearchResults.addAll(classResults);
}
}
StopWatch watch = new StopWatch();
watch.start();
// filter and get parents...
int numEEs = 0;
Collection<BioMaterial> biomaterials = new HashSet<>();
Collection<FactorValue> factorValues = new HashSet<>();
Collection<Treatment> treatments = new HashSet<>();
for (SearchResult sr : characterSearchResults) {
Class<?> resultClass = sr.getResultClass();
// highlightedText.put( sr.getResultObject(), sr.getHighlightedText() );
if (ExpressionExperiment.class.isAssignableFrom(resultClass)) {
sr.setHighlightedText(sr.getHighlightedText() + " (characteristic)");
results.add(sr);
numEEs++;
} else if (BioMaterial.class.isAssignableFrom(resultClass)) {
biomaterials.add((BioMaterial) sr.getResultObject());
} else if (FactorValue.class.isAssignableFrom(resultClass)) {
factorValues.add((FactorValue) sr.getResultObject());
} else if (Treatment.class.isAssignableFrom(resultClass)) {
treatments.add((Treatment) sr.getResultObject());
}
}
/*
* Much faster to batch it...but we loose track of which search result came from which, so we put generic
* highlighted text.
*/
if (biomaterials.size() > 0) {
Collection<ExpressionExperiment> ees = expressionExperimentService.findByBioMaterials(biomaterials);
for (ExpressionExperiment ee : ees) {
results.add(new SearchResult(ee, SearchServiceImpl.INDIRECT_DB_HIT_PENALTY, "BioMaterial characteristic"));
}
}
this.addEEeByFactorvalues(results, factorValues);
if (treatments.size() > 0) {
SearchServiceImpl.log.info("Not processing treatments, but hits were found");
}
if (SearchServiceImpl.log.isDebugEnabled()) {
SearchServiceImpl.log.debug("ExpressionExperiment search: " + settings + " -> " + results.size() + " characteristic hits");
}
if (watch.getTime() > 1000) {
SearchServiceImpl.log.info("Retrieving " + results.size() + " experiments from " + characterSearchResults.size() + " retrieved characteristics took " + watch.getTime() + " ms");
SearchServiceImpl.log.info("Breakdown: " + numEEs + " via direct association with EE; " + biomaterials.size() + " via association with Biomaterial; " + factorValues.size() + " via experimental design");
}
return results;
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class ProcessedExpressionDataVectorCreateTaskImpl method execute.
@Override
public TaskResult execute() {
ExpressionExperiment ee = taskCommand.getExpressionExperiment();
Collection<ProcessedExpressionDataVector> processedVectors;
if (taskCommand.isCorrelationMatrixOnly()) {
// only create them if necessary. This is sort of stupid, it's just so I didn't have to create a whole other
// task for the correlation matrix computation.
processedVectors = processedExpressionDataVectorService.getProcessedDataVectors(ee);
if (processedVectors.isEmpty()) {
processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
}
} else {
processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
}
coexpressionMatrixService.create(ee);
return new TaskResult(taskCommand, processedVectors.size());
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class TwoChannelMissingValueTaskImpl method execute.
@Override
public TaskResult execute() {
ExpressionExperiment ee = taskCommand.getExpressionExperiment();
Collection<RawExpressionDataVector> missingValueVectors = twoChannelMissingValues.computeMissingValues(ee, taskCommand.getS2n(), taskCommand.getExtraMissingValueIndicators());
System.out.println("MVs: " + missingValueVectors.size());
return new TaskResult(taskCommand, missingValueVectors.size());
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class BaselineDetectionTest method setUp.
@Before
public void setUp() throws Exception {
String path = FileTools.resourceToPath("/data/loader/expression/geo/gse18162Short");
try {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(path));
Collection<?> results = geoService.fetchAndLoad("GSE18162", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
// OK.
if (e.getData() instanceof List) {
ee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
} else {
ee = (ExpressionExperiment) e.getData();
}
}
ee = this.eeService.thawLite(ee);
if (ee.getExperimentalDesign().getExperimentalFactors().isEmpty()) {
ee = eeService.load(ee.getId());
ee = this.eeService.thawLite(ee);
try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/geo/gse18162Short/design.txt")) {
experimentalDesignImporter.importDesign(ee, is);
}
ee = eeService.load(ee.getId());
ee = this.eeService.thawLite(ee);
}
// end setup
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class DiffExMetaAnalyzerServiceTest method cleanup.
private void cleanup() {
for (GeneDifferentialExpressionMetaAnalysisSummaryValueObject vo : geneDiffExMetaAnalysisHelperService.loadAllMetaAnalyses()) {
analysisService.delete(vo.getId());
}
this.deleteSet("GSE2018");
this.deleteSet("GSE2111");
this.deleteSet("GSE6344");
ArrayDesign gpl96 = arrayDesignService.findByShortName("GPL96");
ArrayDesign gpl97 = arrayDesignService.findByShortName("GPL97");
if (gpl96 != null) {
for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl96)) {
experimentService.remove(ee);
}
arrayDesignService.remove(gpl96);
}
if (gpl97 != null) {
for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl97)) {
experimentService.remove(ee);
}
arrayDesignService.remove(gpl97);
}
Collection<Gene> genes = geneService.loadAll();
for (Gene gene : genes) {
try {
geneService.remove(gene);
} catch (Exception e) {
log.warn("Failed to remove gene " + gene);
}
}
}
Aggregations