use of org.nextprot.api.core.domain.annotation.AnnotationEvidence in project nextprot-api by calipho-sib.
the class DbXrefServiceIntegrationTest method shouldReturn_1_ReactomeXrefAsAnnotation.
/*
* This query finds entries having a single xref among 'Orphanet', 'KEGGPathway' , 'Reactome' and 'DrugBank'
* It is convenient for tests: we know we get a single annotation from xrefs for a given entry
* Example:
* NX_A0AVF1 for Reactome
* NX_A1L167 for Kegg
* NX_A0PJY2 for Orphanet
* NX_Q9Y2D1 for DrugBank
select a.unique_name, string_agg(a.acs, ',') as acs, string_agg(a.cv_name, ',') as dbs, count(*) as dbcount, sum(a.cnt) as xrcount from (
select si.unique_name, db.cv_name, count(*) as cnt, string_agg(x.accession, ',') as acs
from sequence_identifiers si
inner join identifier_resource_assoc ira on (si.identifier_id=ira.identifier_id)
inner join db_xrefs x on (ira.resource_id=x.resource_id)
inner join cv_databases db on (x.cv_database_id=db.cv_id)
where si.cv_type_id=1 and si.cv_status_id=1
and db.cv_name in ('Orphanet', 'DrugBank','KEGGPathway','Reactome')
group by si.unique_name, db.cv_name
) a
group by a.unique_name
having sum(a.cnt)=1
;
*/
@Test
public void shouldReturn_1_ReactomeXrefAsAnnotation() {
List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_A0AVF1");
assertTrue(annotations.size() == 1);
Annotation annot = annotations.get(0);
assertTrue(annot.getCategory().equals(AnnotationCategory.PATHWAY.getDbAnnotationTypeName()));
assertTrue(annot.getAPICategory() == AnnotationCategory.PATHWAY);
assertTrue(annot.getQualityQualifier().equals("GOLD"));
Assert.assertEquals("Intraflagellar transport", annot.getDescription());
for (AnnotationIsoformSpecificity spec : annot.getTargetingIsoformsMap().values()) {
assertTrue(spec.getSpecificity().equals("UNKNOWN"));
}
assertTrue(annot.getEvidences().size() == 1);
AnnotationEvidence evi = annot.getEvidences().get(0);
assertTrue(evi.getAssignedBy().equals("Reactome"));
assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
assertTrue(evi.getResourceAccession().equals("R-HSA-5620924"));
assertTrue(evi.getResourceDb().equals("Reactome"));
Assert.assertTrue(annotations.get(0).getProperties().isEmpty());
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidence 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());
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidence 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);
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidence in project nextprot-api by calipho-sib.
the class AnnotationTest method testTwoNegative.
@Test
public void testTwoNegative() {
Annotation a = new Annotation();
List<AnnotationEvidence> evidences = new ArrayList<>();
evidences.add(buildEvidence("negative"));
evidences.add(buildEvidence("negative"));
a.setEvidences(evidences);
Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
Assert.assertTrue(!a.isExpressionLevelDetected().get());
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidence in project nextprot-api by calipho-sib.
the class AnnotationTest method testOneNegative.
@Test
public void testOneNegative() {
Annotation a = new Annotation();
List<AnnotationEvidence> evidences = new ArrayList<>();
evidences.add(buildEvidence("negative"));
a.setEvidences(evidences);
Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
Assert.assertTrue(!a.isExpressionLevelDetected().get());
}
Aggregations