Search in sources :

Example 11 with Annotation

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

the class ByAnnotationSubjectComparatorTest method compareAnnotationsFirstDefinedSubjectComponent.

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

Example 12 with Annotation

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

the class ByAnnotationSubjectComparatorTest method compareAnnotationsCannotFindOneSubjectAnnot.

@Test(expected = NextProtException.class)
public void compareAnnotationsCannotFindOneSubjectAnnot() throws Exception {
    ByAnnotationSubjectComparator comparator = new ByAnnotationSubjectComparator(newHashMap(mockAnnotation(AnnotationCategory.VARIANT, "hash1")));
    Annotation a1 = new Annotation();
    a1.setSubjectComponents(Collections.singletonList("hash1"));
    Annotation a2 = new Annotation();
    a2.setSubjectComponents(Collections.singletonList("hash2"));
    int cmp = comparator.compare(a1, a2);
    Assert.assertEquals(0, cmp);
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 13 with Annotation

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

the class AnnotationUtilsUnconfirmedPE1Test method createPeptideMappingAnnot.

private Annotation createPeptideMappingAnnot(int id, String pepname, Integer p1, Integer p2, boolean proteotypic) {
    Annotation a = new Annotation();
    a.setAnnotationCategory(AnnotationCategory.PEPTIDE_MAPPING);
    a.setAnnotationId(id);
    AnnotationProperty p = new AnnotationProperty();
    p.setName("is proteotypic");
    p.setValue(proteotypic ? "Y" : "N");
    a.addProperty(p);
    if (pepname != null) {
        p = new AnnotationProperty();
        p.setName("peptide name");
        p.setValue(pepname);
        a.addProperty(p);
    }
    AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
    spec1.setIsoformAccession("NX_P10000-1");
    spec1.setFirstPosition(p1);
    spec1.setLastPosition(p2);
    AnnotationIsoformSpecificity spec2 = new AnnotationIsoformSpecificity();
    spec2.setIsoformAccession("NX_P10000-2");
    spec2.setFirstPosition(p1 == null ? null : p1 + 10);
    spec2.setLastPosition(p2 == null ? null : p2 + 10);
    List<AnnotationIsoformSpecificity> specs = new ArrayList<>();
    specs.add(spec1);
    specs.add(spec2);
    a.addTargetingIsoforms(specs);
    return a;
}
Also used : AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) ArrayList(java.util.ArrayList) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 14 with Annotation

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

the class InteractionServiceImpl method findInteractionsAsAnnotationsByEntry.

@Override
@Cacheable("interactions-as-annot")
public List<Annotation> findInteractionsAsAnnotationsByEntry(String entryName) {
    List<Annotation> annots = new ArrayList<>();
    List<Isoform> isoforms = this.isoService.findIsoformsByEntryName(entryName);
    List<Interaction> interactions = this.interactionDAO.findInteractionsByEntry(entryName);
    for (Interaction inter : interactions) {
        Annotation annot = BinaryInteraction2Annotation.transform(inter, entryName, isoforms, mainNamesService);
        annots.add(annot);
    }
    // returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
    return new ImmutableList.Builder<Annotation>().addAll(annots).build();
}
Also used : Interaction(org.nextprot.api.core.domain.Interaction) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform) BinaryInteraction2Annotation(org.nextprot.api.core.utils.BinaryInteraction2Annotation) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 15 with Annotation

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

the class AnnotationBaseMerger method merge.

@Override
public Annotation merge(Annotation annotation1, Annotation annotation2) {
    Annotation dest = getDestAnnotation(annotation1, annotation2);
    Annotation source = getSourceAnnotation(annotation1, annotation2);
    updateDestEvidences(dest, source);
    updateDestAnnotationHash(dest, source);
    updateDestIsoformSpecificityName(dest, source);
    updateDestQualityQualifier(dest, source);
    updateDestBioObject(dest, source);
    return dest;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

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