Search in sources :

Example 6 with Annotation

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();
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 7 with Annotation

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());
        }
    }
}
Also used : AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 8 with Annotation

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);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 9 with Annotation

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"));
    }
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 10 with Annotation

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

Annotation (org.nextprot.api.core.domain.annotation.Annotation)120 Test (org.junit.Test)79 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)32 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)28 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)22 ArrayList (java.util.ArrayList)19 Isoform (org.nextprot.api.core.domain.Isoform)17 Entry (org.nextprot.api.core.domain.Entry)9 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)7 BioObject (org.nextprot.api.core.domain.BioObject)7 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)7 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)6 AnnotationSimilarityPredicate (org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate)6 Collectors (java.util.stream.Collectors)5 NextProtException (org.nextprot.api.commons.exception.NextProtException)5 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)5 Assert (org.junit.Assert)4 CvTerm (org.nextprot.api.core.domain.CvTerm)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 java.util (java.util)3