Search in sources :

Example 41 with Entry

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

the class EntryBuilderServiceImpl method build.

@Override
public Entry build(EntryConfig entryConfig) {
    String entryName = EntryUtils.getEntryName(entryConfig.getEntryName());
    Entry entry = new Entry(entryName);
    // Lock per entry in case the cache is not set yet (should be quite) fast thougth
    synchronized (getOrPutSynchronizer(entryName)) {
        // Always set properties about the entry, unless it was explicitly said not to set them
        if (!entryConfig.hasNoProperties()) {
            entry.setProperties(entryPropertiesService.findEntryProperties(entryName));
        }
        if (entryConfig.hasOverview()) {
            entry.setOverview(this.overviewService.findOverviewByEntry(entryName));
        }
        if (entryConfig.hasPublications()) {
            entry.setPublications(this.publicationService.findPublicationsByEntryName(entryName));
        }
        if (entryConfig.hasXrefs()) {
            entry.setXrefs(this.xrefService.findDbXrefsByMaster(entryName));
        }
        if (entryConfig.hasIdentifiers()) {
            entry.setIdentifiers(this.identifierService.findIdentifiersByMaster(entryName));
        }
        if (entryConfig.hasChromosomalLocations()) {
            entry.setChromosomalLocations(this.geneService.findChromosomalLocationsByEntry(entryName));
        }
        if (entryConfig.hasGenomicMappings()) {
            entry.setGenomicMappings(this.genomicMappingService.findGenomicMappingsByEntryName(entryName));
        }
        if (entryConfig.hasTargetIsoforms()) {
            entry.setIsoforms(this.isoformService.findIsoformsByEntryName(entryName));
        }
        if (entryConfig.hasGeneralAnnotations()) {
            if (entryConfig.hasBed()) {
                entry.setAnnotations(this.annotationService.findAnnotations(entryName));
            } else {
                entry.setAnnotations(this.annotationService.findAnnotationsExcludingBed(entryName));
            }
        }
        if (entryConfig.hasMdata()) {
            List<Annotation> annotations = entry.getAnnotations();
            // In case we did't set annotations but we need them to find experimental contexts
            if (annotations == null) {
                annotations = this.annotationService.findAnnotations(entryName);
            }
            List<Long> mdataIds = new ArrayList<>(EntryUtils.getMdataIds(annotations));
            entry.setMdataList(mdataService.findMdataByIds(mdataIds));
        }
        if (entryConfig.hasExperimentalContext()) {
            List<Annotation> annotations = entry.getAnnotations();
            // In case we did't set annotations but we need them to find experimental contexts
            if (annotations == null) {
                annotations = this.annotationService.findAnnotations(entryName);
            }
            Set<Long> ecIds = EntryUtils.getExperimentalContextIds(annotations);
            entry.setExperimentalContexts(expCtxService.findExperimentalContextsByIds(ecIds));
        }
        if (entryConfig.hasInteractions()) {
            entry.setInteractions(this.interactionService.findInteractionsByEntry(entryName));
        }
        if (entryConfig.hasEnzymes()) {
            entry.setEnzymes(terminologyService.findEnzymeByMaster(entryName));
        }
        if ((entryConfig.hasGeneralAnnotations() || entryConfig.hasSubPart())) {
            // TODO should be added in annotation list
            // adds isoforms, publications, xrefs and experimental contexts
            setEntryAdditionalInformation(entry, entryConfig);
        }
    }
    // CPU Intensive
    if (entryConfig.hasSubPart() || entryConfig.hasGoldOnly()) {
        // TODO should be added in annotation list
        return EntryUtils.filterEntryBySubPart(entry, entryConfig);
    } else {
        return entry;
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 42 with Entry

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

the class PageViewTest method shouldDoIt.

@Ignore
@Test
public void shouldDoIt() throws Exception {
    // String entryName="NX_Q8WZ42";  // TITIN, 1st most annotated protein: 147ms processing
    // String entryName="NX_Q5VST9";  // OBSCN, 3rd most annotated protein:  25ms processing
    String entryName = "NX_P02649";
    // String entryName="NX_P52701";
    // String entryName="NX_P01308";
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).withEverything());
    System.out.println("- - - - - before - - - - -");
    System.out.println("annot categ : " + entry.getAnnotationsByCategory().size());
    System.out.println("annot count : " + entry.getAnnotations().size());
    System.out.println("xrefs       : " + entry.getXrefs().size());
    showXref(entry, "UniProt");
    PageView pageDef = new SequencePageView();
    long t0 = System.currentTimeMillis();
    List<DbXref> xrefs = pageDef.getFurtherExternalLinksXrefs(entry);
    t0 = System.currentTimeMillis() - t0;
    System.out.println("- - - - - after  - - - - -");
    showXref(xrefs);
    System.out.println("xrefs       : " + xrefs.size());
    System.out.println("proc time ms: " + t0);
    System.out.println("- - - - - end  - - - - -");
}
Also used : SequencePageView(org.nextprot.api.core.domain.ui.page.impl.SequencePageView) PageView(org.nextprot.api.core.domain.ui.page.PageView) DbXref(org.nextprot.api.core.domain.DbXref) Entry(org.nextprot.api.core.domain.Entry) SequencePageView(org.nextprot.api.core.domain.ui.page.impl.SequencePageView) Ignore(org.junit.Ignore) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 43 with Entry

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

the class EntryVelocityBasedStreamWriter method streamWithVelocityTemplate.

final void streamWithVelocityTemplate(String entryName, String... otherViewNames) throws IOException {
    EntryConfig entryConfig = EntryConfig.newConfig(entryName);
    entryConfig.with(viewName);
    for (String otherName : otherViewNames) {
        entryConfig.with(otherName);
    }
    Entry entry = entryBuilderService.build(entryConfig);
    handleTemplateMerge(template, newNXVelocityContext(entry));
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig)

Example 44 with Entry

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

the class EntryPageServiceTest method testFilterEntryContentInPageView.

@Test
public void testFilterEntryContentInPageView() {
    String entryAC = "NX_P02649";
    Entry originalEntry = entryBuilderService.build(EntryConfig.newConfig(entryAC).withEverything());
    Entry filteredEntry;
    filteredEntry = entryPageService.filterXrefInPageView(entryAC, "sequence");
    Assert.assertTrue(originalEntry.getXrefs().size() > filteredEntry.getXrefs().size());
    // uniprot xref should be present
    Assert.assertTrue(filteredEntry.getXrefs().stream().anyMatch(x -> x.getDatabaseName().equals("UniProt") && x.getAccession().equals(originalEntry.getUniprotName())));
    filteredEntry = entryPageService.filterXrefInPageView(entryAC, "expression");
    Assert.assertTrue(originalEntry.getXrefs().size() > filteredEntry.getXrefs().size());
    // uniprot xref should NOT be present
    Assert.assertFalse(filteredEntry.getXrefs().stream().anyMatch(x -> x.getDatabaseName().equals("UniProt") && x.getAccession().equals(originalEntry.getUniprotName())));
}
Also used : Entry(org.nextprot.api.core.domain.Entry) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) Map(java.util.Map) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) Assert(org.junit.Assert) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) Entry(org.nextprot.api.core.domain.Entry) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 45 with Entry

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

the class BuildEntryTest method testVirtualGeneShouldBeAbsent.

@Test
public void testVirtualGeneShouldBeAbsent() throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_Q6ZTC4").withGenomicMappings().withChromosomalLocations().withXrefs());
    Assert.assertEquals(1, entry.getChromosomalLocations().size());
    Assert.assertTrue(!entry.getChromosomalLocations().get(0).getAccession().isEmpty());
    Assert.assertTrue(entry.getGenomicMappings().isEmpty());
    for (DbXref xref : entry.getXrefs()) {
        Assert.assertTrue(!xref.getAccession().matches("NX_VG.+"));
    }
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) Entry(org.nextprot.api.core.domain.Entry) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

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