Search in sources :

Example 36 with Entry

use of org.nextprot.api.core.domain.Entry 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)

Example 37 with Entry

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

the class ChromosomeFieldBuilderDiffTest method testChromsomalLocation.

@Test
public void testChromsomalLocation() {
    for (int i = 0; i < 10; i++) {
        Entry entry = getEntry(i);
        System.out.println(entry.getUniqueName());
        testChrLoc(entry);
        testChrLocS(entry);
        testGeneBand(entry);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) SolrDiffTest(org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest) Test(org.junit.Test)

Example 38 with Entry

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

the class ChromosomeFieldBuilderIntegrationTest method testChrLoc.

@Test
public void testChrLoc() {
    Fields field = Fields.CHR_LOC;
    String entryName = "NX_Q06124";
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).withChromosomalLocations());
    ChromosomeFieldBuilder cfb = new ChromosomeFieldBuilder();
    cfb.initializeBuilder(entry);
    String chrLocValue = cfb.getFieldValue(field, String.class);
    assertTrue(chrLocValue.contains("12q24.13"));
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Fields(org.nextprot.api.solr.index.EntryIndex.Fields) ChromosomeFieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.impl.ChromosomeFieldBuilder) SolrBuildIntegrationTest(org.nextprot.api.tasks.solr.indexer.entry.SolrBuildIntegrationTest) Test(org.junit.Test)

Example 39 with Entry

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

the class AnnotationFieldBuilderGoldDiffTest method testGoldAnnotations.

@Ignore
@Test
public void testGoldAnnotations() {
    // Since the functional tests are already done in the various fieldbuilder diff tests we will only test
    // the fields that have quality qualifiers (GOs, PTMs, variants and expression...
    String[] test_list = { "NX_Q13158", "NX_Q06830", "NX_Q7Z6P3", "NX_E5RQL4", "NX_Q14721", "NX_Q7Z6P3", "NX_Q7Z713", "NX_P22102", "NX_O00115", "NX_Q13286", "NX_Q9UNK4", "NX_Q9NWT6" };
    for (int i = 0; i < test_list.length; i++) {
        // for(int i=0; i < 120; i++){
        Entry entry = getEntry(test_list[i]);
        // Entry entry = getEntry(i); // 'random' entry
        // Entry entry = getEntry("NX_P20592");
        System.out.println(entry.getUniqueName());
        testGoldAnnotations(entry);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Ignore(org.junit.Ignore) Test(org.junit.Test) SolrDiffTest(org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest)

Example 40 with Entry

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

the class AnnotationExporter method calcAnnotationStatsFromEntryAccessions.

private void calcAnnotationStatsFromEntryAccessions(List<String> entryAccessions) {
    statisticsMap.clear();
    for (String entryAccession : entryAccessions) {
        Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryAccession).withAnnotations());
        // statement rows
        for (Annotation annotation : entry.getAnnotations()) {
            if (!statisticsMap.containsKey(annotation.getAPICategory())) {
                statisticsMap.put(annotation.getAPICategory(), new NpBedMergingStats());
            }
            NpBedMergingStats stats = statisticsMap.get(annotation.getAPICategory());
            // sb.append(config.fields.stream().map(statement::getValue).collect(Collectors.joining("\t"))).append("\n");
            String annotationHash = annotation.getAnnotationHash();
            String uniqueName = annotation.getUniqueName();
            // bed integrated with np1
            if (annotationHash != null) {
                // merged
                if (!uniqueName.equals(annotationHash)) {
                    stats.addAnnot(NpBedMergingStats.AnnotType.MERGED, annotation);
                } else // not merged
                {
                    stats.addAnnot(NpBedMergingStats.AnnotType.UNMERGED_BED, annotation);
                }
            } else // np1
            {
                stats.addAnnot(NpBedMergingStats.AnnotType.UNMERGED_NP, annotation);
            }
        }
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

Entry (org.nextprot.api.core.domain.Entry)60 Test (org.junit.Test)38 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)16 Annotation (org.nextprot.api.core.domain.annotation.Annotation)9 Isoform (org.nextprot.api.core.domain.Isoform)8 EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)8 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)8 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Assert (org.junit.Assert)4 Ignore (org.junit.Ignore)4 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)4 DbXref (org.nextprot.api.core.domain.DbXref)4 ArrayList (java.util.ArrayList)3 PropertyApiModel (org.nextprot.api.commons.constants.PropertyApiModel)3 SolrDiffTest (org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 java.util (java.util)2