Search in sources :

Example 66 with Annotation

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

Example 67 with Annotation

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

the class AnnotationUtilsTest method exportMergedAnnotationsForBrca1AndScn9A.

// @Test
public void exportMergedAnnotationsForBrca1AndScn9A() throws FileNotFoundException {
    List<String> accessions = Arrays.asList("NX_Q15858", "NX_P38398");
    List<String> headers = Arrays.asList("accession", "uniqueName", "category", "annotationName", "annotationHash", "masterPosition");
    PrintWriter pw = new PrintWriter("mergedBrca1AndScn9AVariants.tsv");
    // write header line
    pw.append(headers.stream().collect(Collectors.joining("\t"))).append("\n");
    for (String accession : accessions) {
        Entry entry = entryBuilderService.build(EntryConfig.newConfig(accession).withAnnotations());
        List<Annotation> mergedAnnotations = entry.getAnnotations().stream().filter(a -> a.getAnnotationHash() != null).filter(a -> a.getUniqueName().startsWith("AN")).filter(a -> a.getAPICategory() == AnnotationCategory.VARIANT || a.getAPICategory() == AnnotationCategory.MUTAGENESIS).collect(Collectors.toList());
        pw.append(exportAnnotationsAsTsvString(entry, mergedAnnotations));
    }
    pw.close();
}
Also used : CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) java.util(java.util) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) BioObject(org.nextprot.api.core.domain.BioObject) IsoformUtils(org.nextprot.api.core.utils.IsoformUtils) IsoformSequencePositionMapper(org.nextprot.api.core.utils.seqmap.IsoformSequencePositionMapper) AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) PrintWriter(java.io.PrintWriter) Entry(org.nextprot.api.core.domain.Entry) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) PropertyApiModel(org.nextprot.api.commons.constants.PropertyApiModel) AnnotationService(org.nextprot.api.core.service.AnnotationService) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) Isoform(org.nextprot.api.core.domain.Isoform) Mockito.mock(org.mockito.Mockito.mock) Entry(org.nextprot.api.core.domain.Entry) Annotation(org.nextprot.api.core.domain.annotation.Annotation) PrintWriter(java.io.PrintWriter)

Example 68 with Annotation

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

the class AnnotationUtilsTest method shouldTurnSequenceCautionRelativeEvidenceIntoDifferingSequenceProperty.

@Test
public void shouldTurnSequenceCautionRelativeEvidenceIntoDifferingSequenceProperty() {
    long annotId = 1234;
    // create evidence (type=3)
    AnnotationEvidence ev3 = new AnnotationEvidence();
    ev3.setAnnotationId(annotId);
    ev3.setAssignedBy(null);
    ev3.setAssignmentMethod(null);
    ev3.setEvidenceCodeAC("ECO-000003");
    ev3.setEvidenceId(3000);
    ev3.setNegativeEvidence(false);
    ev3.setQualityQualifier("GOLD");
    ev3.setResourceAccession("AC-0003");
    ev3.setResourceAssociationType("evidence");
    ev3.setResourceDb("DB-0003");
    ev3.setResourceDescription("Resource descr 3");
    ev3.setResourceId(3333);
    ev3.setResourceType("database");
    // create relative info (type=2)
    AnnotationEvidence ev2 = new AnnotationEvidence();
    ev2.setAnnotationId(annotId);
    ev2.setAssignedBy(null);
    ev2.setAssignmentMethod(null);
    ev2.setEvidenceCodeAC(null);
    ev2.setEvidenceId(2000);
    ev2.setNegativeEvidence(false);
    ev2.setQualityQualifier("SILVER");
    ev2.setResourceAccession("AC-0002");
    ev2.setResourceAssociationType("relative");
    ev2.setResourceDb("DB-0002");
    ev2.setResourceDescription("Resource descr 2");
    ev2.setResourceId(2222);
    ev2.setResourceType("database");
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(ev2);
    evidences.add(ev3);
    // create an annotation
    Annotation annot = new Annotation();
    annot.setAnnotationId(annotId);
    annot.setUniqueName("some_sequence_caution_annotation");
    annot.setCategory(AnnotationCategory.SEQUENCE_CAUTION.getDbAnnotationTypeName());
    annot.setQualityQualifier("GOLD");
    annot.setEvidences(evidences);
    // will be modified by convertType2EvidencesToProperties()
    annot.setDescription("");
    List<Annotation> annotations = new ArrayList<>();
    annotations.add(annot);
    AnnotationUtils.convertRelativeEvidencesToProperties(annotations);
    // evidence type 2 should removed
    Assert.assertEquals(1, annotations.get(0).getEvidences().size());
    // property should be created (replaces evidence removed)
    Assert.assertEquals(1, annotations.get(0).getProperties().size());
    assertContainsExpectedProperties(annotations.get(0).getProperties(), newAnnotationProperty(1234, "AC-0002", PropertyApiModel.NAME_DIFFERING_SEQUENCE, String.valueOf(ev2.getResourceId()), PropertyApiModel.VALUE_TYPE_RIF));
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 69 with Annotation

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

the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase4.

@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase4() {
    // BinaryInteraction with 2 isoforms, 1 targetingIsoform record => 1 isoformDiplayed as specific
    int isoCount = 2;
    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.GO_MOLECULAR_FUNCTION);
    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 70 with Annotation

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

the class ByAnnotationSubjectComparatorTest method compareAnnotationsSecondDefinedSubjectComponent.

@Test
public void compareAnnotationsSecondDefinedSubjectComponent() throws Exception {
    ByAnnotationSubjectComparator comparator = new ByAnnotationSubjectComparator(new HashMap<>());
    Annotation a2 = new Annotation();
    a2.setSubjectComponents(Collections.emptyList());
    int cmp = comparator.compare(new Annotation(), a2);
    Assert.assertEquals(1, cmp);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) 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