Search in sources :

Example 1 with AnnotationEvidence

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

the class AnnotationUtils method convertRelativeEvidenceToProperty.

private static List<AnnotationEvidence> convertRelativeEvidenceToProperty(Annotation annot, String propertyName) {
    List<AnnotationEvidence> toRemove = new ArrayList<>();
    for (AnnotationEvidence evi : annot.getEvidences()) {
        if ("relative".equals(evi.getResourceAssociationType())) {
            AnnotationProperty p = new AnnotationProperty();
            p.setAnnotationId(annot.getAnnotationId());
            p.setAccession(evi.getResourceAccession());
            p.setName(propertyName);
            p.setValue(Long.toString(evi.getResourceId()));
            p.setValueType(PropertyApiModel.VALUE_TYPE_RIF);
            annot.addProperties(Arrays.asList(p));
            toRemove.add(evi);
        }
    }
    return toRemove;
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty)

Example 2 with AnnotationEvidence

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

the class AnnotationUtils method toString.

public static String toString(Annotation a) {
    StringBuilder sb = new StringBuilder();
    String sep = "\n";
    sb.append("isProteoformAnnotation      :").append(a.isProteoformAnnotation()).append(sep);
    sb.append("getAnnotationHash           :").append(a.getAnnotationHash()).append(sep);
    sb.append("getAnnotationId             :").append(a.getAnnotationId()).append(sep);
    // sb.append("getAnnotationName           :").append(a.getAnnotationName()).append(sep);
    sb.append("getUniqueName               :").append(a.getUniqueName()).append(sep);
    // sb.append("getSubjectName              :").append(a.getSubjectName()).append(sep);
    sb.append("getDescription              :").append(a.getDescription()).append(sep);
    sb.append("getBioObject                :").append(a.getBioObject() == null ? "null" : a.getBioObject()).append(sep);
    sb.append("getSubjectComponents size   :").append(a.getSubjectComponents() == null ? 0 : a.getSubjectComponents().size()).append(sep);
    if (a.getSubjectComponents() != null) {
        for (String c : a.getSubjectComponents()) sb.append("- component                 :").append(c).append(sep);
    }
    sb.append("getApiTypeName              :").append(a.getApiTypeName()).append(sep);
    sb.append("getCategory                 :").append(a.getCategory()).append(sep);
    sb.append("getCategoryName             :").append(a.getCategoryName()).append(sep);
    sb.append("getCvTermAccessionCode      :").append(a.getCvTermAccessionCode()).append(sep);
    sb.append("getCvTermName               :").append(a.getCvTermName()).append(sep);
    sb.append("getEvidences.size           :").append(a.getEvidences() == null ? 0 : a.getEvidences().size()).append(sep);
    if (a.getEvidences() != null) {
        for (AnnotationEvidence ae : a.getEvidences()) sb.append("- evidence                 :").append(ae.getEvidenceId()).append(sep);
    }
    sb.append("getTargetingIsoformsMap size:").append(a.getTargetingIsoformsMap() == null ? 0 : a.getTargetingIsoformsMap().size()).append(sep);
    // sb.append("").append(a.).append(sep);
    return sb.toString();
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence)

Example 3 with AnnotationEvidence

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

the class AnnotationUtilsTest method shouldTurnDiseaseRelativeEvidenceIntoAlternativeDiseaseTermProperty.

@Test
public void shouldTurnDiseaseRelativeEvidenceIntoAlternativeDiseaseTermProperty() {
    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<AnnotationEvidence>();
    evidences.add(ev2);
    evidences.add(ev3);
    // create an annotation
    Annotation annot = new Annotation();
    annot.setAnnotationId(annotId);
    annot.setUniqueName("some_disease_annotation");
    annot.setCategory(AnnotationCategory.DISEASE.getDbAnnotationTypeName());
    annot.setQualityQualifier("GOLD");
    annot.setEvidences(evidences);
    // will be modified by convertType2EvidencesToProperties()
    annot.setDescription("");
    List<Annotation> annotations = new ArrayList<Annotation>();
    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_ALTERNATIVE_DISEASE_TERM, 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 4 with AnnotationEvidence

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

the class DbXrefServiceIntegrationTest method shouldReturn_1_KEGGPathwayXrefAsAnnotation.

@Test
public void shouldReturn_1_KEGGPathwayXrefAsAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_A1L167");
    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("Ubiquitin mediated proteolysis", 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("KEGG_PTW"));
    assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
    assertTrue(evi.getResourceAccession().equals("hsa04120+134111"));
    assertTrue(evi.getResourceDb().equals("KEGGPathway"));
    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 5 with AnnotationEvidence

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

the class DbXrefServiceIntegrationTest method shouldReturn_1_DrugBankXrefAsAnnotation.

@Test
public void shouldReturn_1_DrugBankXrefAsAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_Q9Y2D1");
    assertTrue(annotations.size() == 1);
    Annotation annot = annotations.get(0);
    assertTrue(annot.getCategory().equals(AnnotationCategory.SMALL_MOLECULE_INTERACTION.getDbAnnotationTypeName()));
    assertTrue(annot.getAPICategory() == AnnotationCategory.SMALL_MOLECULE_INTERACTION);
    assertTrue(annot.getQualityQualifier().equals("GOLD"));
    Assert.assertEquals("Pseudoephedrine", 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("DrugBank"));
    assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
    assertTrue(evi.getResourceAccession().equals("DB00852"));
    assertTrue(evi.getResourceDb().equals("DrugBank"));
    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)

Aggregations

AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)39 Annotation (org.nextprot.api.core.domain.annotation.Annotation)28 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)16 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)11 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)7 CvTerm (org.nextprot.api.core.domain.CvTerm)6 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)5 Collectors (java.util.stream.Collectors)4 BioObject (org.nextprot.api.core.domain.BioObject)4 java.util (java.util)3 List (java.util.List)3 NextProtException (org.nextprot.api.commons.exception.NextProtException)3 DbXref (org.nextprot.api.core.domain.DbXref)3 AnnotationEvidenceProperty (org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty)3 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)3 Supplier (com.google.common.base.Supplier)2 Logger (org.apache.log4j.Logger)2 IdentifierOffset (org.nextprot.api.commons.constants.IdentifierOffset)2 StringUtils (org.nextprot.api.commons.utils.StringUtils)2