/** * It takes an interactions Collection and retrieves the ACs for the interactions that have a NucleicAcid or * SmallMolecule as component. * This is used in case psi version is PSI 1.0 as it does not allow Nucleic Acid as Interaction's participant. * @param interactions Collection of interactions * @return a list with the ACs which should be filtered */ public static List<String> filterInteractions(Collection<Interaction> interactions){ List<String> filteredAcs = new ArrayList<String>(); for (Interaction interaction : interactions) { if ( InteractionUtils.containsNonProteinInteractors(interaction) || InteractionUtils.isSelfInteraction(interaction) || InteractionUtils.isUnaryInteraction( interaction ) ) { filteredAcs.add(interaction.getAc()); } } return filteredAcs; }
/** * checkes if the given interaction has an IMEx identifier. * * @param interaction the interaction to seach on. * @return true if the interaction has an IMEx identifier, false otherwise. */ public static boolean hasImexIdentifier(Interaction interaction) { return getImexIdentifier(interaction) != null; }
public Collection<Interaction> getSelfBinaryInteractionsByProtAc( String protAc ) { List<Interaction> interactions = getInteractionsByInteractorAc( protAc ); Set<Interaction> selfInteractions = new HashSet<Interaction>(); for ( Interaction inter : interactions ) { boolean isSelfInteraction = InteractionUtils.isSelfBinaryInteraction( inter ); if ( isSelfInteraction ) { selfInteractions.add( inter ); } } return selfInteractions; }
public Interaction createInteraction(Component ... components) { CvInteractionType cvInteractionType = createCvObject(CvInteractionType.class, CvInteractionType.DIRECT_INTERACTION_MI_REF, CvInteractionType.DIRECT_INTERACTION); Experiment experiment = createExperimentEmpty(); Interaction interaction = new InteractionImpl(new ArrayList<Experiment>(Arrays.asList(experiment)), cvInteractionType, null, "temp", getInstitution()); for (Component component : components) { interaction.addComponent(component); } String shortLabel = InteractionUtils.calculateShortLabel(interaction); interaction.setShortLabel(shortLabel); return interaction; }
public void onPrePersist(Interaction objToPersist) { String shortLabel = objToPersist.getShortLabel(); String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel); if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); objToPersist.setShortLabel(newShortLabel); } }
/** * Syncs a short label with the database, checking that there are no duplicates and that the correct suffix is added. * <p/> * Concurrency note: just after getting the new short label, it is recommended to persist/update the interaction immediately * in the database - so this method should ONLY be used before saving the interaction to the database. In some * race conditions, two interactions could be created with the same id; currently there is no way to * reserve a short label * * @param shortLabel the short label to sync * @return the synced short label * @see uk.ac.ebi.intact.model.util.InteractionShortLabelGenerator * @since 1.6 */ public static String syncShortLabelWithDb( String shortLabel ) { if (isTemporaryLabel(shortLabel)) { if (log.isWarnEnabled()) log.warn("Label for interaction was temporary ("+shortLabel+"), hence not synced with the database"); return shortLabel; } return InteractionShortLabelGenerator.nextAvailableShortlabel( shortLabel ); }
public static boolean isNegative(Interaction interaction) { Collection<Annotation> annotations = fetchAnnotations(interaction); for (Annotation annotation : annotations) { if (annotation.getCvTopic() != null && annotation.getCvTopic().getShortLabel().equals(CvTopic.NEGATIVE)) { return true; } } return false; }
@Override protected String findAcForInteraction( Interaction interaction ) { // replace all this eventually by just using the CRC InteractionDao interactionDao = getDaoFactory().getInteractionDao(); CrcCalculator crcCalculator = new CrcCalculator(); // Get the interactors where exactly the same interactors are involved List<String> interactorPrimaryIDs = InteractionUtils.getInteractorPrimaryIDs( interaction ); List<Interaction> interactionsWithSameInteractors = interactionDao.getByInteractorsPrimaryId( true, interactorPrimaryIDs.toArray( new String[interactorPrimaryIDs.size()] ) ); for ( Interaction interactionWithSameInteractor : interactionsWithSameInteractors ) { String interactionCrc = crcCalculator.crc64( interaction ); String interactionWithSameInteractorCrc = crcCalculator.crc64( interactionWithSameInteractor ); if ( interactionCrc.equals( interactionWithSameInteractorCrc ) ) { return interactionWithSameInteractor.getAc(); } } return null; }
public Interaction createInteraction(Component ... components) { CvInteractionType cvInteractionType = createCvObject(CvInteractionType.class, CvInteractionType.DIRECT_INTERACTION_MI_REF, CvInteractionType.DIRECT_INTERACTION); Experiment experiment = createExperimentEmpty(); CvInteractorType intType = createCvObject(CvInteractorType.class, CvInteractorType.INTERACTION_MI_REF, CvInteractorType.INTERACTION ); Interaction interaction = new InteractionImpl(new ArrayList<Experiment>(Arrays.asList(experiment)), cvInteractionType, intType, "temp", getInstitution()); for (Component component : components) { interaction.addComponent(component); } try { String shortLabel = InteractionUtils.calculateShortLabel(interaction); interaction.setShortLabel(shortLabel); } catch (Exception e) { interaction.setShortLabel("unk-unk"); } return interaction; }
/** * Update the shortlabel based on the data available in the database. */ public void synchronizeShortLabel() { if( IntactContext.currentInstanceExists() ) { if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateInteractionLabel() ) { String shortLabel = getShortLabel(); String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel); if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); setShortLabel(newShortLabel); } } } else { log.warn( "There is no IntAct Context initialized, skipping interaction shortlabel synchronization." ); } }
/** * Syncs a short label with the database, checking that there are no duplicates and that the correct suffix is added. * <p/> * Concurrency note: just after getting the new short label, it is recommended to persist/update the interaction immediately * in the database - so this method should ONLY be used before saving the interaction to the database. In some * race conditions, two interactions could be created with the same id; currently there is no way to * reserve a short label * * @param shortLabel the short label to sync * @return the synced short label * @see uk.ac.ebi.intact.model.util.InteractionShortLabelGenerator * @since 1.6 */ public static String syncShortLabelWithDb(String shortLabel) { if (isTemporaryLabel(shortLabel)) { if (log.isDebugEnabled()) log.debug("Label for interaction was temporary (" + shortLabel + "), hence not synced with the database"); return shortLabel; } return InteractionShortLabelGenerator.nextAvailableShortlabel(shortLabel); }
public static boolean isNegative(Interaction interaction) { Collection<Annotation> annotations = fetchAnnotations(interaction); for (Annotation annotation : annotations) { if (annotation.getCvTopic() != null && annotation.getCvTopic().getShortLabel().equals(CvTopic.NEGATIVE)) { return true; } } return false; }
@Override protected String findAcForInteraction( Interaction interaction ) { // replace all this eventually by just using the CRC InteractionDao interactionDao = getDaoFactory().getInteractionDao(); CrcCalculator crcCalculator = new CrcCalculator(); // Get the interactors where exactly the same interactors are involved List<String> interactorPrimaryIDs = InteractionUtils.getInteractorPrimaryIDs( interaction ); List<Interaction> interactionsWithSameInteractors = interactionDao.getByInteractorsPrimaryId( true, interactorPrimaryIDs.toArray( new String[interactorPrimaryIDs.size()] ) ); for ( Interaction interactionWithSameInteractor : interactionsWithSameInteractors ) { String interactionCrc = crcCalculator.crc64( interaction ); String interactionWithSameInteractorCrc = crcCalculator.crc64( interactionWithSameInteractor ); if ( interactionCrc.equals( interactionWithSameInteractorCrc ) ) { return interactionWithSameInteractor.getAc(); } } return null; }
/** * It takes an interactions Collection and retrieves the ACs for the interactions that have a NucleicAcid or * SmallMolecule as component. * This is used in case psi version is PSI 1.0 as it does not allow Nucleic Acid as Interaction's participant. * @param interactions Collection of interactions * @return a list with the ACs which should be filtered */ public static List<String> filterInteractions(Collection<Interaction> interactions){ List<String> filteredAcs = new ArrayList<String>(); for (Interaction interaction : interactions) { if ( InteractionUtils.containsNonProteinInteractors(interaction) || InteractionUtils.isSelfInteraction(interaction) || InteractionUtils.isUnaryInteraction( interaction ) ) { filteredAcs.add(interaction.getAc()); } } return filteredAcs; }
public Interaction createInteraction(Component ... components) { CvInteractionType cvInteractionType = createCvObject(CvInteractionType.class, CvInteractionType.DIRECT_INTERACTION_MI_REF, CvInteractionType.DIRECT_INTERACTION); Experiment experiment = createExperimentEmpty(); CvInteractorType intType = createCvObject(CvInteractorType.class, CvInteractorType.INTERACTION_MI_REF, CvInteractorType.INTERACTION ); Interaction interaction = new InteractionImpl(new ArrayList<Experiment>(Arrays.asList(experiment)), cvInteractionType, intType, "temp", getInstitution()); for (Component component : components) { interaction.addComponent(component); } try { String shortLabel = InteractionUtils.calculateShortLabel(interaction); interaction.setShortLabel(shortLabel); } catch (Exception e) { interaction.setShortLabel("unk-unk"); } return interaction; }
public Collection<Interaction> getSelfBinaryInteractionsByProtAc( String protAc ) { List<Interaction> interactions = getInteractionsByInteractorAc( protAc ); Set<Interaction> selfInteractions = new HashSet<Interaction>(); for ( Interaction inter : interactions ) { boolean isSelfInteraction = InteractionUtils.isSelfBinaryInteraction( inter ); if ( isSelfInteraction ) { selfInteractions.add( inter ); } } return selfInteractions; }
/** * checkes if the given interaction has an IMEx identifier. * * @param interaction the interaction to seach on. * @return true if the interaction has an IMEx identifier, false otherwise. */ public static boolean hasImexIdentifier(Interaction interaction) { return getImexIdentifier(interaction) != null; }
/** * Update the shortlabel based on the data available in the database. */ public void synchronizeShortLabel() { if( IntactContext.currentInstanceExists() ) { if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateInteractionLabel() ) { String shortLabel = getShortLabel(); String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel); if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); setShortLabel(newShortLabel); } } } else { log.warn( "There is no IntAct Context initialized, skipping interaction shortlabel synchronization." ); } }
/** * Syncs a short label with the database, checking that there are no duplicates and that the correct suffix is added. * <p/> * Concurrency note: just after getting the new short label, it is recommended to persist/update the interaction immediately * in the database - so this method should ONLY be used before saving the interaction to the database. In some * race conditions, two interactions could be created with the same id; currently there is no way to * reserve a short label * * @param shortLabel the short label to sync * @return the synced short label * @see uk.ac.ebi.intact.model.util.InteractionShortLabelGenerator * @since 1.6 */ public static String syncShortLabelWithDb(String shortLabel) { if (isTemporaryLabel(shortLabel)) { if (log.isDebugEnabled()) log.debug("Label for interaction was temporary (" + shortLabel + "), hence not synced with the database"); return shortLabel; } return InteractionShortLabelGenerator.nextAvailableShortlabel(shortLabel); }
/** * It takes an interactions Collection and retrieves the ACs for the interactions that have a NucleicAcid or * SmallMolecule as component. * This is used in case psi version is PSI 1.0 as it does not allow Nucleic Acid as Interaction's participant. * @param interactions Collection of interactions * @return a list with the ACs which should be filtered */ public static List<String> filterInteractions(Collection<Interaction> interactions){ List<String> filteredAcs = new ArrayList<String>(); for (Interaction interaction : interactions) { if ( InteractionUtils.containsNonProteinInteractors(interaction) || InteractionUtils.isSelfInteraction(interaction) || InteractionUtils.isUnaryInteraction( interaction ) ) { filteredAcs.add(interaction.getAc()); } } return filteredAcs; }