Search in sources :

Example 1 with EntryConfig

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

the class PepXServiceImpl method findEntriesWithPeptides.

@Override
public List<Entry> findEntriesWithPeptides(String peptides, boolean modeIsoleucine) {
    List<Entry> entries = new ArrayList<>();
    PepXResponse pepXResponse = getPepXResponse(peptides, modeIsoleucine);
    Set<String> entriesNames = pepXResponse.getEntriesNames();
    for (String entryName : entriesNames) {
        EntryConfig targetIsoconf = EntryConfig.newConfig(entryName).withTargetIsoforms().with("variant").withOverview().withoutAdditionalReferences().withoutProperties();
        Entry entry = entryBuilderService.build(targetIsoconf);
        List<Annotation> virtualAnnotations = new ArrayList<>();
        Set<String> peptidesForEntry = pepXResponse.getPeptidesForEntry(entryName);
        for (String peptide : peptidesForEntry) {
            PepXEntryMatch pepxEntryMatch = pepXResponse.getPeptideMatch(peptide).getPepxMatchesForEntry(entryName);
            if (pepxEntryMatch != null && pepxEntryMatch.getIsoforms() != null && pepxEntryMatch.getIsoforms().size() > 0) {
                virtualAnnotations.addAll(buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, pepxEntryMatch.getIsoforms(), entry.getAnnotations(), entry.getIsoforms()));
            }
        }
        if ((virtualAnnotations != null) && (!virtualAnnotations.isEmpty())) {
            Entry resultEntry = new Entry(entry.getUniqueName());
            // Adds the overview as well
            resultEntry.setOverview(entry.getOverview());
            resultEntry.setAnnotations(virtualAnnotations);
            entries.add(resultEntry);
        }
    }
    // add peptide unicity extra info required to unicity checker and peptide viewer
    updateAnnotationsWithPeptideProperties(entries);
    return entries;
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) PepXResponse(org.nextprot.api.web.domain.PepXResponse) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 2 with EntryConfig

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

the class EntryXLSWriter method writeEntry.

@Override
protected void writeEntry(String entryName) throws IOException {
    EntryConfig config = EntryConfig.newConfig(entryName);
    for (EntryBlock block : entryDataProvider.getSourceEntryBlocks()) {
        config.withBlock(block);
    }
    Entry entry = entryBuilderService.build(config);
    for (Record record : entryDataProvider.getRecords(entry)) {
        HSSFRow row = worksheet.createRow(rowIndex);
        writeRecord(row, record);
        rowIndex++;
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) EntryBlock(org.nextprot.api.core.service.export.format.EntryBlock)

Example 3 with EntryConfig

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

the class ServiceEntryValidation method checkValidEntry.

@Around("execution(* org.nextprot.api.*.service.*.*(..))")
public // @Around("execution(* org.nextprot.api.*.service.*.*(.., @aspects.ValidEntry (*), ..))")
Object checkValidEntry(ProceedingJoinPoint pjp) throws Throwable {
    Object[] arguments = pjp.getArgs();
    for (Object arg : arguments) {
        if ((arg != null) && EntryConfig.class.isAssignableFrom(arg.getClass())) {
            String argument = ((EntryConfig) arg).getEntryName();
            String entryAccession = EntryUtils.getEntryName(argument);
            if (!uniqueNames.contains(entryAccession)) {
                LOGGER.error("neXtProt entry " + argument + " was not found, throwing EntryNotFoundException");
                throw new EntryNotFoundException(argument);
            }
        }
    }
    MethodSignature ms = (MethodSignature) pjp.getSignature();
    Annotation[][] annotations = ms.getMethod().getParameterAnnotations();
    int i = 0;
    for (Annotation[] paramAnnotations : annotations) {
        for (Annotation annotation : paramAnnotations) {
            if (ValidEntry.class.isAssignableFrom(annotation.getClass())) {
                if (!uniqueNames.contains(arguments[i])) {
                    LOGGER.error("neXtProt entry " + arguments[i] + " was not found, throwing EntryNotFoundException");
                    throw new EntryNotFoundException((String) arguments[i]);
                }
                break;
            }
        }
        i++;
    }
    return pjp.proceed();
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) EntryNotFoundException(org.nextprot.api.commons.exception.EntryNotFoundException) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Annotation(java.lang.annotation.Annotation) Around(org.aspectj.lang.annotation.Around)

Example 4 with EntryConfig

use of org.nextprot.api.core.service.fluent.EntryConfig 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)

Aggregations

EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)4 Entry (org.nextprot.api.core.domain.Entry)3 Annotation (java.lang.annotation.Annotation)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Around (org.aspectj.lang.annotation.Around)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1 EntryNotFoundException (org.nextprot.api.commons.exception.EntryNotFoundException)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 EntryBlock (org.nextprot.api.core.service.export.format.EntryBlock)1 PepXResponse (org.nextprot.api.web.domain.PepXResponse)1 PepXEntryMatch (org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch)1