use of org.nextprot.api.core.domain.ExperimentalContext in project nextprot-api by calipho-sib.
the class ExperimentalContextDictAnalyserTask method execute.
@Override
protected void execute() throws IOException {
ExperimentalContextDictionaryService bean = getBean(ExperimentalContextDictionaryService.class);
Map<Long, ExperimentalContext> dict = bean.getAllExperimentalContexts();
/* If instrumentation is available, use it, otherwise guess the size using sun.misc.Unsafe; if that is unavailable,
* guess using predefined specifications -> setting jamm as -javaagent is now optional */
MemoryMeter memMeter = new MemoryMeter().withGuessing(MemoryMeter.Guess.FALLBACK_BEST);
if (getCommandLineParser().isDebugMode()) {
memMeter = memMeter.enableDebug();
}
long shallowMemory = memMeter.measure(dict);
long deepMemory = memMeter.measureDeep(dict);
long childrenCount = memMeter.countChildren(dict);
StringBuilder sb = new StringBuilder("experimental-context-dictionary memory allocation: ");
sb.append("shallow=").append(shallowMemory).append("B").append(", deep=").append((int) Math.ceil(deepMemory / 1024.)).append("KB").append(", children#=").append(childrenCount).append("\n");
System.out.printf(sb.toString());
}
use of org.nextprot.api.core.domain.ExperimentalContext in project nextprot-api by calipho-sib.
the class EntryPartExporterImpl method setExperimentalContextRowValues.
private void setExperimentalContextRowValues(Row row, Entry entry, AnnotationEvidence evidence) {
ExperimentalContext ec = entry.getExperimentalContext(evidence.getExperimentalContextId()).orElseThrow(() -> new NextProtException("missing experimental context for " + evidence.getEvidenceCodeAC()));
if (ec.getDevelopmentalStage() != null) {
setRowValue(row, STAGE_ACCESSION, ec.getDevelopmentalStageAC());
setRowValue(row, STAGE_NAME, ec.getDevelopmentalStage().getName());
}
if (ec.getCellLine() != null) {
setRowValue(row, CELL_LINE_ACCESSION, ec.getCellLineAC());
setRowValue(row, CELL_LINE_NAME, ec.getCellLine().getName());
}
if (ec.getDisease() != null) {
setRowValue(row, DISEASE_ACCESSION, ec.getDiseaseAC());
setRowValue(row, DISEASE_NAME, ec.getDisease().getName());
}
if (ec.getOrganelle() != null) {
setRowValue(row, ORGANELLE_ACCESSION, ec.getOrganelleAC());
setRowValue(row, ORGANELLE_NAME, ec.getOrganelle().getName());
}
}
use of org.nextprot.api.core.domain.ExperimentalContext in project nextprot-api by calipho-sib.
the class ExperimentalContextDictionaryServiceImpl method getAllExperimentalContexts.
@Override
@Cacheable("experimental-context-dictionary")
public Map<Long, ExperimentalContext> getAllExperimentalContexts() {
// long t0 = System.currentTimeMillis(); System.out.println("Building experimental context dictionary...");
List<ExperimentalContext> ecs = ecDao.findAllExperimentalContexts();
updateTerminologies(ecs);
Map<Long, ExperimentalContext> dictionary = new TreeMap<>();
for (ExperimentalContext ec : ecs) dictionary.put(ec.getContextId(), ec);
ecs = null;
return dictionary;
}
use of org.nextprot.api.core.domain.ExperimentalContext in project nextprot-api by calipho-sib.
the class ExperimentalContextDictionaryServiceImpl method updateTerminologies.
private void updateTerminologies(List<ExperimentalContext> ecs) {
Set<String> terminologyAccessions = new HashSet<String>();
for (ExperimentalContext ec : ecs) {
terminologyAccessions.add(ec.getCellLineAC());
terminologyAccessions.add(ec.getTissueAC());
terminologyAccessions.add(ec.getOrganelleAC());
terminologyAccessions.add(ec.getDetectionMethodAC());
terminologyAccessions.add(ec.getDiseaseAC());
terminologyAccessions.add(ec.getDevelopmentalStageAC());
}
if (terminologyAccessions.size() > 0) {
List<CvTerm> terms = terminologyService.findCvTermsByAccessions(terminologyAccessions);
Map<String, CvTerm> map = new HashMap<>();
for (CvTerm term : terms) {
map.put(term.getAccession(), term);
}
for (ExperimentalContext ec : ecs) {
updateTerminologies(ec, map);
}
}
}
Aggregations