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;
}
}
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 - - - - -");
}
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));
}
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())));
}
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.+"));
}
}
Aggregations