Search in sources :

Example 36 with Annotation

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

the class IsoformSequencePositionMapperIntegrationTest method testSingleVariantWithInvalidNucleotideIndice.

@Test
public void testSingleVariantWithInvalidNucleotideIndice() throws Exception {
    String entry_ac = "NX_O00115";
    String iso_ac = "NX_O00115-1";
    String variant_ac = "AN_O00115_000472";
    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);
            for (Isoform iso2 : entry.getIsoforms()) {
                if (!iso2.equals(iso)) {
                    CodonNucleotideIndices nuIdx = IsoformSequencePositionMapper.getCodonNucleotideIndices(nuPos, iso2);
                    // cannot be projected to iso2
                    Assert.assertEquals(false, nuIdx.has3Nucleotides());
                    Assert.assertEquals(false, nuIdx.areConsecutive());
                    Assert.assertEquals(false, nuIdx.areInFrame());
                    Assert.assertNull(nuIdx.getAminoAcidPosition());
                }
            }
            return;
        }
    }
    Assert.assertTrue(false);
}
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)

Example 37 with Annotation

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

the class DbXrefServiceImpl method convertXrefIntoAnnotation.

private Annotation convertXrefIntoAnnotation(DbXref xref, String entryName, List<Isoform> isoforms) {
    Preconditions.checkNotNull(xref.getProperties());
    Annotation annotation = new Annotation();
    annotation.setAnnotationId(xref.getDbXrefId() + IdentifierOffset.XREF_ANNOTATION_OFFSET);
    Xref2Annotation xam = Xref2Annotation.getByDatabaseName(xref.getDatabaseName());
    annotation.setCategory(xam.getAnnotCat());
    // copy of some xref property
    annotation.setDescription(xref.getPropertyValue(xam.getXrefPropName()));
    annotation.setQualityQualifier(xam.getQualityQualifier());
    annotation.setCvTermName(null);
    annotation.setCvTermAccessionCode(null);
    annotation.setSynonym(null);
    annotation.setUniqueName("AN_" + entryName.substring(3) + "_XR_" + String.valueOf(xref.getDbXrefId()));
    annotation.setParentXref(xref);
    annotation.setEvidences(Collections.singletonList(newAnnotationEvidence(annotation)));
    annotation.addTargetingIsoforms(newAnnotationIsoformSpecificityList(isoforms, annotation));
    return annotation;
}
Also used : Xref2Annotation(org.nextprot.api.commons.constants.Xref2Annotation) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Xref2Annotation(org.nextprot.api.commons.constants.Xref2Annotation)

Example 38 with Annotation

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

the class AntibodyResourceIdsServiceImpl method findAllAntibodyIdsByMasterId.

@Override
public List<Long> findAllAntibodyIdsByMasterId(String uniqueName) {
    Long masterId = masterIdentifierService.findIdByUniqueName(uniqueName);
    List<Annotation> annotations = antibodyMappingDao.findAntibodyMappingAnnotationsById(masterId);
    Set<Long> names = new HashSet<>();
    for (Annotation annotation : annotations) {
        for (AnnotationEvidence evidence : annotation.getEvidences()) {
            names.add(evidence.getResourceId());
        }
    }
    return new ImmutableList.Builder<Long>().addAll(new ArrayList<>(names)).build();
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation) HashSet(java.util.HashSet)

Example 39 with Annotation

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

the class AntibodyMappingDaoTest method testFindAntibodiesById.

@Test
public void testFindAntibodiesById() {
    List<Annotation> annotations = this.antibodyMappingDao.findAntibodyMappingAnnotationsById(636535L);
    Assert.assertEquals(2, annotations.size());
    long tmpId = 4049518L;
    long annotId = tmpId + IdentifierOffset.ANTIBODY_MAPPING_ANNOTATION_OFFSET;
    long evidenceId = tmpId + IdentifierOffset.ANTIBODY_MAPPING_ANNOTATION_EVIDENCE_OFFSET;
    // String annotUniqueName = "AN_"+resultSet.getString("resource_ac")+"_"+annotId; // AN_HPA039796_000890
    // old = AN_HPA036302_4049518"
    String annotUniqueName = "AN_HPA036302_" + annotId;
    Annotation annotation = getAnnotationByUniqueName(annotUniqueName, annotations);
    Assert.assertEquals(AnnotationCategory.ANTIBODY_MAPPING, annotation.getAPICategory());
    Assert.assertEquals(annotUniqueName, annotation.getUniqueName());
    Assert.assertEquals("GOLD", annotation.getQualityQualifier());
    Assert.assertEquals(annotId, annotation.getAnnotationId());
    Assert.assertEquals(1, annotation.getEvidences().size());
    Assert.assertEquals(annotId, annotation.getEvidences().get(0).getAnnotationId());
    Assert.assertEquals(17201575, annotation.getEvidences().get(0).getResourceId());
    Assert.assertEquals("database", annotation.getEvidences().get(0).getResourceType());
    Assert.assertEquals("Human protein atlas", annotation.getEvidences().get(0).getAssignedBy());
    Assert.assertEquals("HPA", annotation.getEvidences().get(0).getResourceDb());
    Assert.assertEquals("evidence", annotation.getEvidences().get(0).getResourceAssociationType());
    Assert.assertEquals("ECO:0000154", annotation.getEvidences().get(0).getEvidenceCodeAC());
    Assert.assertTrue(!annotation.getEvidences().get(0).isNegativeEvidence());
    Assert.assertEquals(2, annotation.getTargetingIsoformsMap().size());
    Assert.assertTrue(annotation.getTargetingIsoformsMap().containsKey("NX_P06213-1"));
    Assert.assertTrue(annotation.getTargetingIsoformsMap().containsKey("NX_P06213-2"));
    Assert.assertEquals(608, annotation.getTargetingIsoformsMap().get("NX_P06213-1").getFirstPosition().intValue());
    Assert.assertEquals(608, annotation.getTargetingIsoformsMap().get("NX_P06213-2").getFirstPosition().intValue());
    Assert.assertEquals(742, annotation.getTargetingIsoformsMap().get("NX_P06213-1").getLastPosition().intValue());
    Assert.assertEquals(742, annotation.getTargetingIsoformsMap().get("NX_P06213-2").getLastPosition().intValue());
    tmpId = 9547085;
    annotId = tmpId + IdentifierOffset.ANTIBODY_MAPPING_ANNOTATION_OFFSET;
    evidenceId = tmpId + IdentifierOffset.ANTIBODY_MAPPING_ANNOTATION_EVIDENCE_OFFSET;
    annotUniqueName = "AN_HPA036303_" + annotId;
    // old "AN_HPA036303_9547085"
    annotation = getAnnotationByUniqueName(annotUniqueName, annotations);
    Assert.assertEquals(AnnotationCategory.ANTIBODY_MAPPING, annotation.getAPICategory());
    Assert.assertEquals(annotUniqueName, annotation.getUniqueName());
    Assert.assertEquals("GOLD", annotation.getQualityQualifier());
    Assert.assertEquals(annotId, annotation.getAnnotationId());
    Assert.assertEquals(1, annotation.getEvidences().size());
    Assert.assertEquals(annotId, annotation.getEvidences().get(0).getAnnotationId());
    Assert.assertEquals(39235676, annotation.getEvidences().get(0).getResourceId());
    Assert.assertEquals("database", annotation.getEvidences().get(0).getResourceType());
    Assert.assertEquals("HPA", annotation.getEvidences().get(0).getResourceDb());
    Assert.assertEquals("Human protein atlas", annotation.getEvidences().get(0).getAssignedBy());
    Assert.assertEquals("evidence", annotation.getEvidences().get(0).getResourceAssociationType());
    Assert.assertEquals("ECO:0000154", annotation.getEvidences().get(0).getEvidenceCodeAC());
    Assert.assertTrue(!annotation.getEvidences().get(0).isNegativeEvidence());
    Assert.assertEquals(2, annotation.getTargetingIsoformsMap().size());
    Assert.assertTrue(annotation.getTargetingIsoformsMap().containsKey("NX_P06213-1"));
    Assert.assertTrue(annotation.getTargetingIsoformsMap().containsKey("NX_P06213-2"));
    Assert.assertEquals(246, annotation.getTargetingIsoformsMap().get("NX_P06213-1").getFirstPosition().intValue());
    Assert.assertEquals(246, annotation.getTargetingIsoformsMap().get("NX_P06213-2").getFirstPosition().intValue());
    Assert.assertEquals(326, annotation.getTargetingIsoformsMap().get("NX_P06213-1").getLastPosition().intValue());
    Assert.assertEquals(326, annotation.getTargetingIsoformsMap().get("NX_P06213-2").getLastPosition().intValue());
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 40 with Annotation

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

the class AnnotationDaoTest method shouldSplitTransitPeptideAnnotations.

@Test
public void shouldSplitTransitPeptideAnnotations() {
    List<Annotation> annotations = annotationDAO.findAnnotationsByEntryName("NX_Q6P4F2");
    List<String> list = new ArrayList<String>();
    for (Annotation an : annotations) list.add(an.getCategory());
    assertEquals(list.contains(AnnotationCategory.MITOCHONDRIAL_TRANSIT_PEPTIDE.getDbAnnotationTypeName()), true);
    assertEquals(list.contains(AnnotationCategory.PEROXISOME_TRANSIT_PEPTIDE.getDbAnnotationTypeName()), true);
    assertEquals(annotations.size(), 2);
}
Also used : ArrayList(java.util.ArrayList) 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