Search in sources :

Example 61 with Annotation

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

the class IsoformPEFFHeaderBuilderTest method newIsoformPEFFHeaderBuilder.

private IsoformPEFFHeaderBuilder newIsoformPEFFHeaderBuilder(String isoName) {
    String entryAccession = isoformService.findEntryAccessionFromIsoformAccession(isoName);
    Isoform isoform = isoformService.findIsoform(isoName);
    List<Annotation> isoformAnnotations = annotationService.findAnnotations(entryAccession).stream().filter(annotation -> annotation.isSpecificForIsoform(isoName)).collect(Collectors.toList());
    Overview overview = overviewService.findOverviewByEntry(entryAccession);
    return new IsoformPEFFHeaderBuilder(isoform, isoformAnnotations, overview, terminologyService::findPsiModAccession, terminologyService::findPsiModName);
}
Also used : CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) OverviewService(org.nextprot.api.core.service.OverviewService) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationService(org.nextprot.api.core.service.AnnotationService) Collectors(java.util.stream.Collectors) TerminologyService(org.nextprot.api.core.service.TerminologyService) Overview(org.nextprot.api.core.domain.Overview) List(java.util.List) IsoformPEFFHeader(org.nextprot.api.core.domain.IsoformPEFFHeader) IsoformService(org.nextprot.api.core.service.IsoformService) Assert(org.junit.Assert) Isoform(org.nextprot.api.core.domain.Isoform) Isoform(org.nextprot.api.core.domain.Isoform) Overview(org.nextprot.api.core.domain.Overview) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 62 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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 63 with Annotation

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

the class AnnotationUtilsTest method shouldNotReturnAnnotationIfOverlapsALittleBit.

@Test
public void shouldNotReturnAnnotationIfOverlapsALittleBit() {
    // This is used on the pepX logic, if you want to change the logic be careful (add a flag or change the method name for example), but keep the same logic for pepX
    String isoName = "iso-1";
    Annotation a1 = mock(Annotation.class);
    when(a1.isAnnotationPositionalForIsoform(isoName)).thenReturn(true);
    when(a1.getStartPositionForIsoform(isoName)).thenReturn(5);
    when(a1.getEndPositionForIsoform(isoName)).thenReturn(10);
    assertTrue(AnnotationUtils.filterAnnotationsBetweenPositions(10, 20, Arrays.asList(a1), isoName).isEmpty());
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 64 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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 65 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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)

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