public void addExperimentalRole( CvExperimentalRole experimentalRole ) { getExperimentalRoles().add( experimentalRole ); }
public void addExperimentalRole( CvExperimentalRole experimentalRole ) { getExperimentalRoles().add( experimentalRole ); }
public int compare(Component comp1, Component comp2) { String name1 = getLabel(comp1); String name2 = getLabel(comp2); // same role? alphabetical order CvExperimentalRole role1 = null; CvExperimentalRole role2 = null; if (!comp1.getExperimentalRoles().isEmpty()) { role1 = comp1.getExperimentalRoles().iterator().next(); } if (!comp2.getExperimentalRoles().isEmpty()) { role2 = comp2.getExperimentalRoles().iterator().next(); } if (role1 == null && role2 == null) return name1.compareTo(name2); if (role1 != null && role2 == null) return -1; if (role1 == null) return 1; // the order is: bait -> prey -> other final boolean isBait1 = ComponentUtils.isBait(comp1.getExperimentalRoles()); final boolean isBait2 = ComponentUtils.isBait(comp2.getExperimentalRoles()); final boolean isPrey1 = ComponentUtils.isPrey(comp1.getExperimentalRoles()); final boolean isPrey2 = ComponentUtils.isPrey(comp2.getExperimentalRoles()); if (isBait1 && !isBait2) return -1; if (isBait1 && isBait2) return name1.compareTo(name2); if (isBait2) return 1; if (isPrey1 && !isPrey2) return -1; if (isPrey1 && isPrey2) return name1.compareTo(name2); if (isPrey2) return 1; return name1.compareTo(name2); }
public int compare(Component comp1, Component comp2) { String name1 = getLabel(comp1); String name2 = getLabel(comp2); // same role? alphabetical order CvExperimentalRole role1 = null; CvExperimentalRole role2 = null; if (!comp1.getExperimentalRoles().isEmpty()) { role1 = comp1.getExperimentalRoles().iterator().next(); } if (!comp2.getExperimentalRoles().isEmpty()) { role2 = comp2.getExperimentalRoles().iterator().next(); } if (role1 == null && role2 == null) return name1.compareTo(name2); if (role1 != null && role2 == null) return -1; if (role1 == null) return 1; // the order is: bait -> prey -> other final boolean isBait1 = ComponentUtils.isBait(comp1.getExperimentalRoles()); final boolean isBait2 = ComponentUtils.isBait(comp2.getExperimentalRoles()); final boolean isPrey1 = ComponentUtils.isPrey(comp1.getExperimentalRoles()); final boolean isPrey2 = ComponentUtils.isPrey(comp2.getExperimentalRoles()); if (isBait1 && !isBait2) return -1; if (isBait1 && isBait2) return name1.compareTo(name2); if (isBait2) return 1; if (isPrey1 && !isPrey2) return -1; if (isPrey1 && isPrey2) return name1.compareTo(name2); if (isPrey2) return 1; return name1.compareTo(name2); }
/** * Returns the first components marked as bait. If no such components is found, return null. * * @return The first components marked as bait, otherwise null. * * @deprecated this method should not be part of the model. A utility class should instead, * for instance: uk.ac.ebi.intact.model.util.InteractionUtils. */ @Transient @Deprecated public Component getBait() { for ( Component component : components ) { Collection<CvExperimentalRole> roles = component.getExperimentalRoles(); if ( roles == null ) { return null; } for ( CvExperimentalRole role : roles ) { if ( role.getShortLabel().equals( "bait" ) ) { return component; } } } return null; }
/** * Returns the first components marked as bait. If no such components is found, return null. * * @return The first components marked as bait, otherwise null. * * @deprecated this method should not be part of the model. A utility class should instead, * for instance: uk.ac.ebi.intact.model.util.InteractionUtils. */ @Transient @Deprecated public Component getBait() { for ( Component component : components ) { Collection<CvExperimentalRole> roles = component.getExperimentalRoles(); if ( roles == null ) { return null; } for ( CvExperimentalRole role : roles ) { if ( role.getShortLabel().equals( "bait" ) ) { return component; } } } return null; }
/** * Retrieves the experimental roles from a participant, initializing them if necessary. * Do not set the initialized collection of experimental roles because cannot be orphan * @param component the component * @return The returned experimental roles are ensured to be initialized * @since 2.4.0 */ public static Collection<CvExperimentalRole> ensureInitializedExperimentalRoles(Component component) { Collection<CvExperimentalRole> roles; if (IntactCore.isInitialized(component.getExperimentalRoles())) { roles = component.getExperimentalRoles(); } else { roles = IntactContext.getCurrentInstance().getDaoFactory().getComponentDao().getExperimentalRolesForComponentAc(component.getAc()); } return roles; }
/** * Retrieves the experimental roles from a participant, initializing them if necessary. * Do not set the initialized collection of experimental roles because cannot be orphan * @param component the component * @return The returned experimental roles are ensured to be initialized * @since 2.4.0 */ public static Collection<CvExperimentalRole> ensureInitializedExperimentalRoles(Component component) { Collection<CvExperimentalRole> roles; if (IntactCore.isInitialized(component.getExperimentalRoles())) { roles = component.getExperimentalRoles(); } else { roles = IntactContext.getCurrentInstance().getDaoFactory().getComponentDao().getExperimentalRolesForComponentAc(component.getAc()); } return roles; }
@Override public boolean isExpandable(Interaction interaction) { if (!super.isExpandable(interaction)) { return false; } if (interaction.getComponents().size() > 1) { boolean containsBait = false; for (Component component : interaction.getComponents()) { if (containsRole(component.getExperimentalRoles(), new String[] {CvExperimentalRole.BAIT_PSI_REF})) { containsBait = true; break; } } return containsBait; } return true; }
@Override public InteractionCategory findInteractionCategory(Interaction interaction) { if (interaction.getComponents().size() == 1) { Component c = interaction.getComponents().iterator().next(); // we have a self interaction but inter molecular if (c.getStoichiometry() >= 2 || (c.getStoichiometry() == 0 && !containsRole(c.getExperimentalRoles(), new String[]{CvExperimentalRole.SELF_PSI_REF, PUTATIVE_SELF_PSI_REF}))){ return InteractionCategory.self_inter_molecular; } else { return InteractionCategory.self_intra_molecular; } } else if (interaction.getComponents().size() == 2){ return InteractionCategory.binary; } else if (interaction.getComponents().size() > 2){ return InteractionCategory.n_ary; } return null; } }
if (IntactCore.isInitializedAndDirty(component.getExperimentalRoles())) { Collection<CvExperimentalRole> roles = synchronizeCollection( component.getExperimentalRoles() ); component.getExperimentalRoles().clear(); component.getExperimentalRoles().addAll(roles);
if (IntactCore.isInitializedAndDirty(component.getExperimentalRoles())) { Collection<CvExperimentalRole> roles = synchronizeCollection( component.getExperimentalRoles() ); component.getExperimentalRoles().clear(); component.getExperimentalRoles().addAll(roles);
List<CvExperimentalRole> expRoles = new ArrayList<CvExperimentalRole>(component.getExperimentalRoles()); Collections.sort(expRoles, new CvObjectComparator());
List<CvExperimentalRole> expRoles = new ArrayList<CvExperimentalRole>(component.getExperimentalRoles()); Collections.sort(expRoles, new CvObjectComparator());
if (isCollectionClonable(component.getExperimentalRoles())) { Collection<CvExperimentalRole> roles = IntactCore.ensureInitializedExperimentalRoles(component); clone.getExperimentalRoles().add(clone(expRole));
if (isCollectionClonable(component.getExperimentalRoles())) { Collection<CvExperimentalRole> roles = IntactCore.ensureInitializedExperimentalRoles(component); clone.getExperimentalRoles().add(clone(expRole));
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); }
if ( !CollectionUtils.isEqualCollection(getExperimentalRoles(), component.getExperimentalRoles()) ) { return false;
if ( !CollectionUtils.isEqualCollection(getExperimentalRoles(), component.getExperimentalRoles()) ) { return false;