Search in sources :

Example 16 with AnnotationIsoformSpecificity

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

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

the class AnnotationMockServiceTest method extractIsoformSpecificity.

private static List<AnnotationIsoformSpecificity> extractIsoformSpecificity(FlatXmlDataSetExtractor extractor) throws DataSetException {
    FlatXmlDataSetExtractor.Factory<AnnotationIsoformSpecificity> factory = new FlatXmlDataSetExtractor.Factory<AnnotationIsoformSpecificity>() {

        @Override
        public AnnotationIsoformSpecificity create() {
            return new AnnotationIsoformSpecificity();
        }

        @Override
        public void setField(AnnotationIsoformSpecificity spec, String key, String value) {
            switch(key) {
                case "annotation_protein_id":
                    spec.setAnnotationId(Long.valueOf(value));
                    break;
                case "first_pos":
                    spec.setFirstPosition(Integer.valueOf(value));
                    break;
                case "last_pos":
                    spec.setLastPosition(Integer.valueOf(value));
            }
        }
    };
    List<AnnotationIsoformSpecificity> specs = extractor.extractDataList("protein_feature_positions", factory, "annotation_protein_id", "first_pos", "last_pos");
    Map<Long, String> ids = extractSequenceIdentifiers(extractor);
    for (AnnotationIsoformSpecificity spec : specs) {
        spec.setIsoformAccession(ids.get(spec.getAnnotationId()));
    }
    return specs;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)

Example 18 with AnnotationIsoformSpecificity

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

the class DbXrefServiceIntegrationTest method shouldReturn_1_OrphanetXrefAsAnnotation.

@Test
public void shouldReturn_1_OrphanetXrefAsAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_A0PJY2");
    assertTrue(annotations.size() == 1);
    Annotation annot = annotations.get(0);
    assertTrue(annot.getCategory().equals(AnnotationCategory.DISEASE.getDbAnnotationTypeName()));
    assertTrue(annot.getAPICategory() == AnnotationCategory.DISEASE);
    assertTrue(annot.getQualityQualifier().equals("GOLD"));
    Assert.assertEquals("Kallmann syndrome", annot.getDescription());
    for (AnnotationIsoformSpecificity spec : annot.getTargetingIsoformsMap().values()) {
        assertTrue(spec.getSpecificity().equals("UNKNOWN"));
    }
    assertTrue(annot.getEvidences().size() == 1);
    AnnotationEvidence evi = annot.getEvidences().get(0);
    assertTrue(evi.getAssignedBy().equals("Orphanet"));
    assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
    assertTrue(evi.getResourceAccession().equals("478"));
    assertTrue(evi.getResourceDb().equals("Orphanet"));
    Assert.assertTrue(annotations.get(0).getProperties().isEmpty());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) 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 19 with AnnotationIsoformSpecificity

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

the class DbXrefServiceIntegrationTest method shouldReturn_1_ReactomeXrefAsAnnotation.

/*
 * This query finds entries having a single xref among 'Orphanet', 'KEGGPathway' , 'Reactome' and 'DrugBank'
 * It is convenient for tests: we know we get a single annotation from xrefs for a given entry
 * Example:
 * NX_A0AVF1 for Reactome
 * NX_A1L167 for Kegg
 * NX_A0PJY2 for Orphanet
 * NX_Q9Y2D1 for DrugBank

select a.unique_name, string_agg(a.acs, ',') as acs, string_agg(a.cv_name, ',') as dbs, count(*) as dbcount, sum(a.cnt) as xrcount from (
select si.unique_name, db.cv_name, count(*) as cnt, string_agg(x.accession, ',') as acs
from sequence_identifiers si
inner join identifier_resource_assoc ira on (si.identifier_id=ira.identifier_id)
inner join db_xrefs x on (ira.resource_id=x.resource_id)
inner join cv_databases db on (x.cv_database_id=db.cv_id)
where si.cv_type_id=1 and si.cv_status_id=1 
and db.cv_name in ('Orphanet', 'DrugBank','KEGGPathway','Reactome')
group by si.unique_name, db.cv_name
) a
group by a.unique_name
having sum(a.cnt)=1
;


 */
@Test
public void shouldReturn_1_ReactomeXrefAsAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_A0AVF1");
    assertTrue(annotations.size() == 1);
    Annotation annot = annotations.get(0);
    assertTrue(annot.getCategory().equals(AnnotationCategory.PATHWAY.getDbAnnotationTypeName()));
    assertTrue(annot.getAPICategory() == AnnotationCategory.PATHWAY);
    assertTrue(annot.getQualityQualifier().equals("GOLD"));
    Assert.assertEquals("Intraflagellar transport", annot.getDescription());
    for (AnnotationIsoformSpecificity spec : annot.getTargetingIsoformsMap().values()) {
        assertTrue(spec.getSpecificity().equals("UNKNOWN"));
    }
    assertTrue(annot.getEvidences().size() == 1);
    AnnotationEvidence evi = annot.getEvidences().get(0);
    assertTrue(evi.getAssignedBy().equals("Reactome"));
    assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
    assertTrue(evi.getResourceAccession().equals("R-HSA-5620924"));
    assertTrue(evi.getResourceDb().equals("Reactome"));
    Assert.assertTrue(annotations.get(0).getProperties().isEmpty());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) 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 20 with AnnotationIsoformSpecificity

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

the class ByIsoformPositionComparatorTest method mockAnnotation.

private static Annotation mockAnnotation(long id, AnnotationCategory cat, TargetIsoform... targets) {
    Annotation mock = Mockito.mock(Annotation.class);
    when(mock.getAnnotationId()).thenReturn(id);
    when(mock.getAPICategory()).thenReturn(cat);
    Map<String, AnnotationIsoformSpecificity> map = new HashMap<>();
    for (TargetIsoform target : targets) {
        AnnotationIsoformSpecificity specificity = Mockito.mock(AnnotationIsoformSpecificity.class);
        when(specificity.getFirstPosition()).thenReturn(target.getStart());
        when(specificity.getLastPosition()).thenReturn(target.getEnd());
        when(specificity.getIsoformAccession()).thenReturn(target.getIsoformAccession());
        when(specificity.getAnnotationId()).thenReturn(id);
        when(mock.getStartPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getStart());
        when(mock.getEndPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getEnd());
        map.put(target.getIsoformAccession(), specificity);
    }
    when(mock.getTargetingIsoformsMap()).thenReturn(map);
    return mock;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)24 Annotation (org.nextprot.api.core.domain.annotation.Annotation)19 Test (org.junit.Test)12 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)12 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 Isoform (org.nextprot.api.core.domain.Isoform)3 ArrayList (java.util.ArrayList)2 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Family (org.nextprot.api.core.domain.Family)1 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)1 TargetIsoformStatementPosition (org.nextprot.commons.statements.TargetIsoformStatementPosition)1