use of ubic.gemma.model.association.coexpression.Gene2GeneCoexpression in project Gemma by PavlidisLab.
the class CoexpressionDaoImpl method findLink.
/**
* Find link (or null) based on the genes and direction of correlation in the given nonpersistent link.
*
* @param q q
* @param g2g g2g
* @param existingResults index of which links already have an entry in the database (possibly with a support of
* zero)
* @return gene 2 gene coexp
*/
private Gene2GeneCoexpression findLink(Query q, NonPersistentNonOrderedCoexpLink g2g, Map<NonPersistentNonOrderedCoexpLink, Boolean> existingResults) {
Long firstGene = g2g.getFirstGene();
Long secondGene = g2g.getSecondGene();
assert firstGene < secondGene;
if (existingResults.containsKey(g2g) && existingResults.get(g2g)) {
try {
q.setParameter("f", firstGene);
q.setParameter("s", secondGene);
q.setParameter("pc", g2g.isPositiveCorrelation());
Gene2GeneCoexpression existingLink = (Gene2GeneCoexpression) q.uniqueResult();
if (CoexpressionDaoImpl.log.isDebugEnabled() && existingLink != null && existingResults.containsKey(g2g) && existingResults.get(g2g))
CoexpressionDaoImpl.log.debug("fetched existing link: " + existingLink + " (" + g2g + ") " + existingResults.get(g2g));
// which can be null
return existingLink;
} catch (HibernateException e) {
CoexpressionDaoImpl.log.error("Error while searching for: " + g2g + ": " + e.getMessage());
throw e;
}
}
// // it isn't in the existing results we fetched already, so we don't bother checking
if (CoexpressionDaoImpl.log.isDebugEnabled())
CoexpressionDaoImpl.log.debug("No existing link for " + g2g);
return null;
}
Aggregations