Search in sources :

Example 1 with TerminologyService

use of org.nextprot.api.core.service.TerminologyService in project nextprot-api by calipho-sib.

the class GenerateSolrTerminologyIndex method start.

@Override
public void start(String[] args) {
    TerminologyService terminologyService = getBean(TerminologyService.class);
    int termcnt = 0;
    String solrServer = System.getProperty("solr.server");
    NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=\"http://localhost:8983/solr/npcvs1\"");
    logger.info("Solr server: " + solrServer);
    // eg: java -Dsolr.ontology="UniprotFamilyCv" (don't forget CamelCasing)
    String ontologyToReindex = System.getProperty("solr.ontology");
    SolrIndexer<CvTerm> indexer = new CvTermSolrIndexer(solrServer);
    List<CvTerm> allterms;
    if (ontologyToReindex == null) {
        // No arg: index all ontologies
        System.err.println("indexing: all ontologies");
        logger.info("indexing all terminologies");
        indexer.clearDatabase("");
        allterms = terminologyService.findAllCVTerms();
    } else {
        // Index ontology given as VM argument
        System.err.println("indexing: " + ontologyToReindex);
        logger.info("indexing terminology: " + ontologyToReindex);
        indexer.clearDatabase("filters:" + ontologyToReindex);
        allterms = terminologyService.findCvTermsByOntology(ontologyToReindex);
    }
    for (CvTerm term : allterms) {
        indexer.add(term);
        termcnt++;
        if ((termcnt % 3000) == 0)
            logger.info(termcnt + "/" + allterms.size() + " cv terms done");
    }
    indexer.addRemaing();
    logger.info("comitting");
    indexer.commit();
    logger.info(termcnt + " terms indexed...END");
}
Also used : CvTermSolrIndexer(org.nextprot.api.tasks.solr.indexer.CvTermSolrIndexer) CvTerm(org.nextprot.api.core.domain.CvTerm) TerminologyService(org.nextprot.api.core.service.TerminologyService)

Example 2 with TerminologyService

use of org.nextprot.api.core.service.TerminologyService 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 3 with TerminologyService

use of org.nextprot.api.core.service.TerminologyService in project nextprot-api by calipho-sib.

the class IsoformPEFFHeaderBuilderTest method newIsoformPEFFHeaderBuilder.

private IsoformPEFFHeaderBuilder newIsoformPEFFHeaderBuilder(String isoName) {
    String entryAccession = isoformService.findEntryAccessionFromIsoformAccession(isoName);
    Isoform isoform = isoformService.findIsoform(isoName);
    List<Annotation> isoformAnnotations = annotationService.findAnnotations(entryAccession).stream().filter(annotation -> annotation.isSpecificForIsoform(isoName)).collect(Collectors.toList());
    Overview overview = overviewService.findOverviewByEntry(entryAccession);
    return new IsoformPEFFHeaderBuilder(isoform, isoformAnnotations, overview, terminologyService::findPsiModAccession, terminologyService::findPsiModName);
}
Also used : CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) OverviewService(org.nextprot.api.core.service.OverviewService) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationService(org.nextprot.api.core.service.AnnotationService) Collectors(java.util.stream.Collectors) TerminologyService(org.nextprot.api.core.service.TerminologyService) Overview(org.nextprot.api.core.domain.Overview) List(java.util.List) IsoformPEFFHeader(org.nextprot.api.core.domain.IsoformPEFFHeader) IsoformService(org.nextprot.api.core.service.IsoformService) Assert(org.junit.Assert) Isoform(org.nextprot.api.core.domain.Isoform) Isoform(org.nextprot.api.core.domain.Isoform) Overview(org.nextprot.api.core.domain.Overview) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

TerminologyService (org.nextprot.api.core.service.TerminologyService)3 CvTerm (org.nextprot.api.core.domain.CvTerm)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 ConsoleProgressBar (org.nextprot.api.commons.app.ConsoleProgressBar)1 Isoform (org.nextprot.api.core.domain.Isoform)1 IsoformPEFFHeader (org.nextprot.api.core.domain.IsoformPEFFHeader)1 Overview (org.nextprot.api.core.domain.Overview)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 AnnotationService (org.nextprot.api.core.service.AnnotationService)1 IsoformService (org.nextprot.api.core.service.IsoformService)1 OverviewService (org.nextprot.api.core.service.OverviewService)1 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)1 CvTermSolrIndexer (org.nextprot.api.tasks.solr.indexer.CvTermSolrIndexer)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ActiveProfiles (org.springframework.test.context.ActiveProfiles)1