Search in sources :

Example 1 with PeptideUnicityService

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

the class PepXServiceImpl method computePeptideUnicityStatus.

/**
 * Computes a unicity value for each peptide: UNIQUE, PSEUDO_UNIQUE, NON_UNIQUE
 * based on the response returned by pepx (a list of peptide - isoform matches)
 * by using the PeptideUnicityService
 * @param entries
 * @param withVariants
 * @return a map with key = peptide sequence, value = unicity value
 */
private Map<String, PeptideUnicity> computePeptideUnicityStatus(List<Entry> entries, boolean withVariants) {
    Map<String, Set<String>> pepIsoSetMap = new HashMap<>();
    entries.forEach(e -> {
        e.getAnnotationsByCategory(AnnotationCategory.PEPX_VIRTUAL_ANNOTATION).stream().filter(a -> a.getVariant() == null || withVariants).forEach(a -> {
            String pep = a.getCvTermName();
            if (!pepIsoSetMap.containsKey(pep))
                pepIsoSetMap.put(pep, new TreeSet<String>());
            a.getTargetingIsoformsMap().values().forEach(i -> {
                pepIsoSetMap.get(pep).add(i.getIsoformAccession());
            });
        });
    });
    Map<String, PeptideUnicity> pepUnicityMap = new HashMap<>();
    pepIsoSetMap.entrySet().forEach(e -> {
        String pep = e.getKey();
        PeptideUnicity pu = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(e.getValue());
        pepUnicityMap.put(pep, pu);
    });
    return pepUnicityMap;
}
Also used : java.util(java.util) PepXResponse(org.nextprot.api.web.domain.PepXResponse) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) URL(java.net.URL) Annotation(org.nextprot.api.core.domain.annotation.Annotation) NextProtException(org.nextprot.api.commons.exception.NextProtException) Autowired(org.springframework.beans.factory.annotation.Autowired) PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) Value(org.springframework.beans.factory.annotation.Value) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) Service(org.springframework.stereotype.Service) URLConnection(java.net.URLConnection) IsoformUtils(org.nextprot.api.core.utils.IsoformUtils) AnnotationVariant(org.nextprot.api.core.domain.annotation.AnnotationVariant) AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) PeptideUnicityService(org.nextprot.api.core.service.PeptideUnicityService) Entry(org.nextprot.api.core.domain.Entry) PeptideUtils(org.nextprot.api.core.utils.PeptideUtils) IOException(java.io.IOException) PropertyApiModel(org.nextprot.api.commons.constants.PropertyApiModel) InputStreamReader(java.io.InputStreamReader) AnnotationUtils(org.nextprot.api.core.service.annotation.AnnotationUtils) PepXService(org.nextprot.api.web.service.PepXService) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) PepxUtils(org.nextprot.api.web.domain.PepxUtils) BufferedReader(java.io.BufferedReader) Isoform(org.nextprot.api.core.domain.Isoform) PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 java.util (java.util)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 PropertyApiModel (org.nextprot.api.commons.constants.PropertyApiModel)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Entry (org.nextprot.api.core.domain.Entry)1 Isoform (org.nextprot.api.core.domain.Isoform)1 PeptideUnicity (org.nextprot.api.core.domain.PeptideUnicity)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)1 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)1 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)1 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)1 PeptideUnicityService (org.nextprot.api.core.service.PeptideUnicityService)1