Search in sources :

Example 1 with ConsoleProgressBar

use of org.nextprot.api.commons.app.ConsoleProgressBar 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 2 with ConsoleProgressBar

use of org.nextprot.api.commons.app.ConsoleProgressBar in project nextprot-api by calipho-sib.

the class DbXrefAnalyserTask method analyseNextprotEntriesDbXrefs.

private void analyseNextprotEntriesDbXrefs() throws IOException {
    LOGGER.info("**** Analysing dbxrefs from entry accession...");
    ConsoleProgressBar pb;
    try (DbXrefUrlVisitor visitor = new DbXrefUrlVisitor(outputDirectory + "/allentries-xrefs-url.tsv", outputDirectory + "/allentries-xrefs-url.log")) {
        DbXrefService xrefService = getBean(DbXrefService.class);
        Set<String> allEntryAcs = getNextprotEntries();
        pb = ConsoleProgressBar.determinated("analysing dbxrefs (from neXtProt entries)", allEntryAcs.size());
        pb.start();
        for (String entryAc : allEntryAcs) {
            try {
                visitor.visit(entryAc, xrefService.findDbXrefsByMaster(entryAc));
                visitor.flush();
                pb.incrementValue();
            } catch (EntryNotFoundException e) {
                LOGGER.error(e.getMessage() + ": skipping entry " + entryAc);
            }
        }
        visitor.flush();
        visitor.close();
    }
    pb.stop();
}
Also used : DbXrefService(org.nextprot.api.core.service.DbXrefService) EntryNotFoundException(org.nextprot.api.commons.exception.EntryNotFoundException) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar)

Example 3 with ConsoleProgressBar

use of org.nextprot.api.commons.app.ConsoleProgressBar 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 4 with ConsoleProgressBar

use of org.nextprot.api.commons.app.ConsoleProgressBar in project nextprot-api by calipho-sib.

the class PeffServiceValidatorTask method readExpectedIsoformPeffHeaders.

private Map<String, Map<String, Object>> readExpectedIsoformPeffHeaders() throws FileNotFoundException {
    ConsoleProgressBar pb = ConsoleProgressBar.indeterminated("reading expected peff headers from file");
    try {
        ExpectedPeffParser parser = new ExpectedPeffParser();
        pb.run(Files.lines(Paths.get(expectedPeffFilename)).filter(l -> l.startsWith(">nxp:")), parser);
        return parser.isoToPeffHeader;
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage() + ": cannot open file nextprot_all_updatedTo1.0h.peff");
    }
}
Also used : java.util(java.util) Files(java.nio.file.Files) Options(org.apache.commons.cli.Options) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) Logger(org.apache.log4j.Logger) java.io(java.io) SpringBasedTask(org.nextprot.api.commons.app.SpringBasedTask) Paths(java.nio.file.Paths) ParseException(org.apache.commons.cli.ParseException) OptionBuilder(org.apache.commons.cli.OptionBuilder) CommandLine(org.apache.commons.cli.CommandLine) IsoformPEFFHeader(org.nextprot.api.core.domain.IsoformPEFFHeader) IsoformService(org.nextprot.api.core.service.IsoformService) EntryNotFoundException(org.nextprot.api.commons.exception.EntryNotFoundException) MasterIdentifierService(org.nextprot.api.core.service.MasterIdentifierService) CommandLineSpringParser(org.nextprot.api.commons.app.CommandLineSpringParser) Isoform(org.nextprot.api.core.domain.Isoform) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar)

Example 5 with ConsoleProgressBar

use of org.nextprot.api.commons.app.ConsoleProgressBar in project nextprot-api by calipho-sib.

the class PeffServiceValidatorTask method getIsoformPeffHeadersFromAPI.

private Map<String, Map<String, Object>> getIsoformPeffHeadersFromAPI() throws FileNotFoundException {
    Set<String> allEntryAcs = getNextprotEntries();
    ConsoleProgressBar pb = ConsoleProgressBar.determinated("querying peff headers from api", allEntryAcs.size());
    ObservedPeffCollector collector = new ObservedPeffCollector(getBean(IsoformService.class));
    pb.run(allEntryAcs.stream(), collector);
    return collector.map;
}
Also used : IsoformService(org.nextprot.api.core.service.IsoformService) ConsoleProgressBar(org.nextprot.api.commons.app.ConsoleProgressBar)

Aggregations

ConsoleProgressBar (org.nextprot.api.commons.app.ConsoleProgressBar)6 EntryNotFoundException (org.nextprot.api.commons.exception.EntryNotFoundException)2 CvTerm (org.nextprot.api.core.domain.CvTerm)2 IsoformService (org.nextprot.api.core.service.IsoformService)2 java.io (java.io)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 Instant (java.time.Instant)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 CommandLine (org.apache.commons.cli.CommandLine)1 OptionBuilder (org.apache.commons.cli.OptionBuilder)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 Logger (org.apache.log4j.Logger)1 CommandLineSpringParser (org.nextprot.api.commons.app.CommandLineSpringParser)1 SpringBasedTask (org.nextprot.api.commons.app.SpringBasedTask)1 TerminologyCv (org.nextprot.api.commons.constants.TerminologyCv)1 Isoform (org.nextprot.api.core.domain.Isoform)1