Search in sources :

Example 1 with BioObject

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

the class BinaryInteraction2Annotation method newBioObject.

static BioObject newBioObject(Interactant interactant, MainNamesService mainNamesService) {
    BioObject.BioType bioType = (interactant.isIsoform()) ? BioObject.BioType.PROTEIN_ISOFORM : BioObject.BioType.PROTEIN;
    BioObject be = (interactant.isNextprot()) ? BioObject.internal(bioType) : BioObject.external(bioType, interactant.getDatabase());
    be.setId(interactant.getXrefId());
    be.setAccession((interactant.isNextprot()) ? interactant.getNextprotAccession() : interactant.getAccession());
    if (interactant.getGenename() != null)
        be.getProperties().put("geneName", interactant.getGenename());
    if (interactant.isNextprot()) {
        String ac = interactant.getNextprotAccession();
        String masterAc = mainNamesService.findIsoformOrEntryMainName().get(ac).getEntryAccession();
        String proteinName = mainNamesService.findIsoformOrEntryMainName().get(masterAc).getName();
        be.getProperties().put("proteinName", proteinName);
        if (interactant.isIsoform()) {
            String isoName = mainNamesService.findIsoformOrEntryMainName().get(ac).getName();
            be.getProperties().put("isoformName", isoName);
        }
    }
    if (interactant.getUrl() != null)
        be.getProperties().put("url", interactant.getUrl());
    return be;
}
Also used : BioObject(org.nextprot.api.core.domain.BioObject)

Example 2 with BioObject

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

the class AnnotationUpdater method updateDestBioObject.

@Override
protected void updateDestBioObject(Annotation dest, Annotation source) {
    BioObject destBioObject = dest.getBioObject();
    BioObject srcBioObject = source.getBioObject();
    if (srcBioObject != null && srcBioObject.getProperties() != null) {
        updateDestBioObjectProperties(destBioObject, srcBioObject.getProperties());
    }
}
Also used : BioObject(org.nextprot.api.core.domain.BioObject)

Example 3 with BioObject

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

the class InteractionServiceIntegrationTest method shouldWork.

@Ignore
@Test
public void shouldWork() {
    String entryName = "NX_P38398";
    List<Annotation> annots = new ArrayList<>();
    List<Isoform> isoforms = this.isoformService.findIsoformsByEntryName(entryName);
    List<Interaction> interactions = this.interactionService.findInteractionsByEntry(entryName);
    System.out.println("Interaction count:" + interactions.size());
    for (Interaction inter : interactions) {
        Annotation annot = BinaryInteraction2Annotation.transform(inter, entryName, isoforms, mainNamesService);
        annots.add(annot);
        BioObject bo = annot.getBioObject();
        if (bo != null && (bo.getAccession().equals("NX_Q92560") || bo.getAccession().equals("Q99PU7"))) {
            System.out.print(inter.getEvidenceXrefAC() + ": ");
            System.out.print(inter.getInteractants().get(0).getAccession());
            if (inter.getInteractants().size() == 2)
                System.out.print(" <==> " + inter.getInteractants().get(1));
            System.out.println("");
            System.out.println(bo);
        }
    }
    System.out.println("Annot count:" + annots.size());
}
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) BioObject(org.nextprot.api.core.domain.BioObject) Ignore(org.junit.Ignore) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 4 with BioObject

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

the class ByAnnotationBioObjectComparatorTest method mockBioObject.

private static BioObject mockBioObject(BioObject.BioType bioType, BioObject.ResourceType resourceType, String hash) {
    BioObject bgo = Mockito.mock(BioObject.class);
    when(bgo.getBioType()).thenReturn(bioType);
    when(bgo.getResourceType()).thenReturn(resourceType);
    when(bgo.getAnnotationHash()).thenReturn(hash);
    return bgo;
}
Also used : BioObject(org.nextprot.api.core.domain.BioObject)

Example 5 with BioObject

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

the class AnnotationUtilsTest method testConvertEvidenceToExternalBioObject.

// ----------------------------------
@Test
public void testConvertEvidenceToExternalBioObject() {
    AnnotationEvidence ev = new AnnotationEvidence();
    ev.setResourceAccession("CHEBI:38290");
    ev.setResourceAssociationType("relative");
    ev.setResourceDb("ChEBI");
    ev.setResourceId(39334228);
    BioObject bo = AnnotationUtils.newExternalChemicalBioObject(ev);
    Assert.assertEquals("CHEBI:38290", bo.getAccession());
    Assert.assertEquals("ChEBI", bo.getDatabase());
    Assert.assertEquals(39334228, bo.getId());
    Assert.assertEquals(BioObject.BioType.CHEMICAL, bo.getBioType());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) BioObject(org.nextprot.api.core.domain.BioObject) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Aggregations

BioObject (org.nextprot.api.core.domain.BioObject)10 Annotation (org.nextprot.api.core.domain.annotation.Annotation)5 Test (org.junit.Test)3 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)2 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)2 Supplier (com.google.common.base.Supplier)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 Ignore (org.junit.Ignore)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 IdentifierOffset (org.nextprot.api.commons.constants.IdentifierOffset)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 StringUtils (org.nextprot.api.commons.utils.StringUtils)1 BioType (org.nextprot.api.core.domain.BioObject.BioType)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 Interaction (org.nextprot.api.core.domain.Interaction)1 Isoform (org.nextprot.api.core.domain.Isoform)1 Publication (org.nextprot.api.core.domain.Publication)1