use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class LinkAnalysisServiceTest method checkResults.
private int checkResults(Collection<BioAssaySet> ees, int expectedMinimumMaxSupport) {
boolean foundOne = false;
int maxSupport = 0;
Taxon mouse = taxonService.findByCommonName("mouse");
Collection<Gene> genesWithLinks = new ArrayList<>();
int totalLinks = 0;
// numdatasetstesting will not be set so we won't bother checking.
assertTrue(!geneCoexpressionService.getCoexpression(ee, true).isEmpty());
Collection<CoexpressionValueObject> eeResults = geneCoexpressionService.getCoexpression(ee, false);
assertTrue(!eeResults.isEmpty());
for (CoexpressionValueObject coex : eeResults) {
this.checkResult(coex);
}
Map<Long, GeneCoexpressionNodeDegreeValueObject> nodeDegrees = geneCoexpressionService.getNodeDegrees(EntityUtils.getIds(geneService.loadAll()));
assertTrue(!nodeDegrees.isEmpty());
// experiment-major query
Map<Long, List<CoexpressionValueObject>> allLinks = geneCoexpressionService.findCoexpressionRelationships(mouse, new HashSet<Long>(), EntityUtils.getIds(ees), ees.size(), 10, false);
assertTrue(!allLinks.isEmpty());
for (Long g : allLinks.keySet()) {
for (CoexpressionValueObject coex : allLinks.get(g)) {
this.checkResult(coex);
}
}
for (Gene gene : geneService.loadAll(mouse)) {
Collection<CoexpressionValueObject> links = geneCoexpressionService.findCoexpressionRelationships(gene, EntityUtils.getIds(ees), 1, 0, false);
if (links == null || links.isEmpty()) {
continue;
}
assertEquals(geneCoexpressionService.findCoexpressionRelationships(gene, Collections.singleton(ee.getId()), 0, false).size(), geneCoexpressionService.countLinks(ee, gene).intValue());
GeneCoexpressionNodeDegreeValueObject nodeDegree = geneCoexpressionService.getNodeDegree(gene);
if (links.size() != nodeDegree.getLinksWithMinimumSupport(1)) {
log.info(nodeDegree);
assertEquals("Node degree check failed for gene " + gene, links.size(), nodeDegree.getLinksWithMinimumSupport(1).intValue());
}
assertTrue(nodeDegree.getLinksWithMinimumSupport(1) >= nodeDegree.getLinksWithMinimumSupport(2));
totalLinks += links.size();
log.debug(links.size() + " hits for " + gene);
for (CoexpressionValueObject coex : links) {
this.checkResult(coex);
if (coex.getNumDatasetsSupporting() > maxSupport) {
maxSupport = coex.getNumDatasetsSupporting();
}
}
foundOne = true;
if (genesWithLinks.size() == 5) {
// without specifying stringency
Map<Long, List<CoexpressionValueObject>> multiGeneResults = geneCoexpressionService.findCoexpressionRelationships(mouse, EntityUtils.getIds(genesWithLinks), EntityUtils.getIds(ees), 100, false);
if (multiGeneResults.isEmpty()) {
// noinspection ConstantConditions // these strange structures are to help with debugger.
assertTrue(!multiGeneResults.isEmpty());
}
for (Long id : multiGeneResults.keySet()) {
for (CoexpressionValueObject coex : multiGeneResults.get(id)) {
this.checkResult(coex);
}
}
// with stringency specified, quick.
Map<Long, List<CoexpressionValueObject>> multiGeneResults2 = geneCoexpressionService.findCoexpressionRelationships(mouse, EntityUtils.getIds(genesWithLinks), EntityUtils.getIds(ees), ees.size(), 100, true);
if (multiGeneResults.size() != multiGeneResults2.size()) {
assertEquals(multiGeneResults.size(), multiGeneResults2.size());
}
for (Long id : multiGeneResults2.keySet()) {
for (CoexpressionValueObject coex : multiGeneResults2.get(id)) {
this.checkResult(coex);
}
}
}
genesWithLinks.add(gene);
}
assertTrue(foundOne);
Map<Long, List<CoexpressionValueObject>> mygeneresults = geneCoexpressionService.findInterCoexpressionRelationships(mouse, EntityUtils.getIds(genesWithLinks), EntityUtils.getIds(ees), 1, false);
if (mygeneresults.isEmpty()) {
// noinspection ConstantConditions // these strange structures are to help with debugger.
assertTrue(!mygeneresults.isEmpty());
}
for (Long id : mygeneresults.keySet()) {
for (CoexpressionValueObject coex : mygeneresults.get(id)) {
this.checkResult(coex);
}
}
assertTrue(maxSupport >= expectedMinimumMaxSupport);
return totalLinks;
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class DiffExMetaAnalyzerServiceTest method extraTests1.
private void extraTests1(ExpressionExperiment ds1) {
Collection<Gene> geneCollection = geneService.findByOfficialSymbol("ACTA2");
assertTrue(!geneCollection.isEmpty());
Gene g = geneCollection.iterator().next();
assertNotNull(g);
long count = geneService.getCompositeSequenceCountById(g.getId());
assertTrue(count != 0);
Collection<CompositeSequence> compSequences = geneService.getCompositeSequencesById(g.getId());
assertTrue(compSequences.size() != 0);
Collection<CompositeSequence> collection = compositeSequenceService.findByGene(g);
assertEquals(1, collection.size());
ArrayDesign ad = experimentService.getArrayDesignsUsed(ds1).iterator().next();
collection = compositeSequenceService.findByGene(g, ad);
assertEquals(1, collection.size());
Collection<CompositeSequence> css = compositeSequenceService.findByName("200974_at");
assertTrue(!css.isEmpty());
CompositeSequence cs = css.iterator().next();
Collection<Gene> genes = compositeSequenceService.getGenes(cs);
assertEquals(1, genes.size());
assertEquals(g, genes.iterator().next());
tableMaintenanceUtil.disableEmail();
tableMaintenanceUtil.updateGene2CsEntries();
Map<CompositeSequence, Collection<Gene>> gm = compositeSequenceService.getGenes(css);
assertEquals(1, gm.size());
assertEquals(g, gm.values().iterator().next().iterator().next());
}
use of ubic.gemma.model.genome.Gene 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);
}
}
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class SupportDetailsTest method test.
@Test
public void test() {
Gene g1 = Gene.Factory.newInstance();
g1.setId(3L);
Gene g2 = Gene.Factory.newInstance();
g2.setId(4L);
SupportDetails sd1 = new MouseCoexpressionSupportDetailsImpl(g1, g2, true);
SupportDetails sd2 = new MouseCoexpressionSupportDetailsImpl(g1, g2, true);
sd1.addEntity(1L);
sd2.addEntity(2L);
sd2.removeEntity(2L);
sd2.addEntity(1L);
sd1.addEntity(10L);
sd2.addEntity(10L);
assertEquals(2, sd2.getNumIds());
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class CoexpressionNodeDegreeValueObjectTest method testa.
@Test
public void testa() {
Gene g = Gene.Factory.newInstance();
g.setId(1L);
g.setOfficialName("foo");
GeneCoexpressionNodeDegree nd = GeneCoexpressionNodeDegree.Factory.newInstance(g);
GeneCoexpressionNodeDegreeValueObject t = new GeneCoexpressionNodeDegreeValueObject(nd);
t.increment(1, true);
t.increment(2, true);
assertEquals(2, t.getLinksWithMinimumSupport(1, true).intValue());
assertEquals(1, t.getLinksWithExactSupport(1, true).intValue());
t.increment(1, true);
t.increment(2, true);
assertEquals(4, t.getLinksWithMinimumSupport(1, true).intValue());
assertEquals(2, t.getLinksWithMinimumSupport(2, true).intValue());
assertEquals(2, t.getLinksWithExactSupport(1, true).intValue());
assertEquals(3, t.asIntArrayPos().length);
assertEquals(0, t.asIntArrayPos()[0]);
assertEquals(2, t.asIntArrayPos()[1]);
assertEquals(2, t.asIntArrayPos()[2]);
}
Aggregations