Search in sources :

Example 1 with TerminologyCv

use of org.nextprot.api.commons.constants.TerminologyCv in project nextprot-api by calipho-sib.

the class OntologyDAGAnalyserTask method readWriteCache.

private void readWriteCache(boolean readCacheForSure) {
    Set<String> allCvTerms = new HashSet<>();
    ConsoleProgressBar pb = ConsoleProgressBar.determinated(((readCacheForSure) ? "read" : "read/write") + " terminology-by-ontology cache", terminologyCvs.length);
    pb.start();
    Instant t = Instant.now();
    for (TerminologyCv ontology : terminologyCvs) {
        allCvTerms.addAll(terminologyService.findCvTermsByOntology(ontology.name()).stream().map(CvTerm::getAccession).collect(Collectors.toSet()));
        pb.incrementValue();
    }
    pb.stop();
    System.out.println("\ttiming 'terminology-by-ontology': " + ChronoUnit.SECONDS.between(t, Instant.now()) + " s");
    pb = ConsoleProgressBar.determinated(((readCacheForSure) ? "read" : "read/write") + " 'ontology-dag' cache", terminologyCvs.length);
    pb.start();
    t = Instant.now();
    for (TerminologyCv ontology : terminologyCvs) {
        cvTermGraphService.findCvTermGraph(ontology);
        pb.incrementValue();
    }
    pb.stop();
    System.out.println("\ttiming 'ontology-dag': " + ChronoUnit.SECONDS.between(t, Instant.now()) + " s");
    pb = ConsoleProgressBar.determinated(((readCacheForSure) ? "read" : "read/write") + " 'terminology-by-accession' cache", allCvTerms.size());
    pb.start();
    t = Instant.now();
    for (String cvTerm : allCvTerms) {
        terminologyService.findCvTermByAccession(cvTerm);
        pb.incrementValue();
    }
    pb.stop();
    System.out.println("\ttiming 'terminology-by-accession': " + ChronoUnit.SECONDS.between(t, Instant.now()) + " s");
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) Instant(java.time.Instant) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar) TerminologyCv(org.nextprot.api.commons.constants.TerminologyCv)

Example 2 with TerminologyCv

use of org.nextprot.api.commons.constants.TerminologyCv in project nextprot-api by calipho-sib.

the class TerminologyDaoIntegrationTest method shouldTheTerminologiesByInSyncWithDB.

@Test
public void shouldTheTerminologiesByInSyncWithDB() {
    List<String> terminologies = terminologyDao.findTerminologyNamesList();
    List<TerminologyCv> tCv = Arrays.stream(TerminologyCv.values()).collect(Collectors.toList());
    assertEquals(terminologies.size(), tCv.size());
    for (TerminologyCv t : tCv) {
        if (!t.equals(TerminologyCv.NextprotCellosaurusCv)) {
            // TEMP pass thru
            if (!terminologies.contains(StringUtils.camelToKebabCase(t.name()))) {
                fail(t + " is not contained anymore");
            }
        }
    }
}
Also used : TerminologyCv(org.nextprot.api.commons.constants.TerminologyCv) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 3 with TerminologyCv

use of org.nextprot.api.commons.constants.TerminologyCv in project nextprot-api by calipho-sib.

the class OntologyDAGAnalyserTask method calcStatisticsForAllOntologies.

private void calcStatisticsForAllOntologies() throws FileNotFoundException {
    Set<TerminologyCv> excludedOntology = EnumSet.of(TerminologyCv.NextprotCellosaurusCv, TerminologyCv.MeshAnatomyCv, TerminologyCv.MeshCv);
    PrintWriter pw = new PrintWriter(getCommandLineParser().getOutputDirectory() + "/dag-ontology.csv");
    pw.write(getStatisticsHeaders().stream().collect(Collectors.joining(",")));
    pw.write(",building time (ms),TerminologyUtils.getAllAncestors() time (ms),OntologyDAG.getAncestors() time (ms)\n");
    for (TerminologyCv terminologyCv : terminologyCvs) {
        Instant t1 = Instant.now();
        // no cache here: create a new instance to access graph advanced methods
        CvTermGraph graph = cvTermGraphService.findCvTermGraph(terminologyCv);
        long buildingTime = ChronoUnit.MILLIS.between(t1, Instant.now());
        List<String> statistics = calcStatistics(graph);
        statistics.add(new DecimalFormat("######.##").format(buildingTime));
        if (!excludedOntology.contains(terminologyCv)) {
            statistics.addAll(benchmarkingGetAncestorsMethods(terminologyCv, terminologyService).stream().map(l -> Long.toString(l)).collect(Collectors.toList()));
        } else {
            statistics.addAll(Arrays.asList("NA", "NA"));
        }
        pw.write(statistics.stream().collect(Collectors.joining(",")));
        pw.write("\n");
        pw.flush();
    }
    pw.close();
}
Also used : Instant(java.time.Instant) DecimalFormat(java.text.DecimalFormat) TerminologyCv(org.nextprot.api.commons.constants.TerminologyCv) CvTermGraph(org.nextprot.api.core.domain.CvTermGraph) PrintWriter(java.io.PrintWriter)

Example 4 with TerminologyCv

use of org.nextprot.api.commons.constants.TerminologyCv in project nextprot-api by calipho-sib.

the class TermController method buildTerminologyCache.

@RequestMapping(value = "/terminology-graph/build-all", produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, String> buildTerminologyCache() {
    Map<String, String> map = new HashMap<>();
    Instant totalTime = Instant.now();
    for (TerminologyCv terminologyCv : TerminologyCv.values()) {
        Instant t = Instant.now();
        cvTermGraphService.findCvTermGraph(terminologyCv);
        long ms = ChronoUnit.MILLIS.between(t, Instant.now());
        map.put(terminologyCv.name(), String.valueOf(ms) + " ms");
    }
    map.put("TOTAL BUILD", String.valueOf(ChronoUnit.SECONDS.between(totalTime, Instant.now())) + " s");
    return map;
}
Also used : HashMap(java.util.HashMap) Instant(java.time.Instant) TerminologyCv(org.nextprot.api.commons.constants.TerminologyCv) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TerminologyCv (org.nextprot.api.commons.constants.TerminologyCv)4 Instant (java.time.Instant)3 PrintWriter (java.io.PrintWriter)1 DecimalFormat (java.text.DecimalFormat)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ConsoleProgressBar (org.nextprot.api.commons.app.ConsoleProgressBar)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 CvTermGraph (org.nextprot.api.core.domain.CvTermGraph)1 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1