public Collection<BinaryInteraction> convert( Collection<Interaction> interactions ) { if ( interactions == null ) { throw new IllegalArgumentException( "Interactions must not be null" ); } if (expansionStrategy == null) { throw new NullPointerException("No expansion strategy defined"); } Collection<BinaryInteraction> result = new ArrayList<BinaryInteraction>(interactions.size()); for ( Interaction interaction : interactions ) { Collection<BinaryInteraction> expandedInteractions = null; try { expandedInteractions = expansionStrategy.expand(interaction); } catch ( NotExpandableInteractionException e ) { log.warn( "Interaction " + interaction.getAc() + " could not be expanded. Skipping." ); } if( expandedInteractions != null ) { result.addAll(expandedInteractions); } } if ( ! result.isEmpty() ) { result = doPostProcessing( result ); } return result; }
/** * Gets the Interactor Identifiers for that interaction * * @since 1.7.2 */ public static List<String> getInteractorPrimaryIDs(Interaction interaction) { final Collection<Component> components = interaction.getComponents(); List<String> ids = new ArrayList<String>(components.size()); for (Component component : components) { Interactor interactor = component.getInteractor(); final Collection<InteractorXref> idXrefs = XrefUtils.getIdentityXrefs(interactor); if (idXrefs.size() > 0) { final Iterator<InteractorXref> iterator = idXrefs.iterator(); ids.add(iterator.next().getPrimaryId()); if (log.isDebugEnabled()) { if (iterator.hasNext()) { log.debug("Interaction contains interactor with more than one identities. Interaction: " + interaction.getShortLabel() + "(" + interaction.getAc() + ") " + " - Xrefs: " + idXrefs); } } } } return ids; }
/** * Gets the Interactor Identifiers for that interaction * * @since 1.7.2 */ public static List<String> getInteractorPrimaryIDs(Interaction interaction) { final Collection<Component> components = interaction.getComponents(); List<String> ids = new ArrayList<String>(components.size()); for (Component component : components) { Interactor interactor = component.getInteractor(); final Collection<InteractorXref> idXrefs = XrefUtils.getIdentityXrefs(interactor); if (idXrefs.size() > 0) { final Iterator<InteractorXref> iterator = idXrefs.iterator(); ids.add(iterator.next().getPrimaryId()); if (log.isDebugEnabled()) { if (iterator.hasNext()) { log.debug("Interaction contains interactor with more than one identities. Interaction: " + interaction.getShortLabel() + "(" + interaction.getAc() + ") " + " - Xrefs: " + idXrefs); } } } } return ids; }
/** * 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; }
/** * 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; }
/** * 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; }
log.info("Processing interaction : " + intactInteraction.getAc());
@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; }
@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; }
/** * Filter the binary interactions of a given list of interactions and return a list composed with only binary interactions * @param interactionAcs : the list of interaction accessions * @param eligibleInteractions : the list of eligible interactions for uniprot export */ private void filterTrueBinaryInteractions(List<String> interactionAcs, List<String> eligibleInteractions) { // process each interaction of the list final int interactionCount = interactionAcs.size(); for (int i = 0; i < interactionCount; i++) { TransactionStatus status = IntactContext.getCurrentInstance().getDataContext().beginTransaction(); // get the IntAct interaction object String interactionAc = interactionAcs.get(i); Interaction interaction = IntactContext.getCurrentInstance().getDaoFactory().getInteractionDao().getByAc(interactionAc); // the interaction exists in IntAct if (interaction != null){ logger.info("\t\t Interaction: Shortlabel:" + interaction.getShortLabel() + " AC: " + interaction.getAc()); if (InteractionUtils.isBinaryInteraction(interaction)){ eligibleInteractions.add(interactionAc); } } IntactContext.getCurrentInstance().getDataContext().commitTransaction(status); } // i }
private static Collection<Annotation> fetchAnnotations(Interaction interaction) { Collection<Annotation> annotations; if (IntactCore.isInitialized(interaction.getAnnotations())) { annotations = interaction.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(InteractionImpl.class, interaction.getAc()); } return annotations; }
private static Collection<Annotation> fetchAnnotations(Interaction interaction) { Collection<Annotation> annotations; if (IntactCore.isInitialized(interaction.getAnnotations())) { annotations = interaction.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(InteractionImpl.class, interaction.getAc()); } return annotations; }
/** * Retrieves the confidences from an interaction, initializing them if necessary. * Do not set the initialized collection of confidences because confidences cannot be orphan * @param interaction the interaction * @return The returned confidences are ensured to be initialized * @since 2.4.0 */ public static Collection<Confidence> ensureInitializedConfidences(Interaction interaction) { Collection<Confidence> confidences; if (IntactCore.isInitialized(interaction.getConfidences())) { confidences = interaction.getConfidences(); } else { confidences = IntactContext.getCurrentInstance().getDaoFactory().getConfidenceDao().getByInteractionAc(interaction.getAc()); } return confidences; }
/** * Retrieves the experiment from an interaction, initializing them if necessary. * * @param interaction the interaction * @return The returned experiments are ensured to be initialized * @since 2.4.0 */ public static Collection<Experiment> ensureInitializedExperiments(Interaction interaction) { Collection<Experiment> experiments; if (IntactCore.isInitialized(interaction.getExperiments())) { experiments = interaction.getExperiments(); } else { experiments = IntactContext.getCurrentInstance().getDaoFactory().getExperimentDao().getByInteractionAc(interaction.getAc()); } return experiments; }
/** * Retrieves the experiment from an interaction, initializing them if necessary. * * @param interaction the interaction * @return The returned experiments are ensured to be initialized * @since 2.4.0 */ public static Collection<Experiment> ensureInitializedExperiments(Interaction interaction) { Collection<Experiment> experiments; if (IntactCore.isInitialized(interaction.getExperiments())) { experiments = interaction.getExperiments(); } else { experiments = IntactContext.getCurrentInstance().getDaoFactory().getExperimentDao().getByInteractionAc(interaction.getAc()); } return experiments; }
/** * Retrieves the parameters from an interaction, initializing them if necessary. * Do not set the initialized collection of parameters because parameters cannot be orphan * @param interaction the interaction * @return The returned confidences are ensured to be initialized * @since 2.4.0 */ public static Collection<InteractionParameter> ensureInitializedInteractionParameters(Interaction interaction) { Collection<InteractionParameter> parameters; if (IntactCore.isInitialized(interaction.getParameters())) { parameters = interaction.getParameters(); } else { parameters = IntactContext.getCurrentInstance().getDaoFactory().getInteractionParameterDao().getByInteractionAc(interaction.getAc()); } return parameters; }
/** * Retrieves the confidences from an interaction, initializing them if necessary. * Do not set the initialized collection of confidences because confidences cannot be orphan * @param interaction the interaction * @return The returned confidences are ensured to be initialized * @since 2.4.0 */ public static Collection<Confidence> ensureInitializedConfidences(Interaction interaction) { Collection<Confidence> confidences; if (IntactCore.isInitialized(interaction.getConfidences())) { confidences = interaction.getConfidences(); } else { confidences = IntactContext.getCurrentInstance().getDaoFactory().getConfidenceDao().getByInteractionAc(interaction.getAc()); } return confidences; }
/** * Retrieves the parameters from an interaction, initializing them if necessary. * Do not set the initialized collection of parameters because parameters cannot be orphan * @param interaction the interaction * @return The returned confidences are ensured to be initialized * @since 2.4.0 */ public static Collection<InteractionParameter> ensureInitializedInteractionParameters(Interaction interaction) { Collection<InteractionParameter> parameters; if (IntactCore.isInitialized(interaction.getParameters())) { parameters = interaction.getParameters(); } else { parameters = IntactContext.getCurrentInstance().getDaoFactory().getInteractionParameterDao().getByInteractionAc(interaction.getAc()); } return parameters; }
/** * Retrieves the components from an interaction, initializing them if necessary. * Do not set the initialized collection of components because components cannot be orphan * * @param interaction the interaction * @return The returned components are ensured to be initialized * @since 2.4.0 */ public static Collection<Component> ensureInitializedParticipants(Interaction interaction) { Collection<Component> components; if (IntactCore.isInitialized(interaction.getComponents())) { components = interaction.getComponents(); } else { components = IntactContext.getCurrentInstance().getDaoFactory().getComponentDao().getByInteractionAc(interaction.getAc()); } return components; }
/** * Retrieves the components from an interaction, initializing them if necessary. * Do not set the initialized collection of components because components cannot be orphan * * @param interaction the interaction * @return The returned components are ensured to be initialized * @since 2.4.0 */ public static Collection<Component> ensureInitializedParticipants(Interaction interaction) { Collection<Component> components; if (IntactCore.isInitialized(interaction.getComponents())) { components = interaction.getComponents(); } else { components = IntactContext.getCurrentInstance().getDaoFactory().getComponentDao().getByInteractionAc(interaction.getAc()); } return components; }