Search in sources :

Example 36 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class GemmaClassicHomePageController method updateCounts.

public void updateCounts() {
    Map<String, Long> stats = new HashMap<String, Long>();
    long bioAssayCount = bioAssayService.countAll();
    long arrayDesignCount = arrayDesignService.countAll();
    /*
         * Sort taxa by name.
         */
    TreeMap<Taxon, Long> eesPerTaxon = new TreeMap<Taxon, Long>(new Comparator<Taxon>() {

        @Override
        public int compare(Taxon o1, Taxon o2) {
            return o1.getScientificName().compareTo(o2.getScientificName());
        }
    });
    eesPerTaxon.putAll(expressionExperimentService.getPerTaxonCount());
    long expressionExperimentCount = 0;
    long otherTaxaEECount = 0;
    for (Iterator<Taxon> it = eesPerTaxon.keySet().iterator(); it.hasNext(); ) {
        Taxon t = it.next();
        Long c = eesPerTaxon.get(t);
        // TODO problem with this is we want to make a link to them.
        if (c < 10) {
            // temporary, hide 'uncommon' taxa from this table. See bug 2052
            otherTaxaEECount += c;
            it.remove();
        }
        expressionExperimentCount += c;
    }
    if (otherTaxaEECount > 0) {
    // eesPerTaxon.put( otherTaxa, otherTaxaEECount );
    }
    WhatsNew wn = whatsNewService.retrieveReport();
    stats.put("bioAssayCount", bioAssayCount);
    stats.put("arrayDesignCount", arrayDesignCount);
    mav.addObject("stats", stats);
    mav.addObject("taxonCount", eesPerTaxon);
    mav.addObject("expressionExperimentCount", expressionExperimentCount);
    if (wn != null && wn.getDate() != null) {
        mav.addObject("whatsNew", wn);
    }
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) WhatsNew(ubic.gemma.core.analysis.report.WhatsNew)

Example 37 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class BioSequenceImplTest method testEqualsTaxon.

public void testEqualsTaxon() {
    BioSequence a = BioSequence.Factory.newInstance();
    BioSequence b = BioSequence.Factory.newInstance();
    a.setName("foo");
    b.setName("foo");
    a.setSequence("AAAAAAAAAAAAAAAA");
    b.setSequence("AAAAAAAAAAAAAAAA");
    Taxon m = Taxon.Factory.newInstance();
    m.setIsSpecies(true);
    m.setIsGenesUsable(true);
    m.setScientificName("Mus musculus");
    Taxon h = Taxon.Factory.newInstance();
    h.setIsSpecies(true);
    h.setIsGenesUsable(true);
    h.setScientificName("Homo sapiens");
    a.setTaxon(m);
    b.setTaxon(h);
    TestCase.assertTrue(!a.equals(b));
}
Also used : Taxon(ubic.gemma.model.genome.Taxon)

Example 38 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class GeneServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    geneDaoMock = createMock(GeneDaoImpl.class);
    svc = new GeneServiceImpl(geneDaoMock);
    Taxon t = Taxon.Factory.newInstance();
    t.setCommonName("moose");
    t.setScientificName("moose");
    t.setIsSpecies(true);
    t.setIsGenesUsable(true);
    // tDAO.create( t );
    g = Gene.Factory.newInstance();
    g.setOfficialName("rabble");
    g.setOfficialSymbol("rab");
    allThree.add(g);
    justRab.add(g);
    g2 = Gene.Factory.newInstance();
    g2.setOfficialName("rabblebong");
    g2.setTaxon(t);
    allThree.add(g2);
    g3 = Gene.Factory.newInstance();
    g3.setOfficialName("rabble");
    g3.setNcbiGeneId(12345);
    g3.setOfficialSymbol("rab3");
    g3.setId((long) 1234);
    // For testing need to add physical locations to the gene products of a given gene.
    Chromosome chromosome = new Chromosome("fakeChromosome", t);
    FieldUtils.writeField(chromosome, "id", 54321L, true);
    // Gene product 1 (Min=100 max=200)
    PhysicalLocation ploc1 = PhysicalLocation.Factory.newInstance();
    ploc1.setChromosome(chromosome);
    ploc1.setStrand(GeneServiceImplTest.STRAND);
    ploc1.setNucleotide((long) 100);
    ploc1.setNucleotideLength(100);
    GeneProduct gp1 = GeneProduct.Factory.newInstance();
    gp1.setPhysicalLocation(ploc1);
    gp1.setGene(g3);
    gp1.setName("gp1");
    // gene product 2 (min=110 max = 210)
    PhysicalLocation ploc2 = PhysicalLocation.Factory.newInstance();
    ploc2.setChromosome(chromosome);
    ploc2.setStrand(GeneServiceImplTest.STRAND);
    ploc2.setNucleotide((long) 110);
    ploc2.setNucleotideLength(100);
    GeneProduct gp2 = GeneProduct.Factory.newInstance();
    gp2.setPhysicalLocation(ploc2);
    gp2.setGene(g3);
    gp2.setName("gp2");
    // Gene Product 3 (min=90 max=140)
    PhysicalLocation ploc3 = PhysicalLocation.Factory.newInstance();
    ploc3.setChromosome(chromosome);
    ploc3.setStrand(GeneServiceImplTest.STRAND);
    ploc3.setNucleotide((long) 90);
    ploc3.setNucleotideLength(50);
    GeneProduct gp3 = GeneProduct.Factory.newInstance();
    gp3.setPhysicalLocation(ploc3);
    gp3.setGene(g3);
    gp3.setName("gp3");
    // Gene Product 4 (wrong strand should get regected, min 10 max 210)
    PhysicalLocation ploc4 = PhysicalLocation.Factory.newInstance();
    ploc4.setChromosome(chromosome);
    ploc4.setStrand("-");
    ploc4.setNucleotide((long) 10);
    ploc4.setNucleotideLength(200);
    GeneProduct gp4 = GeneProduct.Factory.newInstance();
    gp4.setPhysicalLocation(ploc4);
    gp4.setGene(g3);
    gp4.setName("wrong strand gp4");
    gp4.setId((long) 3456);
    // Gene Product 5 (right strand wrong chromosome should get regected, min 20 max 220)
    Chromosome wrongChromosome = new Chromosome("wrongFakeChromosome", t);
    FieldUtils.writeField(chromosome, "id", 43215L, true);
    PhysicalLocation ploc5 = PhysicalLocation.Factory.newInstance();
    ploc5.setChromosome(wrongChromosome);
    ploc5.setStrand(GeneServiceImplTest.STRAND);
    ploc5.setNucleotide((long) 20);
    ploc5.setNucleotideLength(200);
    GeneProduct gp5 = GeneProduct.Factory.newInstance();
    gp5.setPhysicalLocation(ploc5);
    gp5.setGene(g3);
    gp5.setName("wrong chromosome gp5");
    gp5.setId((long) 4567);
    Collection<GeneProduct> gps = new ArrayList<>();
    gps.add(gp1);
    gps.add(gp2);
    gps.add(gp4);
    gps.add(gp5);
    gps.add(gp3);
    g3.setProducts(gps);
    allThree.add(g3);
    justRabble.add(g3);
}
Also used : GeneServiceImpl(ubic.gemma.core.genome.gene.service.GeneServiceImpl) Taxon(ubic.gemma.model.genome.Taxon) ArrayList(java.util.ArrayList) Chromosome(ubic.gemma.model.genome.Chromosome) GeneDaoImpl(ubic.gemma.persistence.service.genome.GeneDaoImpl) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) Before(org.junit.Before)

Example 39 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class ArrayDesignServiceTest method testGetTaxaOneTaxonForArray.

/*
     * Test retrieving one taxa for an arraydesign where hibernate query is not restricted to return just 1 taxon.
     */
@Test
public void testGetTaxaOneTaxonForArray() {
    ad = (ArrayDesign) persisterHelper.persist(ad);
    Collection<Taxon> taxa = arrayDesignService.getTaxa(ad.getId());
    assertEquals(1, taxa.size());
    Taxon tax = taxa.iterator().next();
    assertEquals(ArrayDesignServiceTest.DEFAULT_TAXON, tax.getScientificName());
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 40 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class GeneServiceTest method testLoadGenes.

@Test
public void testLoadGenes() {
    Taxon human = taxonService.findByCommonName("human");
    Gene gene = Gene.Factory.newInstance();
    Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
    gene.setNcbiGeneId(id);
    gene.setName("Ma_Gene");
    gene.setDescription("Lost in space");
    gene.setTaxon(human);
    geneDao.create(gene);
    Collection<Gene> genes = geneDao.loadAll(human);
    assertNotNull(genes);
    assertTrue(genes.contains(gene));
    geneDao.remove(gene);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Aggregations

Taxon (ubic.gemma.model.genome.Taxon)161 Gene (ubic.gemma.model.genome.Gene)34 Test (org.junit.Test)31 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)29 HashSet (java.util.HashSet)23 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)23 InputStream (java.io.InputStream)17 Before (org.junit.Before)16 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)15 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)14 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)12 StopWatch (org.apache.commons.lang3.time.StopWatch)11 Transactional (org.springframework.transaction.annotation.Transactional)11 ArrayList (java.util.ArrayList)10 File (java.io.File)9 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)9 Chromosome (ubic.gemma.model.genome.Chromosome)8 Collection (java.util.Collection)7 Element (org.w3c.dom.Element)7 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)7