Search in sources :

Example 1 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testPseudoUniqueCase2.

@Test
public void testPseudoUniqueCase2() {
    // first 2 isoforms have same sequence (same md5) and other isoforms belong to same entry => PSEUDO UNIQUE
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_P0DN79-1", "NX_P35520-1", "NX_P35520-2", "NX_P35520-3"));
    PeptideUnicity result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.PSEUDO_UNIQUE, result.getValue());
    Set<String> expEquivSet = new TreeSet<String>(Arrays.asList("NX_P0DN79-1", "NX_P35520-1"));
    Assert.assertEquals(expEquivSet, result.getEquivalentIsoforms());
}
Also used : PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) TreeSet(java.util.TreeSet) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 2 with PeptideUnicity

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

Example 3 with PeptideUnicity

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

the class PeptideUnicityServiceImpl method getPeptideNameUnicityMap.

@Override
@Cacheable("peptide-name-unicity-map")
public Map<String, PeptideUnicity> getPeptideNameUnicityMap() {
    LOGGER.info("Starting, thread: " + Thread.currentThread().getId());
    Map<String, PeptideUnicity> result = new HashMap<>();
    List<String> list = peptideMappingDao.findPeptideIsoformMappingsList();
    LOGGER.info("Got mapping iso-pep from db, size: " + list.size() + " , thread: " + Thread.currentThread().getId());
    for (int i = 0; i < list.size(); i++) {
        String row = list.get(i);
        String[] fields = row.split(":");
        String pep = fields[0];
        String[] isolist = fields[1].split(",");
        Set<String> mappedIsoSet = new HashSet<>(Arrays.asList(isolist));
        PeptideUnicity pu = getPeptideUnicityFromMappingIsoforms(mappedIsoSet);
        result.put(pep, pu);
    }
    LOGGER.info("Computed uncity for peptides, size: " + result.size() + " , thread: " + Thread.currentThread().getId());
    LOGGER.info("Done" + " , thread: " + Thread.currentThread().getId());
    return result;
}
Also used : PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) HashMap(java.util.HashMap) HashSet(java.util.HashSet) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testUniqueCase1.

/* 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 * 
 * UNIQUE cases
 * 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 */
@Test
public void testUniqueCase1() {
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_ENTRY1-1"));
    PeptideUnicity result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.UNIQUE, result.getValue());
}
Also used : PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) TreeSet(java.util.TreeSet) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 5 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testPseudoUniqueCase1.

/* 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 * 
 * PSEUDO_UNIQUE cases
 * 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 * Each line in this comment contains a list of isoforms that are known to be identical but in different entries
 * If a peptide matches isoforms of multiple entries known as sharing an isoform then the peptide is said PSEUDO_UNIQUE
 * NX_A0A087WW87-1,NX_P01614-1
 * NX_O43812-1,NX_Q96PT3-2
 * NX_Q6S5H4-1,NX_A0JP26-1
 * NX_P0DMU8-1,NX_P0DMV0-1,NX_P0DMU7-1
 * NX_Q01081-1,NX_P0DN76-1
 * NX_B7ZAQ6-1,NX_P0CG08-1
 * NX_B0FP48-1,NX_E5RIL1-1
 * NX_P0DN79-1,NX_P35520-1
 */
@Test
public void testPseudoUniqueCase1() {
    // the 2 isoform have same sequence (same md5) => PSEUDO UNIQUE
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_P0DN79-1", "NX_P35520-1"));
    PeptideUnicity result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.PSEUDO_UNIQUE, result.getValue());
    Assert.assertEquals(isoset, result.getEquivalentIsoforms());
}
Also used : PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) TreeSet(java.util.TreeSet) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Aggregations

PeptideUnicity (org.nextprot.api.core.domain.PeptideUnicity)12 Test (org.junit.Test)8 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)8 TreeSet (java.util.TreeSet)7 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 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)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 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1