Search in sources :

Example 11 with CvTerm

use of org.nextprot.api.core.domain.CvTerm 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 12 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class DbXrefAnalyserTask method analyseCvTermsDbXrefs.

private void analyseCvTermsDbXrefs() throws IOException {
    LOGGER.info("**** Analysing dbxrefs from terminology...");
    DbXrefUrlVisitor visitor = new DbXrefUrlVisitor(outputDirectory + "/allterminologies-xrefs-url.tsv", outputDirectory + "/allterminologies-xrefs-url.log");
    TerminologyService terminologyService = getBean(TerminologyService.class);
    List<CvTerm> allCvTerms = terminologyService.findAllCVTerms();
    ConsoleProgressBar pb = ConsoleProgressBar.determinated("analysing dbxrefs (from neXtProt cv terms)", allCvTerms.size());
    pb.start();
    for (CvTerm terminology : allCvTerms) {
        visitor.visit(terminology.getAccession(), terminology.getXrefs());
        visitor.flush();
        pb.incrementValue();
    }
    visitor.flush();
    visitor.close();
    pb.stop();
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) TerminologyService(org.nextprot.api.core.service.TerminologyService) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar)

Example 13 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyDaoImpl method findTerminologyByOntology.

public List<CvTerm> findTerminologyByOntology(String ontology) {
    SqlParameterSource params = new MapSqlParameterSource("ontology", ontology);
    List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-ontology"), params, new DbTermRowMapper());
    return terms;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CvTerm(org.nextprot.api.core.domain.CvTerm) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 14 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyDaoImpl method findTerminologyByAccessions.

@Override
public List<CvTerm> findTerminologyByAccessions(Set<String> accessions) {
    SqlParameterSource params = new MapSqlParameterSource("accessions", accessions);
    List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-acs"), params, new DbTermRowMapper());
    return terms;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CvTerm(org.nextprot.api.core.domain.CvTerm) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Example 15 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class ConsistencyServiceImpl method findMissingCvTerms.

@Override
public List<String> findMissingCvTerms() {
    List<String> missingCvTerms = new ArrayList<>();
    List<String> terms = statementDao.findAllDistinctValuesforField(StatementField.ANNOT_CV_TERM_ACCESSION);
    for (String t : terms) {
        if (t != null) {
            CvTerm term = terminologyService.findCvTermByAccession(t);
            if (term == null) {
                missingCvTerms.add(t);
            }
        }
    }
    return missingCvTerms;
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) ArrayList(java.util.ArrayList)

Aggregations

CvTerm (org.nextprot.api.core.domain.CvTerm)34 Test (org.junit.Test)9 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)8 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 NextProtException (org.nextprot.api.commons.exception.NextProtException)4 CvTermGraph (org.nextprot.api.core.domain.CvTermGraph)4 Annotation (org.nextprot.api.core.domain.annotation.Annotation)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)4 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)4 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)4 Publication (org.nextprot.api.core.domain.Publication)3 Supplier (com.google.common.base.Supplier)2 Instant (java.time.Instant)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Collectors (java.util.stream.Collectors)2 Logger (org.apache.log4j.Logger)2 ApiMethod (org.jsondoc.core.annotation.ApiMethod)2 ConsoleProgressBar (org.nextprot.api.commons.app.ConsoleProgressBar)2