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;
}
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());
}
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));
}
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());
}
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());
}
Aggregations