Search in sources :

Example 6 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testNonUniqueCase2.

@Test
public void testNonUniqueCase2() {
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_ENTRY1-1", "NX_ENTRY2-1", "NX_ENTRY2-2"));
    PeptideUnicity result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.NOT_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 7 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testMultiPseudoUnique.

/* 
     * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     * 
     * multiple PSEUDO_UNIQUE cases to see if cache of isoform service is effective 
     * 
     * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     */
@Test
public void testMultiPseudoUnique() {
    // the 2 isoform have same sequence (same md5) => PSEUDO UNIQUE
    long t0;
    PeptideUnicity result;
    // first call
    t0 = System.currentTimeMillis();
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_P0DN79-1", "NX_P35520-1"));
    result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.PSEUDO_UNIQUE, result.getValue());
    long tFirst = System.currentTimeMillis() - t0;
    // loop on 100 calls
    t0 = System.currentTimeMillis();
    for (int i = 0; i < 100; i++) {
        String iso = "NX_P35520-" + (i + 2);
        isoset.add(iso);
        result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
        Assert.assertEquals(PeptideUnicity.Value.PSEUDO_UNIQUE, result.getValue());
    }
    long tNext100 = System.currentTimeMillis() - t0;
    System.out.println("time for very first call: " + tFirst + "[ms]");
    System.out.println("time for next 100  calls: " + tNext100 + "[ms]");
// line below ok only if cache is cleared before starting the test
// Assert.assertTrue(tFirst > tNext100);
}
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 8 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method tesUnicityOfSomeKnownPeptides.

/* 
     * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     * 
     * 
     * 
     * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     */
@Test
public void tesUnicityOfSomeKnownPeptides() {
    // clear related cache to make sure we have no PeptideUnicity serialization version conflict
    cacheManager.getCache("peptide-name-unicity-map").clear();
    PeptideUnicity pu;
    Set<String> expectedEquivalentIsoSet;
    long t0;
    // first call
    t0 = System.currentTimeMillis();
    // [NX_P02771-1]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT01668698");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.UNIQUE);
    long tFirst = System.currentTimeMillis() - t0;
    // subsequent calls should use cache
    t0 = System.currentTimeMillis();
    // maps [NX_P02679-1, NX_P02679-2]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT01410369");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.UNIQUE);
    // maps [NX_O14815-1, NX_O14815-2, NX_P07384-1, NX_P17655-1, NX_P17655-2]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT00361176");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.NOT_UNIQUE);
    // maps [NX_B9A064-1, NX_P0CF74-1, NX_P0CG04-1, NX_P0DOY2-1, NX_P0DOY3-1]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT00000054");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.NOT_UNIQUE);
    // maps [NX_P0DMV8-1, NX_P0DMV8-2, NX_P0DMV9-1]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT01978634");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.PSEUDO_UNIQUE);
    // SOME mapped isoforms are equivalent: [NX_P0DMV8-1, NX_P0DMV9-1]
    expectedEquivalentIsoSet = new TreeSet<>(Arrays.asList("NX_P0DMV8-1", "NX_P0DMV9-1"));
    Assert.assertEquals(expectedEquivalentIsoSet, pu.getEquivalentIsoforms());
    // maps [NX_P0DP23-1, NX_P0DP24-1, NX_P0DP25-1]
    pu = peptideUnicityService.getPeptideNameUnicityMap().get("NX_PEPT01888037");
    Assert.assertEquals(pu.getValue(), PeptideUnicity.Value.PSEUDO_UNIQUE);
    // equivalent isoforms: ALL mapped isoforms are equivalent: [NX_P0DP23-1, NX_P0DP24-1, NX_P0DP25-1]
    expectedEquivalentIsoSet = new TreeSet<>(Arrays.asList("NX_P0DP23-1", "NX_P0DP24-1", "NX_P0DP25-1"));
    Assert.assertEquals(expectedEquivalentIsoSet, pu.getEquivalentIsoforms());
    long tNext = System.currentTimeMillis() - t0;
    System.out.println("time for very first call: " + tFirst + "[ms]");
    System.out.println("time for next      calls: " + tNext + "[ms]");
// line below ok only if cache is cleared before starting the test
// Assert.assertTrue(tFirst > tNext);
}
Also used : PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 9 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testUniqueCase2.

@Test
public void testUniqueCase2() {
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_ENTRY1-1", "NX_ENTRY1-2"));
    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 10 with PeptideUnicity

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

the class PeptideUnicityServiceIntegrationTest method testNonUniqueCase1.

/* 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 * 
 * NON_UNIQUE cases
 * 
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 */
@Test
public void testNonUniqueCase1() {
    Set<String> isoset = new TreeSet<String>(Arrays.asList("NX_ENTRY1-1", "NX_ENTRY2-1"));
    PeptideUnicity result = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(isoset);
    Assert.assertEquals(PeptideUnicity.Value.NOT_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)

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