public GeneratedEntry addInteractor(Interactor interactor) { if (interactor == null) throw new NullPointerException("interactor"); for (Component component : interactor.getActiveInstances()) { addInteraction(component.getInteraction()); } return this; }
public GeneratedEntry addInteractor(Interactor interactor) { if (interactor == null) throw new NullPointerException("interactor"); for (Component component : interactor.getActiveInstances()) { addInteraction(component.getInteraction()); } return this; }
public GeneratedEntry addInteractor(Interactor interactor) { if (interactor == null) throw new NullPointerException("interactor"); for (Component component : interactor.getActiveInstances()) { addInteraction(component.getInteraction()); } return this; }
/** * Equality for Components is currently based on <b>object identity</b> (i.e. the references point to the same * objects) for Interactors, Interactions and CvComponentRoles. * * @param o The object to check * * @return true if the parameter equals this object, false otherwise */ @Override public boolean equals( Object o ) { /* TODO: Take features into account when they are implemented. */ if ( this == o ) { return true; } if ( !( o instanceof Component ) ) { return false; } // don't call super because that's a BasicObject ! final Component component = ( Component ) o; // Compare if the component links the same objects. // This comparision can be based on reference equality, // so "==" can be used instead of "equals". return this.interactor == component.getInteractor() && this.interaction == component.getInteraction() && this.experimentalRole == component.experimentalRole && this.biologicalRole == component.biologicalRole; }
/** * Get all interaction related to the given Protein. * * @param protein the protein of which we want the interactions. * * @return a Collection if Interaction. */ protected final List<Interaction> getInteractions(final Protein protein) { Collection<Component> components = protein.getActiveInstances(); int componentsSize = components.size(); List<Interaction> interactions = new ArrayList<Interaction>(componentsSize); out.println("Found " + componentsSize + " components for protein " + protein.getShortLabel() + ". Starting to get the interactions from those components."); for (Component component : components) { Interaction interaction = component.getInteraction(); if (!interactions.contains(interaction)) { interactions.add(interaction); } } return interactions; // return IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getInteractionDao().getInteractionsByInteractorAc(protein.getAc()); }
/** * Get all interaction related to the given Protein. * * @param protein the protein of which we want the interactions. * * @return a Collection if Interaction. */ protected final List<Interaction> getInteractions(final Protein protein) { Collection<Component> components = protein.getActiveInstances(); int componentsSize = components.size(); List<Interaction> interactions = new ArrayList<Interaction>(componentsSize); out.println("Found " + componentsSize + " components for protein " + protein.getShortLabel() + ". Starting to get the interactions from those components."); for (Component component : components) { Interaction interaction = component.getInteraction(); if (!interactions.contains(interaction)) { interactions.add(interaction); } } return interactions; // return IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getInteractionDao().getInteractionsByInteractorAc(protein.getAc()); }
protected Key keyForComponent(Component component) { final String cacheKey = Component.class.getSimpleName() + ":" + System.identityHashCode(component); Key interactionKey = null; if (!keyCache.containsKey(cacheKey)) { if (component.getInteraction() == null) { throw new IllegalArgumentException("Cannot generate a key for a component without interaction: " + component); } interactionKey = keyForInteraction(component.getInteraction()); } if (keyCache.containsKey(cacheKey)) { return keyCache.get(cacheKey); } if (interactionKey != null) { Key compKey = new Key(interactionKey.getUniqueString() + ":" + component.getShortLabel() + "[" + component.hashCode() + "]"); keyCache.put(cacheKey, compKey); return compKey; } throw new IllegalStateException("This component should already have already a key, generated when the interaction key is generated: " + component); }
protected Key keyForComponent(Component component) { final String cacheKey = Component.class.getSimpleName() + ":" + System.identityHashCode(component); Key interactionKey = null; if (!keyCache.containsKey(cacheKey)) { if (component.getInteraction() == null) { throw new IllegalArgumentException("Cannot generate a key for a component without interaction: " + component); } interactionKey = keyForInteraction(component.getInteraction()); } if (keyCache.containsKey(cacheKey)) { return keyCache.get(cacheKey); } if (interactionKey != null) { Key compKey = new Key(interactionKey.getUniqueString() + ":" + component.getShortLabel() + "[" + component.hashCode() + "]"); keyCache.put(cacheKey, compKey); return compKey; } throw new IllegalStateException("This component should already have already a key, generated when the interaction key is generated: " + component); }
@PrePersist @PreUpdate protected void correctCategory() { if (this.component != null){ if (this.component.getInteraction() != null){ if (Hibernate.isInitialized(this.component.getInteraction().getAnnotations())){ if (ComplexUtils.isComplex(this.component.getInteraction())){ this.category = "modelled"; } else { this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } }
@PrePersist @PreUpdate protected void correctCategory() { if (this.component != null){ if (this.component.getInteraction() != null){ if (Hibernate.isInitialized(this.component.getInteraction().getAnnotations())){ if (ComplexUtils.isComplex(this.component.getInteraction())){ this.category = "modelled"; } else { this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } } else if (this.category == null){ this.category = "evidence"; } }
session.addMessage( "NOTE: CvExperimentalRole( '" + expRole + "' ) has been renamed '" + role + "'." + "(Component: " + component.getAc() + " - " + "Interaction: " + component.getInteraction().getAc() + ")" ); session.addMessage( "NOTE: CvBiologicalRole( '" + bio.getShortLabel() + "' ) has been renamed '" + role + "'." + "(Component: " + component.getAc() + " - " + "Interaction: " + component.getInteraction().getAc() + ")" ); "Role was set to default '" + DEFAULT_ROLE + "'. " + "(Component: " + component.getAc() + " - Interaction: " + component.getInteraction().getAc() + ")" ); role = DEFAULT_ROLE;
return ((Component) child).getInteraction(); } else if (child instanceof InteractionParameter) { return ((InteractionParameter) child).getInteraction();
@Override protected T syncAttributes(T intactObject) { if (intactObject.getBioSource() != null) { BioSource syncedBioSource = BioSourcePersister.getInstance().syncIfTransient(intactObject.getBioSource()); intactObject.setBioSource(syncedBioSource); } if (intactObject.getCvInteractorType() != null) { CvInteractorType cvIntType = (CvInteractorType) CvObjectPersister.getInstance().syncIfTransient(intactObject.getCvInteractorType()); intactObject.setCvInteractorType(cvIntType); } if ( intactObject.getActiveInstances() != null ) { Collection<Component> components = new ArrayList<Component>( intactObject.getActiveInstances().size() ); for ( Component component : intactObject.getActiveInstances() ) { final Component c = ComponentPersister.getInstance().syncIfTransient( component ); c.setInteractor( intactObject ); c.setInteraction( component.getInteraction() ); components.add( c ); } intactObject.setActiveInstances( components ); } return super.syncAttributes(intactObject); }
public static String createKey(AnnotatedObject ao) { String key; final String normalizedClassName = normalizeClassName(ao.getClass()); if (ao instanceof Component) { // So far, components have as shorltabel N/A => we need to create one that allows to discriminate them Component comp = (Component)ao; String label = comp.getInteraction().getShortLabel()+"_"+comp.getInteractor().getShortLabel(); key = normalizedClassName +":"+label; } else if (ao instanceof BioSource) { key = normalizedClassName +":"+((BioSource)ao).getTaxId(); } else if (ao instanceof CvObject) { CvObject cv = (CvObject)ao; CvObjectXref identity = CvObjectUtils.getPsiMiIdentityXref(cv); if (identity != null) { key = normalizedClassName +":"+identity.getPrimaryId(); } else { key = normalizedClassName +":"+ao.getShortLabel(); } } else if (ao instanceof Feature) { String label = ao.getShortLabel()+"_"+createKey(((Feature)ao).getComponent()); key = normalizedClassName+":"+label; } else { key = normalizedClassName +":"+ao.getShortLabel(); } return key; }
component.setInteraction( synchronize( component.getInteraction() ) ); component.setInteractor( synchronize( component.getInteractor() ) );
component.setInteraction( synchronize( component.getInteraction() ) ); component.setInteractor( synchronize( component.getInteractor() ) );
protected void traverseComponent(Component component, IntactVisitor ... visitors) { if (component == null) return; for (IntactVisitor visitor : visitors) { visitor.visitComponent(component); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(component)) { return; } traverse(component.getInteraction(), visitors); traverse(component.getInteractor(), visitors); traverse(component.getCvBiologicalRole(), visitors); traverse(component.getExpressedIn(), visitors); traverse(component.getParameters(), visitors); traverse(component.getParticipantDetectionMethods(), visitors); traverse(component.getExperimentalPreparations(), visitors); traverse(component.getBindingDomains(), visitors); traverse(component.getExperimentalRoles(), visitors); }
protected void traverseComponent(Component component, IntactVisitor ... visitors) { if (component == null) return; for (IntactVisitor visitor : visitors) { visitor.visitComponent(component); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(component)) { return; } traverse(component.getInteraction(), visitors); traverse(component.getInteractor(), visitors); traverse(component.getCvBiologicalRole(), visitors); traverse(component.getExpressedIn(), visitors); traverse(component.getParameters(), visitors); traverse(component.getParticipantDetectionMethods(), visitors); traverse(component.getExperimentalPreparations(), visitors); traverse(component.getBindingDomains(), visitors); traverse(component.getExperimentalRoles(), visitors); }
@Override protected void saveOrUpdateAttributes(Component intactObject) throws PersisterException { super.saveOrUpdateAttributes(intactObject); if (intactObject.getExpressedIn() != null) { BioSourcePersister bioSourcePersister = BioSourcePersister.getInstance(); bioSourcePersister.saveOrUpdate(intactObject.getExpressedIn()); } CvObjectPersister cvPersister = CvObjectPersister.getInstance(); cvPersister.saveOrUpdate(intactObject.getCvBiologicalRole()); cvPersister.saveOrUpdate(intactObject.getCvExperimentalRole()); for (CvIdentification participantDetection : intactObject.getParticipantDetectionMethods()) { cvPersister.saveOrUpdate(participantDetection); } for (CvExperimentalPreparation experimentalPreparation : intactObject.getExperimentalPreparations()) { cvPersister.saveOrUpdate(experimentalPreparation); } InteractionPersister.getInstance().saveOrUpdate(intactObject.getInteraction()); InteractorPersister.getInstance().saveOrUpdate(intactObject.getInteractor()); for (Feature feature : intactObject.getBindingDomains()) { FeaturePersister.getInstance().saveOrUpdate(feature); } }
clone.setInteraction(clone(component.getInteraction())); clone.setCvBiologicalRole(clone(component.getCvBiologicalRole()));