Search in sources :

Example 11 with Gene2GeneCoexpression

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;
}
Also used : Gene2GeneCoexpression(ubic.gemma.model.association.coexpression.Gene2GeneCoexpression)

Aggregations

Gene2GeneCoexpression (ubic.gemma.model.association.coexpression.Gene2GeneCoexpression)11 SupportDetails (ubic.gemma.model.analysis.expression.coexpression.SupportDetails)5 StopWatch (org.apache.commons.lang3.time.StopWatch)4 Transactional (org.springframework.transaction.annotation.Transactional)2 Gene (ubic.gemma.model.genome.Gene)2 BigInteger (java.math.BigInteger)1 IdArrayValueObject (ubic.gemma.model.analysis.expression.coexpression.IdArrayValueObject)1 ExperimentCoexpressionLink (ubic.gemma.model.association.coexpression.ExperimentCoexpressionLink)1 GeneCoexpressionNodeDegreeValueObject (ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject)1 NonPersistentNonOrderedCoexpLink (ubic.gemma.persistence.service.association.coexpression.NonPersistentNonOrderedCoexpLink)1