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