use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method exportAnnotationsAsTsvString.
private String exportAnnotationsAsTsvString(Entry entry, List<Annotation> mergedAnnotations) {
Isoform canonical = IsoformUtils.getCanonicalIsoform(entry);
StringBuilder sb = new StringBuilder();
for (Annotation annotation : mergedAnnotations) {
List<String> row = Arrays.asList(entry.getUniqueName(), annotation.getUniqueName(), annotation.getAPICategory().getApiTypeName(), annotation.getAnnotationName(), annotation.getAnnotationHash(), String.valueOf(computeMasterPos(canonical, annotation.getTargetingIsoformsMap().get(canonical.getIsoformAccession()).getFirstPosition())));
// write annotation line
sb.append(row.stream().collect(Collectors.joining("\t"))).append("\n");
}
return sb.toString();
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldFilterByPropertyTopologyAccession.
@Test
public void shouldFilterByPropertyTopologyAccession() {
List<Annotation> annotations = entryBuilderService.build(EntryConfig.newConfig("NX_P04083").with("subcellular-location")).getAnnotations();
List<Annotation> filtered = annotations.stream().filter(annotationService.buildPropertyPredicate("topology", "SL-9903")).collect(Collectors.toList());
Assert.assertTrue(!filtered.isEmpty());
for (Annotation annot : filtered) {
for (AnnotationProperty property : annot.getPropertiesByKey("topology")) {
Assert.assertEquals("Peripheral membrane protein", property.getValue());
}
}
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldReturnAnnotationIfContainedInTheRange.
@Test
public void shouldReturnAnnotationIfContainedInTheRange() {
String isoName = "iso-1";
Annotation a1 = mock(Annotation.class);
when(a1.isAnnotationPositionalForIsoform(isoName)).thenReturn(true);
when(a1.getStartPositionForIsoform(isoName)).thenReturn(10);
when(a1.getEndPositionForIsoform(isoName)).thenReturn(12);
List<Annotation> filteredAnnots = AnnotationUtils.filterAnnotationsBetweenPositions(10, 20, Arrays.asList(a1), isoName);
assertEquals(filteredAnnots.size(), 1);
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldFilterByPropertyTopologyExistence.
@Test
public void shouldFilterByPropertyTopologyExistence() {
List<Annotation> annotations = entryBuilderService.build(EntryConfig.newConfig("NX_P04083").with("subcellular-location")).getAnnotations();
Assert.assertEquals(22, annotations.size());
List<Annotation> filtered = annotations.stream().filter(annotationService.buildPropertyPredicate("topology", null)).collect(Collectors.toList());
Assert.assertEquals(4, filtered.size());
for (Annotation annot : filtered) {
Assert.assertNotNull(annot.getPropertiesByKey("topology"));
}
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase3.
@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForBinaryInteractionCase3() {
// BinaryInteraction with 1 isoform, 1 specific flag => 0 isoformDiplayed as specific
int isoCount = 1;
Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
spec1.setIsoformAccession("iso1");
spec1.setSpecificity("SPECIFIC");
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());
}
Aggregations