Search in sources :

Example 1 with MasterIdentifierService

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

the class StatementExportTask method execute.

@Override
protected void execute() throws FileNotFoundException {
    StatementDao statementDao = getBean(StatementDao.class);
    MasterIdentifierService masterIdentifierService = getBean(MasterIdentifierService.class);
    ArgumentParser parser = getCommandLineParser();
    StatementExporter exporter = new StatementExporter(statementDao, masterIdentifierService, parser.getExporterConfig());
    LOGGER.info("exporting gene statements...");
    // get all genes if no genes were specified
    if (parser.getSpecificGeneListToExport().isEmpty()) {
        Map<String, String> map = exporter.exportAllGeneStatementsAsTsvString();
        for (String geneName : map.keySet()) {
            exporter.exportAsTsvFile(parser.getOutputDirname(), geneName, map.get(geneName));
            LOGGER.info("gene statements of " + geneName + " exported");
        }
    } else {
        for (String geneName : parser.getSpecificGeneListToExport()) {
            exporter.exportAsTsvFile(parser.getOutputDirname(), geneName, exporter.exportGeneStatementsAsTsvString(geneName));
            LOGGER.info("gene statements of " + geneName + " exported");
        }
    }
}
Also used : StatementDao(org.nextprot.api.core.dao.StatementDao) StatementExporter(org.nextprot.api.core.export.StatementExporter) MasterIdentifierService(org.nextprot.api.core.service.MasterIdentifierService)

Example 2 with MasterIdentifierService

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

the class GenerateSolrAnnotationIndexGold method start.

@Override
public void start(String[] args) {
    MasterIdentifierService MasterEntryService = getBean(MasterIdentifierService.class);
    EntryBuilderService entryBuilderService = getBean(EntryBuilderService.class);
    int ecnt = 0;
    String solrServer = System.getProperty("solr.server");
    NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=\"http://localhost:8983/solr/npentries1gold\"");
    logger.info("Solr server: " + solrServer);
    EntryGoldSolrIndexer indexer = new EntryGoldSolrIndexer(solrServer);
    // Get an access to some needed services
    indexer.setTerminologyservice(getBean(TerminologyService.class));
    indexer.setEntryBuilderService(getBean(EntryBuilderService.class));
    // Remove previous indexes
    logger.info("removing all solr entries records");
    indexer.clearDatabase("");
    Set<String> allentryids;
    System.err.println("getting all entries from API");
    logger.info("getting all entries from API");
    long start = System.currentTimeMillis();
    allentryids = MasterEntryService.findUniqueNames();
    System.err.println("indexing " + allentryids.size() + " entries...");
    logger.info("indexing " + allentryids.size() + " entries...");
    for (String id : allentryids) {
        ecnt++;
        Entry currentry = entryBuilderService.buildWithEverything(id);
        indexer.add(currentry);
        if ((ecnt % 1000) == 0)
            logger.info(ecnt + " entries GOLD-indexed...");
    }
    indexer.addRemaing();
    logger.info("comitting");
    indexer.commit();
    logger.info(ecnt + " entries GOLD-indexed in " + (System.currentTimeMillis() - start) / 1000 + " seconds...END");
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) TerminologyService(org.nextprot.api.core.service.TerminologyService) MasterIdentifierService(org.nextprot.api.core.service.MasterIdentifierService) EntryGoldSolrIndexer(org.nextprot.api.tasks.solr.indexer.EntryGoldSolrIndexer)

Aggregations

MasterIdentifierService (org.nextprot.api.core.service.MasterIdentifierService)2 StatementDao (org.nextprot.api.core.dao.StatementDao)1 Entry (org.nextprot.api.core.domain.Entry)1 StatementExporter (org.nextprot.api.core.export.StatementExporter)1 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)1 TerminologyService (org.nextprot.api.core.service.TerminologyService)1 EntryGoldSolrIndexer (org.nextprot.api.tasks.solr.indexer.EntryGoldSolrIndexer)1