Search in sources :

Example 11 with AnnotationIsoformSpecificity

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

the class ByFeaturePositionComparator method getFirstIsoformSpecificity.

static AnnotationIsoformSpecificity getFirstIsoformSpecificity(Collection<AnnotationIsoformSpecificity> targets) {
    Preconditions.checkNotNull(targets);
    Preconditions.checkArgument(!targets.isEmpty());
    Iterator<AnnotationIsoformSpecificity> iter = targets.iterator();
    AnnotationIsoformSpecificity first = iter.next();
    while (iter.hasNext()) {
        AnnotationIsoformSpecificity specificity = iter.next();
        int cmp = compareAnnotByNullablePosition(specificity.getFirstPosition(), specificity.getLastPosition(), first.getFirstPosition(), first.getLastPosition());
        if (cmp < 0) {
            first = specificity;
        }
    }
    return first;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)

Example 12 with AnnotationIsoformSpecificity

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase2.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase2() {
    // BinaryInteraction with 2 isoforms, 2 specific flag => should return 0 isoformDiplayed as specific
    int isoCount = 2;
    Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("iso1");
    spec1.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso1", spec1);
    AnnotationIsoformSpecificity spec2 = new AnnotationIsoformSpecificity();
    spec2.setIsoformAccession("iso2");
    spec2.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso2", spec2);
    Annotation annot = mock(Annotation.class);
    when(annot.getAPICategory()).thenReturn(AnnotationCategory.BINARY_INTERACTION);
    when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
    List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
    assertEquals(0, result.size());
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 13 with AnnotationIsoformSpecificity

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase1.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase1() {
    // BinaryInteraction with 2 isoforms, 1 specific flag => should return 1 isoformDiplayed as specific
    int isoCount = 2;
    Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("iso1");
    spec1.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso1", spec1);
    AnnotationIsoformSpecificity spec2 = new AnnotationIsoformSpecificity();
    spec2.setIsoformAccession("iso2");
    spec2.setSpecificity("BY DEFAULT");
    targetIsoformMap.put("iso2", spec2);
    Annotation annot = mock(Annotation.class);
    when(annot.getAPICategory()).thenReturn(AnnotationCategory.BINARY_INTERACTION);
    when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
    List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
    assertEquals(1, result.size());
    assertEquals("iso1", result.get(0));
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 14 with AnnotationIsoformSpecificity

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase4.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase4() {
    // BinaryInteraction with 1 isoform, 0 specific flag => 0 isoformDiplayed as specific
    int isoCount = 1;
    Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("iso1");
    spec1.setSpecificity("BY DEFAULT");
    targetIsoformMap.put("iso1", spec1);
    Annotation annot = mock(Annotation.class);
    when(annot.getAPICategory()).thenReturn(AnnotationCategory.BINARY_INTERACTION);
    when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
    List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
    assertEquals(0, result.size());
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 15 with AnnotationIsoformSpecificity

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase2.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase2() {
    // Non BinaryInteraction with 2 isoforms, 2 targetingIsoform records => should return 0 isoformDiplayed as specific
    int isoCount = 2;
    Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("iso1");
    spec1.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso1", spec1);
    AnnotationIsoformSpecificity spec2 = new AnnotationIsoformSpecificity();
    spec2.setIsoformAccession("iso2");
    spec2.setSpecificity("SPECIFIC");
    targetIsoformMap.put("iso2", spec2);
    Annotation annot = mock(Annotation.class);
    when(annot.getAPICategory()).thenReturn(AnnotationCategory.GO_MOLECULAR_FUNCTION);
    when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
    List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
    assertEquals(0, result.size());
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Aggregations

AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)24 Annotation (org.nextprot.api.core.domain.annotation.Annotation)19 Test (org.junit.Test)12 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)12 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 Isoform (org.nextprot.api.core.domain.Isoform)3 ArrayList (java.util.ArrayList)2 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Family (org.nextprot.api.core.domain.Family)1 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)1 TargetIsoformStatementPosition (org.nextprot.commons.statements.TargetIsoformStatementPosition)1