Search in sources :

Example 1 with ExperimentalContext

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());
}
Also used : ExperimentalContextDictionaryService(org.nextprot.api.core.service.ExperimentalContextDictionaryService) ExperimentalContext(org.nextprot.api.core.domain.ExperimentalContext) MemoryMeter(org.github.jamm.MemoryMeter)

Example 2 with ExperimentalContext

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());
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) ExperimentalContext(org.nextprot.api.core.domain.ExperimentalContext)

Example 3 with ExperimentalContext

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;
}
Also used : ExperimentalContext(org.nextprot.api.core.domain.ExperimentalContext) TreeMap(java.util.TreeMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with ExperimentalContext

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);
        }
    }
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) HashMap(java.util.HashMap) ExperimentalContext(org.nextprot.api.core.domain.ExperimentalContext) HashSet(java.util.HashSet)

Aggregations

ExperimentalContext (org.nextprot.api.core.domain.ExperimentalContext)4 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 MemoryMeter (org.github.jamm.MemoryMeter)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 ExperimentalContextDictionaryService (org.nextprot.api.core.service.ExperimentalContextDictionaryService)1 Cacheable (org.springframework.cache.annotation.Cacheable)1