Search in sources :

Example 31 with Annotation

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

the class ObjectAnnotationSimilarityPredicateTest method shouldBeSimilar.

@Test
public void shouldBeSimilar() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Assert.assertTrue(predicate.isSimilar(mockAnnotation(AnnotationCategory.VARIANT), mockAnnotation(AnnotationCategory.VARIANT)));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 32 with Annotation

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

the class ObjectAnnotationSimilarityPredicateTest method sameObjectShouldBeSimilar.

@Test
public void sameObjectShouldBeSimilar() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Annotation annot = mockAnnotation(AnnotationCategory.VARIANT);
    Assert.assertTrue(predicate.isSimilar(annot, annot));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 33 with Annotation

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

the class ObjectAnnotationSimilarityPredicateTest method shouldBeDifferent.

@Test
public void shouldBeDifferent() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Assert.assertFalse(predicate.isSimilar(mockAnnotation(AnnotationCategory.VARIANT), mockAnnotation(AnnotationCategory.MUTAGENESIS)));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 34 with Annotation

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

the class RawStatementDaoTest method findModificationEffectCategory.

@Test
public void findModificationEffectCategory() {
    AnnotationCategory category = AnnotationCategory.PHENOTYPIC_VARIATION;
    Annotation isoAnnotation = new Annotation();
    isoAnnotation.setAnnotationCategory(category);
    assertEquals(isoAnnotation.getCategory(), "phenotypic-variation");
}
Also used : AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) Annotation(org.nextprot.api.core.domain.annotation.Annotation) AnnotationBuilderIntegrationBaseTest(org.nextprot.api.core.service.AnnotationBuilderIntegrationBaseTest) Test(org.junit.Test)

Example 35 with Annotation

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

the class IsoformSequencePositionMapperIntegrationTest method testSingleVariantPositionOnMaster.

@Test
public void testSingleVariantPositionOnMaster() throws Exception {
    // just to be aware of difference between db info and api info
    String entry_ac = "NX_P01308";
    String iso_ac = "NX_P01308-1";
    String variant_ac = "AN_P01308_001747";
    int expectedBeginPosOnMaster = 502;
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
    for (Annotation a : entry.getAnnotations()) {
        if (a.getUniqueName().equals(variant_ac)) {
            int pos = a.getTargetingIsoformsMap().get(iso_ac).getFirstPosition();
            Isoform iso = IsoformUtils.getIsoformByName(entry, iso_ac);
            GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(pos, iso);
            if (sout) {
                System.out.println("isoform position                                               : " + pos);
                System.out.println("nuPos is valid                                                 : " + nuPos.isValid());
                System.out.println("master position according to iso mapper service                : " + nuPos.getNucleotidePosition(0));
                System.out.println("master position according to table identifier_feature_position : " + expectedBeginPosOnMaster);
                System.out.println("master first_position for Anne                                 : " + (nuPos.getNucleotidePosition(0) - 1));
            }
            // we then have to gie the last_positon to Anne, there are 2 cases:
            // case 1: original AAs = single AA
            // => master last_positon fo Anne = first_position for Anne + 3
            // case 2: original AAs length has more than one AAs
            // compute position on master of last AA (same process as above), return nuPos(0)-1 found for iso pos)
            // we expect a difference of 1 between what we have in db and what we have from api
            Assert.assertEquals(new Integer(expectedBeginPosOnMaster + 1), new Integer(nuPos.getNucleotidePosition(0)));
            return;
        }
    }
    Assert.assertTrue(false);
/*
		 * SQL to get master position for this variant
		 * 
		select a.unique_name, a.cv_annotation_type_id, pfp.first_pos,pfp.last_pos,ifp.first_pos as master_frist_pos, ifp.last_pos as master_last_pos from sequence_identifiers si
		inner join annotations a on (a.identifier_id=si.identifier_id)
		inner join annotation_protein_assoc apa on (a.annotation_id=apa.annotation_id)
		inner join protein_feature_positions pfp on (apa.assoc_id=pfp.annotation_protein_id)
		inner join identifier_feature_positions ifp on (ifp.annotation_id=a.annotation_id)
		where si.unique_name='NX_P01308' 
		and pfp.first_pos=20;
		
		SQL result:
		unique_name	        cv_annotation_type_id	first_pos	last_pos	master_frist_pos	master_last_pos
        AN_P01308_001839    1027                    20          21          430                 433
		(1 row)
		
		 */
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

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