From 82a7e45f51504522b531484eabb8d40793c8dc84 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Tue, 30 Aug 2022 20:29:48 +0100 Subject: [PATCH] remove some unnecessary functions, additional parallelisation --- klarigi/src/main/groovy/klarigi/App.groovy | 1 + klarigi/src/main/groovy/klarigi/Scorer.groovy | 22 +++++-------------- .../src/main/groovy/klarigi/StepDown.groovy | 12 +++++++--- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/klarigi/src/main/groovy/klarigi/App.groovy b/klarigi/src/main/groovy/klarigi/App.groovy index a458ee6..d3a9c8b 100644 --- a/klarigi/src/main/groovy/klarigi/App.groovy +++ b/klarigi/src/main/groovy/klarigi/App.groovy @@ -218,6 +218,7 @@ class App { println "Could not handle the --group-file: ${e.toString()}" System.exit(1) } + if(o['verbose']) { println "[...] Loaded ${o['group'].size()} groups from ${o['group-file']}. Ignoring any --group argument." } } else if(o['group'] =~ ';') { o['group'] = o['group'].tokenize(';') } else if(o['group']) { diff --git a/klarigi/src/main/groovy/klarigi/Scorer.groovy b/klarigi/src/main/groovy/klarigi/Scorer.groovy index 96cbf41..d0df2be 100644 --- a/klarigi/src/main/groovy/klarigi/Scorer.groovy +++ b/klarigi/src/main/groovy/klarigi/Scorer.groovy @@ -187,22 +187,7 @@ public class Scorer { } } } -/* - private def findRelevantClasses(relevant, c) { - /*if(relevant.contains(c)) { return; } - relevant << c - - def ce = ontoHelper.dataFactory.getOWLClass(IRI.create(c)) - ontoHelper.reasoner.getSuperClasses(ce, false).each { n -> - n.getEntities().each { sc -> - def strc = sc.getIRI().toString() - findRelevantClasses(relevant, strc) - } - - - relevant += scMap[c] - } -*/ + def scoreClasses(cid, classes) { scoreClasses(cid, classes, false) } @@ -232,7 +217,10 @@ public class Scorer { def scoreAllClasses(cid, returnAll) { // No point running expensive unique here since we check in processClass whether we already have it - def relevant = data.allAssociations.collect { scMap[it] }.flatten() + def relevant + GParsPool.withPool(o['threads']) { p -> + relevant = data.allAssociations.collectParallel { scMap[it] }.flatten() + } def explainers = new ConcurrentHashMap() GParsPool.withPool(o['threads']) { p -> diff --git a/klarigi/src/main/groovy/klarigi/StepDown.groovy b/klarigi/src/main/groovy/klarigi/StepDown.groovy index 3fa2d78..6dec28d 100644 --- a/klarigi/src/main/groovy/klarigi/StepDown.groovy +++ b/klarigi/src/main/groovy/klarigi/StepDown.groovy @@ -14,9 +14,13 @@ public class StepDown { def stepDown = { e, icCutoff, powerCutoff, totalInclusionCutoff -> while(totalCoverage <= (totalInclusionCutoff*100)) { - def ef = candidates.findAll { + + def ef + GParsPool.withPool(threads) { p -> + ef = candidates.findAllParallel { it.nIc >= icCutoff && it.nPower >= powerCutoff } + } totalCoverage = CalculateOI(c, cid, data, ef, threads, false) @@ -52,12 +56,14 @@ public class StepDown { static def CalculateOI(c, cid, data, candidates, threads, total) { def contributingEf = candidates if(!total) { - contributingEf = contributingEf.findAll { it.nInclusion <= c.MAX_INCLUSION && it.nExclusion <= c.MAX_EXCLUSION && it.nPower <= c.MAX_R_SCORE } + GParsPool.withPool(threads) { p -> + contributingEf = contributingEf.findAllParallel { it.nInclusion <= c.MAX_INCLUSION && it.nExclusion <= c.MAX_EXCLUSION && it.nPower <= c.MAX_R_SCORE } + } } def covered = new AtomicInteger(0) GParsPool.withPool(threads) { p -> - data.groupings[cid].each { ee -> + data.groupings[cid].eachParallel { ee -> if(contributingEf.any { it.incEnts.containsKey(ee) }) { covered.getAndIncrement() }