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]);
}
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;
}
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;
}
Aggregations