Search in sources :

Example 1 with Interaction

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

the class InteractionServiceImpl method findInteractionsAsAnnotationsByEntry.

@Override
@Cacheable("interactions-as-annot")
public List<Annotation> findInteractionsAsAnnotationsByEntry(String entryName) {
    List<Annotation> annots = new ArrayList<>();
    List<Isoform> isoforms = this.isoService.findIsoformsByEntryName(entryName);
    List<Interaction> interactions = this.interactionDAO.findInteractionsByEntry(entryName);
    for (Interaction inter : interactions) {
        Annotation annot = BinaryInteraction2Annotation.transform(inter, entryName, isoforms, mainNamesService);
        annots.add(annot);
    }
    // returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
    return new ImmutableList.Builder<Annotation>().addAll(annots).build();
}
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) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with Interaction

use of org.nextprot.api.core.domain.Interaction 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 3 with Interaction

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

the class InteractionFieldBuilder method init.

@Override
protected void init(Entry entry) {
    // WAIT FOR BIO OBJECTS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // String id = entry.getUniqueName();
    String recName = "";
    String interactantAC = "";
    List<Interaction> interactions = entry.getInteractions();
    // System.err.println(interactions.size() + " interactions");
    for (Interaction currinteraction : interactions) {
        // System.err.println(currinteraction.getEvidenceXrefAC()); // EBI-372273,EBI-603319
        List<Interactant> interactants = currinteraction.getInteractants();
        for (Interactant currinteractant : interactants) {
            if (currinteractant.getGenename() != null) {
                // otherwise it is the entry itself
                interactantAC = currinteractant.getAccession();
                if (currinteractant.isNextprot()) {
                    interactantAC = "NX_" + interactantAC.split("-")[0];
                    // We need the entryBuilderService to get interactant's recname
                    recName = entryBuilderService.build(EntryConfig.newConfig(interactantAC).withOverview()).getOverview().getMainProteinName();
                } else
                    // Xeno interaction
                    recName = "";
                if (!this.isGold() || currinteraction.getQuality().equals("GOLD"))
                    addField(Fields.INTERACTIONS, "AC: " + interactantAC + " gene: " + currinteractant.getGenename() + " name: " + recName + " refs: " + currinteraction.getEvidenceXrefAC());
            } else if (currinteraction.isSelfInteraction() == true)
                if (!this.isGold() || currinteraction.getQuality().equals("GOLD"))
                    addField(Fields.INTERACTIONS, "selfInteraction");
        }
    }
    List<Annotation> annots = entry.getAnnotations();
    for (Annotation currannot : annots) if (// Always GOLD
    currannot.getCategory().equals("subunit"))
        addField(Fields.INTERACTIONS, currannot.getDescription());
/*
		//Gets interactions using xrefs
		List<DbXref> xrefs = entry.getXrefs();
		for (DbXref xref : xrefs) {
			String acc = xref.getAccession();
			String db = xref.getDatabaseName();

			// wrong for nextprot gene designation -> protein name
			if ((db.equals("UniProt") || db.equals("neXtProt")) && !id.contains(acc)) {
				String gen = xref.getPropertyValue("gene designation");
				if (gen != null && gen != "-") {
					gen = gen.toUpperCase();
					addField(Fields.INTERACTIONS, gen);
				}
			}
		}
		
		//WAIT FOR BIO OBJECTS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		
		}*/
}
Also used : Interactant(org.nextprot.api.core.domain.Interactant) Interaction(org.nextprot.api.core.domain.Interaction) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

Interaction (org.nextprot.api.core.domain.Interaction)3 Annotation (org.nextprot.api.core.domain.annotation.Annotation)3 ArrayList (java.util.ArrayList)2 Isoform (org.nextprot.api.core.domain.Isoform)2 BinaryInteraction2Annotation (org.nextprot.api.core.utils.BinaryInteraction2Annotation)2 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 BioObject (org.nextprot.api.core.domain.BioObject)1 Interactant (org.nextprot.api.core.domain.Interactant)1 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)1 Cacheable (org.springframework.cache.annotation.Cacheable)1