Search in sources :

Example 81 with Annotation

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

the class DbXrefServiceIntegrationTest method shouldFindTransportActivityAnnotation.

@Test
public void shouldFindTransportActivityAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_Q86VW1").stream().filter(a -> a.getAPICategory() == AnnotationCategory.TRANSPORT_ACTIVITY).collect(Collectors.toList());
    Assert.assertEquals(1, annotations.size());
    Annotation annotation = annotations.get(0);
    Assert.assertEquals("AN_Q86VW1_XR_6580312", annotation.getUniqueName());
    Assert.assertEquals("the major facilitator superfamily (mfs)", annotation.getDescription());
    List<AnnotationEvidence> evidences = annotation.getEvidences().stream().filter(e -> e.getResourceDb().equals("TCDB")).collect(Collectors.toList());
    // Assert Evidence
    Assert.assertEquals(1, evidences.size());
    AnnotationEvidence evidence = evidences.get(0);
    Assert.assertEquals("database", evidence.getResourceType());
    Assert.assertEquals("2.A.1.19.12", evidence.getResourceAccession());
    Assert.assertEquals("ECO:0000305", evidence.getEvidenceCodeAC());
    Assert.assertEquals(QualityQualifier.GOLD.toString(), evidence.getQualityQualifier());
    // Assert Xref
    Assert.assertNotNull(annotation.getParentXref());
    Assert.assertEquals("2.A.1.19.12", annotation.getParentXref().getAccession());
    Assert.assertEquals("TCDB", annotation.getParentXref().getDatabaseName());
    Assert.assertNotNull(annotation.getParentXref().getProperties());
    List<DbXref.DbXrefProperty> props = annotation.getParentXref().getProperties().stream().filter(p -> p.getName().equals("family name")).collect(Collectors.toList());
    Assert.assertEquals(1, props.size());
    Assert.assertEquals("the major facilitator superfamily (mfs)", props.get(0).getValue());
}
Also used : CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) DbXref(org.nextprot.api.core.domain.DbXref) Annotation(org.nextprot.api.core.domain.annotation.Annotation) QualityQualifier(org.nextprot.commons.constants.QualityQualifier) Autowired(org.springframework.beans.factory.annotation.Autowired) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ActiveProfiles(org.springframework.test.context.ActiveProfiles) Collectors(java.util.stream.Collectors) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) List(java.util.List) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) Assert(org.junit.Assert) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 82 with Annotation

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

the class EntryAnnotationBuilderTest method shouldReturnCorrectEcoName.

@Test
public void shouldReturnCorrectEcoName() {
    Statement sb1 = StatementBuilder.createNew().addCompulsaryFields("NX_P01308", "NX_P01308-1", "go-cellular-component", QualityQualifier.GOLD).addField(StatementField.EVIDENCE_CODE, "ECO:00001").addField(StatementField.REFERENCE_DATABASE, "PubMed").addField(StatementField.REFERENCE_ACCESSION, "123").addTargetIsoformsField(new TargetIsoformSet()).buildWithAnnotationHash(AnnotationType.ENTRY);
    List<Statement> statements = Arrays.asList(sb1);
    Annotation annotation = newAnnotationBuilder().buildAnnotation("NX_P01308-1", statements);
    Assert.assertEquals(annotation.getAPICategory(), AnnotationCategory.GO_CELLULAR_COMPONENT);
    Assert.assertEquals(annotation.getEvidences().size(), 1);
    Assert.assertEquals("eco-name-1", annotation.getEvidences().get(0).getEvidenceCodeName());
}
Also used : Statement(org.nextprot.commons.statements.Statement) TargetIsoformSet(org.nextprot.commons.statements.TargetIsoformSet) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 83 with Annotation

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

the class InteractionServiceIntegrationTest method shouldDealWithAnyInteractionSpecialInteraction.

/*
 * This queries retrieves entries with their 
 * - count of xeno interactions
 * - count of self interactions
 * - count of interactions with another protein entry defined in nextprot
 * - count of interactions whih another protein isoform defined in nextprot
 * - count of isoform specific interactions 
 * 
 *  and can be used to find test examples
 *  
select entry_ac, sum(is_iso_spec) as iso_spec_interactions, sum(has_xeno) as with_xeno, sum(has_self) as with_self, sum(has_iso) as with_isos, 
sum(has_entry) as entries, sum(has_xeno)+ sum(has_self)+ sum(has_iso)+ sum(has_entry) as interaction_count from (
select xr1.accession, 
(regexp_split_to_array(xr1.accession,'-'))[1]  as entry_ac,
case when xr1.accession like '%-%' then 1 else 0 end as is_iso_spec,
case when inter.is_xeno then 1 else 0 end as has_xeno,
case when interactant1.is_self_interaction then 1 else 0 end as has_self,
case when inter.is_xeno is false and interactant1.is_self_interaction is false and xr2.accession ilike '%-%' then 1 else 0 end as has_iso,
case when inter.is_xeno is false and interactant1.is_self_interaction is false and xr2.accession not ilike '%-%' then 1 else 0 end as has_entry
from partnerships inter 
inner join partnership_partner_assoc interactant1 on (inter.partnership_id=interactant1.partnership_id)
inner join db_xrefs xr1 on (interactant1.db_xref_id=xr1.resource_id)
left outer join partnership_partner_assoc interactant2 on (inter.partnership_id=interactant2.partnership_id and interactant1.assoc_id != interactant2.assoc_id or interactant2.assoc_id is null)
left outer join db_xrefs xr2 on (interactant2.db_xref_id=xr2.resource_id)
) a 
group by entry_ac
having sum(has_xeno)>0 and sum(has_self)>0 and sum(has_iso)>0 and sum(has_entry)>0
order by sum(has_xeno)+ sum(has_self)+ sum(has_iso)+ sum(has_entry) 
*/
/*
	 * NX_Q9UNQ0 should contain at least 1 interactions of each type:
	 * - self interaction 
	 * - xeno interaction (interaction with a protein not defined in nextprot, see resourceinternalrefs
	 * - interaction with another nextprot entry
	 * - interaction with another nextprot specific isoform
	 * and there should at least 1 interaction declared as isoform specific
	 * 
	 * see query above to find other examples if necessary in future releases
	 * 
	 */
@Test
public void shouldDealWithAnyInteractionSpecialInteraction() {
    String entry_ac = "NX_Q9UNQ0";
    List<Annotation> annots = this.interactionService.findInteractionsAsAnnotationsByEntry(entry_ac);
    int numberOfExperiments = 0;
    int withNxEntries = 0;
    int withNxIsos = 0;
    int withSelf = 0;
    int withXrefs = 0;
    int isoSpecs = 0;
    for (Annotation annot : annots) {
        /*
			System.out.println("partner " + annot.getBioObject().getAccession() +
					" " + annot.getBioObject().getBioType() + " / " + annot.getBioObject().getResourceType());
			*/
        // basic checks
        assertTrue(annot.getCategory().equals("BinaryInteraction"));
        assertTrue(annot.getAPICategory() == AnnotationCategory.BINARY_INTERACTION);
        // partners
        if (isAnnotationASelfInteraction(annot, entry_ac))
            withSelf++;
        if (isAnnotationAnInteractionWithAnExternalXrefAsPartner(annot))
            withXrefs++;
        if (isAnnotationAnInteractionWithaNextprotEntryAsPartner(annot, entry_ac))
            withNxEntries++;
        if (isAnnotationAnInteractionWithANextprotIsoformAsPartner(annot))
            withNxIsos++;
        // specificity of annotation subject
        if (isAnnotationAnInteractionWithANextprotIsoformAsSubject(annot))
            isoSpecs++;
        // evidences
        assertTrue(annot.getEvidences().size() == 1);
        AnnotationEvidence evi = annot.getEvidences().get(0);
        assertTrue(evi.getQualityQualifier().equals("GOLD") || evi.getQualityQualifier().equals("SILVER"));
        assertTrue(evi.getResourceDb().equals("IntAct"));
        if (annot.getEvidences().get(0).getPropertyValue("numberOfExperiments") != null)
            numberOfExperiments++;
    }
    /*
		System.out.println("numberOfExperiments:" + numberOfExperiments);
		System.out.println("withNxEntries:" + withNxEntries);
		System.out.println("withNxIsos:" + withNxIsos);
		System.out.println("withSelf:" + withSelf );
		System.out.println("withXrefs:" + withXrefs );
		System.out.println("isoSpecs:" + isoSpecs );
		*/
    // should exist for each interaction
    assertTrue(numberOfExperiments == annots.size());
    // 8 cases
    assertTrue(withNxEntries >= 1);
    // 1 case
    assertTrue(withNxIsos >= 1);
    // 10 cases
    assertTrue(withXrefs >= 1);
    // 1 case
    assertTrue(withSelf == 1);
    // 16 cases
    assertTrue(isoSpecs > 1);
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) BinaryInteraction2Annotation(org.nextprot.api.core.utils.BinaryInteraction2Annotation) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 84 with Annotation

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

the class AnnotationUtilsUnconfirmedPE1Test method test11.

// @Autowired private EntryBuilderService entryBuilderService = null;
@Test
public void test11() {
    ArrayList<Annotation> list = new ArrayList<>();
    // OK - non overlapping peptides both just long enough
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 18, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 38, true));
    Assert.assertEquals(true, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - non overlapping peptides 1st not long enough
    list.clear();
    // size = 8
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 17, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 38, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - non overlapping peptides, 2nd not long enough
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 18, true));
    // size = 8
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 37, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // OK - non overlapping peptides, both just long enough plus one inclding others
    list.clear();
    list.add(createPeptideMappingAnnot(3, "PEP_INCL", 10, 38, true));
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 18, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 38, true));
    Assert.assertEquals(true, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // OK - non overlapping peptides, both just long enough plus one inclding others, in another order
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 18, true));
    list.add(createPeptideMappingAnnot(3, "PEP_INCL", 10, 38, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 38, true));
    Assert.assertEquals(true, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // OK - non overlapping peptides, both just long enough plus one inclding others, in another order
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 10, 18, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 30, 38, true));
    list.add(createPeptideMappingAnnot(3, "PEP_INCL", 10, 38, true));
    Assert.assertEquals(true, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // OK - overlapping peptides long enough and coverage just enough
    list.clear();
    // size = 11
    list.add(createPeptideMappingAnnot(1, "PEP_1", 11, 21, true));
    // size = 19, coverage = 18
    list.add(createPeptideMappingAnnot(2, "PEP_2", 20, 28, true));
    Assert.assertEquals(true, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - overlapping peptides long enough but coverage too small
    list.clear();
    // size = 11
    list.add(createPeptideMappingAnnot(1, "PEP_1", 12, 22, true));
    // size = 19, coverage = 17
    list.add(createPeptideMappingAnnot(2, "PEP_2", 20, 28, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - peptides including each other
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_INCLUDING", 10, 40, true));
    list.add(createPeptideMappingAnnot(2, "PEP_MIDDLE", 12, 30, true));
    list.add(createPeptideMappingAnnot(3, "PEP_INCLUDED", 14, 20, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - same peptides but other id, exists ???
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 11, 20, true));
    list.add(createPeptideMappingAnnot(2, "PEP_2", 11, 20, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - non overlapping peptides but same peptide id
    list.clear();
    list.add(createPeptideMappingAnnot(1, "PEP_1", 11, 20, true));
    list.add(createPeptideMappingAnnot(2, "PEP_1", 31, 39, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - non overlapping peptides but 1 peptide without name
    list.clear();
    list.add(createPeptideMappingAnnot(1, null, 11, 20, true));
    list.add(createPeptideMappingAnnot(2, "PEP_1", 31, 39, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // OK - non overlapping peptides but no peptide name at all
    list.clear();
    list.add(createPeptideMappingAnnot(1, null, 11, 20, true));
    list.add(createPeptideMappingAnnot(2, null, 31, 39, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - ok but 1 annotation is not peptide  mapping annotation
    list.clear();
    list.add(createPeptideMappingAnnot(1, null, 11, 20, true));
    Annotation a2 = createPeptideMappingAnnot(2, null, 31, 39, true);
    a2.setAnnotationCategory(AnnotationCategory.PTM_INFO);
    list.add(a2);
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - ok but just 1 peptide
    list.clear();
    list.add(createPeptideMappingAnnot(1, null, 11, 20, true));
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
    // KO - no peptide
    list.clear();
    Assert.assertEquals(false, AnnotationUtils.containsAtLeast2NonInclusivePeptidesMinSize9Coverage18(list, true));
}
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)

Example 85 with Annotation

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

the class PeptideMappingServiceIntegrationTest method shouldComputeHTML4Highlight.

@Ignore
@Test
public void shouldComputeHTML4Highlight() throws FileNotFoundException {
    // List<String>entryNames = Arrays.asList(new String[]{"NX_Q8IYL9", "NX_Q66K66", "NX_P01308"});
    // List<String>entryNames = miService.findUniqueNamesOfChromosome("Y");
    // liste Monique
    List<String> entryNames = Arrays.asList(new String[] { "NX_Q6UWW9", "NX_Q04118", "NX_P48165", "NX_P01308", "NX_Q13557" });
    StringBuilder sb = new StringBuilder();
    sb.append("<html><body>\n");
    sb.append("<ul>");
    // sb.append("<span style=\"color:" + chunk.code  + "\">");
    sb.append("<li style=\"color:" + COLOR_NOT_COVERED + "\">" + COLOR_NOT_COVERED + ": no peptide</li>");
    sb.append("<li style=\"color:" + COLOR_PEP_COVERED + "\">" + COLOR_PEP_COVERED + ": peptide</li>");
    sb.append("<li style=\"color:" + COLOR_1_TYPIC_COVERED + "\">" + COLOR_1_TYPIC_COVERED + ": single proteotypic</li>");
    sb.append("<li style=\"color:" + COLOR_N_TYPIC_COVERED + "\">" + COLOR_N_TYPIC_COVERED + ": multiple proteotypic</li>");
    sb.append("</ul>");
    for (String entryName : entryNames) {
        List<Annotation> annotations = this.pmService.findNaturalPeptideMappingAnnotationsByMasterUniqueName(entryName);
        List<Isoform> isoforms = isoService.findIsoformsByEntryName(entryName);
        for (Isoform iso : isoforms) {
            String cpep = computeCoverage(iso, annotations, false, false);
            String ctyp = computeCoverage(iso, annotations, true, false);
            String html = getHighlightHTML(iso, annotations, cpep, ctyp);
            sb.append(html);
        }
    }
    sb.append("</body></html>\n");
    String filename = "./highlight-coverage-peptide-chromosome-y.html";
    PrintWriter out = new PrintWriter(filename);
    out.print(sb.toString());
    out.close();
    System.out.println("Wrote result in file " + filename);
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) PrintWriter(java.io.PrintWriter) Ignore(org.junit.Ignore) 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