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