Search in sources :

Example 1 with GeneCoexpressionNodeDegree

use of ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree 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]);
}
Also used : Gene(ubic.gemma.model.genome.Gene) GeneCoexpressionNodeDegreeValueObject(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject) GeneCoexpressionNodeDegree(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree) Test(org.junit.Test)

Example 2 with GeneCoexpressionNodeDegree

use of ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree in project Gemma by PavlidisLab.

the class CoexpressionDaoImpl method process.

private int process(List<Double> relRanks, Session sess, ByteArrayConverter bac, int i, Long g, boolean positive) {
    GeneCoexpressionNodeDegree nd = (GeneCoexpressionNodeDegree) sess.load(GeneCoexpressionNodeDegree.class, g);
    byte[] r = bac.doubleArrayToBytes(relRanks.toArray(new Double[] {}));
    if (positive) {
        nd.setRelativeLinkRanksPositive(r);
    } else {
        nd.setRelativeLinkRanksNegative(r);
    }
    sess.update(nd);
    if (++i % 1024 == 0) {
        sess.flush();
        sess.clear();
    }
    return i;
}
Also used : GeneCoexpressionNodeDegree(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree)

Example 3 with GeneCoexpressionNodeDegree

use of ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree in project Gemma by PavlidisLab.

the class CoexpressionDaoImpl method updateNodeDegree.

@Override
@Transactional
public GeneCoexpressionNodeDegreeValueObject updateNodeDegree(Gene g, GeneCoexpressionNodeDegree nd) {
    Session sess = this.getSessionFactory().getCurrentSession();
    List<CoexpressionValueObject> hits = this.getCoexpression(g);
    /*
         * We have to reset the support.
         */
    GeneCoexpressionNodeDegreeValueObject gcndvo = new GeneCoexpressionNodeDegreeValueObject(nd);
    gcndvo.clear();
    assert gcndvo.getMaxSupportNeg() == 0;
    for (CoexpressionValueObject hit : hits) {
        if (hit.isPositiveCorrelation()) {
            gcndvo.increment(hit.getNumDatasetsSupporting(), true);
        } else {
            gcndvo.increment(hit.getNumDatasetsSupporting(), false);
        }
    }
    assert gcndvo.total() == hits.size();
    GeneCoexpressionNodeDegree entity = gcndvo.toEntity();
    nd.setLinkCountsPositive(entity.getLinkCountsPositive());
    nd.setLinkCountsNegative(entity.getLinkCountsNegative());
    if (CoexpressionDaoImpl.log.isDebugEnabled())
        CoexpressionDaoImpl.log.debug("gene=" + g.getId() + " pos=" + StringUtils.join(ArrayUtils.toObject(nd.getLinkCountsPositive()), " ") + " neg=" + StringUtils.join(ArrayUtils.toObject(nd.getLinkCountsNegative()), " "));
    sess.update(nd);
    // might not be necessary, but presumption is data is stale now...
    this.gene2GeneCoexpressionCache.remove(g.getId());
    this.geneTestedInCache.remove(g.getId());
    return gcndvo;
}
Also used : GeneCoexpressionNodeDegreeValueObject(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject) GeneCoexpressionNodeDegree(ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GeneCoexpressionNodeDegree (ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegree)3 GeneCoexpressionNodeDegreeValueObject (ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject)2 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Gene (ubic.gemma.model.genome.Gene)1