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