/** * Determines is the interaction is binary. That is involve exactly two participants. * * @param interaction the interaction to check on. * @return true if the interaction is binary. */ protected boolean isBinary(Interaction interaction) { if (interaction == null) { throw new IllegalArgumentException("Interaction must not be null."); } if (interaction.getParticipants().size() == 2) { return true; } return false; }
public InteractionCategory findInteractionCategory(Interaction interaction) { if (interaction.getParticipants().size() == 1) { Participant c = interaction.getParticipants().iterator().next(); // we have a self interaction but inter molecular if (interaction.isIntraMolecular()){ return InteractionCategory.self_intra_molecular; } else { return InteractionCategory.self_inter_molecular; } } else if (interaction.getParticipants().size() == 2) { return InteractionCategory.binary; } else if (interaction.getParticipants().size() > 2) { return InteractionCategory.n_ary; } return null; }
/** * Builds a new interaction object based the given interaction template. * <br/> Participants are replaced by the two given ones. * * @param interactionTemplate the interaction template. * @param p1 participant to add to the newly created interaction. * @param p2 participant to add to the newly created interaction. * @return a new interaction having p1 and p2 as participant. */ protected Interaction buildInteraction(final Interaction interactionTemplate, Participant p1, Participant p2) { // We do not alter the given interaction template but copy it Interaction i = copyInteraction(interactionTemplate); // add cloned participant i.getParticipants().add(p1); i.getParticipants().add(p2); return i; }
@Override protected Collection<Interaction> processNoBaitExpansion(Interaction interaction) { List<Interaction> interactions = new ArrayList<Interaction>(); log.debug("Could not find a bait participant. Pick a participant arbitrarily: 1st by alphabetical order."); if (interaction.getParticipants().isEmpty()) { return interactions; } // Collect and sort participants by name List<Participant> sortedParticipants = sortParticipants(interaction.getParticipants()); // Pick the first one Participant fakeBait = sortedParticipants.get(0); // Build interactions for (int i = 1; i < sortedParticipants.size(); i++) { Participant fakePrey = sortedParticipants.get(i); if (log.isDebugEnabled()) { String baitStr = displayParticipant(fakeBait); String preyStr = displayParticipant(fakePrey); log.debug("Build new binary interaction [" + baitStr + "," + preyStr + "]"); } Interaction spokeInteraction = buildInteraction(interaction, fakeBait, fakePrey); interactions.add(spokeInteraction); } return interactions; }
public static Interaction createInteraction(String name, ExperimentDescription experiment, InteractionType interactionType, Collection<Participant> participants) { Interaction interaction = new Interaction(); assignNextId(interaction); interaction.setNames(createNames(name, null)); for (Participant participant : participants) { interaction.getParticipants().add(participant); } interaction.getInteractionTypes().add(interactionType); interaction.getExperiments().add(experiment); return interaction; }
public static Entry createEntry(Source source, Collection<Interaction> interactions) { Entry entry = new Entry(); entry.setSource(source); for (Interaction interaction : interactions) { entry.getInteractions().add(interaction); for (ExperimentDescription expDesc : interaction.getExperiments()) { entry.getExperiments().add(expDesc); } for (Participant part : interaction.getParticipants()) { entry.getInteractors().add(part.getInteractor()); } } return entry; }
private void mapEdges(final Collection<Interaction> interactions) { final CyTable edgeTable = network.getDefaultEdgeTable(); final CyTable nodeTable = network.getDefaultNodeTable(); if(edgeTable.getColumn(INTERACTION_TYPE) == null) { edgeTable.createListColumn(INTERACTION_TYPE, String.class, false); } for(Interaction interaction: interactions) { if(cancelFlag) return; final Collection<Participant> nodes = interaction.getParticipants(); // Regular edge if(nodes.size() == 2) { final Iterator<Participant> itr = nodes.iterator(); final Participant source = itr.next(); final Participant target = itr.next(); processEdge(source, target, interaction, nodes, nodeTable, edgeTable); } else { // TODO: do we need Clique, too? createSpokeModel(interaction, nodes, nodeTable, edgeTable); } } }
if (interaction.getParticipants().isEmpty()) { return interactions; Collection<Participant> participants = interaction.getParticipants(); log.debug(participants.size() + " participant(s) found.");
Collection<Interaction> interactions = new ArrayList<Interaction>(); if (interaction.getParticipants().isEmpty()) { return interactions; Participant[] participants = interaction.getParticipants().toArray( new Participant[]{ } ); log.debug( participants.length + " participant(s) found." );
private void removeInteractorRedundancy( EntrySet mEntrySet ) { if( ConverterContext.getInstance().getConverterConfig().getXmlForm() == PsimiXmlForm.FORM_COMPACT ) { for ( Entry entry : mEntrySet.getEntries() ) { Map<Interactor, Interactor> uniqueInteractors = new HashMap<Interactor, Interactor>(); for ( Interaction interaction : entry.getInteractions() ) { for ( Participant participant : interaction.getParticipants() ) { if( participant.getInteractor() != null ) { final Interactor myInteractor = participant.getInteractor(); if( uniqueInteractors.containsKey( myInteractor ) ) { final Interactor uniq = uniqueInteractors.get( myInteractor ); participant.setInteractor( uniq ); } else { uniqueInteractors.put( myInteractor, myInteractor ); } } } // participants } // interactions // if we had a compact format, we cannot remove interactor redundancy without changing the interactions // and update the interactor xref if (!uniqueInteractors.isEmpty()){ entry.getInteractors().clear(); entry.getInteractors().addAll( uniqueInteractors.keySet() ); } } // entries } // model is compact }
private void normalizeEntry(Entry entry) { if (entry.getExperiments().isEmpty()) { for (Interaction interaction : entry.getInteractions()) { interaction.getExperimentRefs().clear(); for (ExperimentDescription exp : interaction.getExperiments()) { entry.getExperiments().add(exp); interaction.getExperimentRefs().add(new ExperimentRef(exp.getId())); } } } if (entry.getInteractors().isEmpty()) { for (Interaction interaction : entry.getInteractions()) { for(Participant participant : interaction.getParticipants()) { entry.getInteractors().add(participant.getInteractor()); } } } }
/** * @param interaction * @return names of these interaction. */ private Names getInteractionName(Interaction interaction) { Names interactionName = null; Collection<Participant> participants = interaction.getParticipants(); for (Participant participant : participants) { if (interactionName != null) { String shortLabel = interactionName.getShortLabel().concat("-"); shortLabel = shortLabel.concat(participant.getInteractor().getNames().getShortLabel().split("_")[0]); interactionName.setShortLabel(shortLabel); } if (interactionName == null) { interactionName = new Names(); interactionName.setShortLabel(participant.getInteractor().getNames().getShortLabel().split("_")[0]); } } if (interactionName == null) { log.warn("Interaction don't have a name"); } return interactionName; }
protected void failIfInconsistentConversion(Interaction intact, psidev.psi.mi.xml.model.Interaction psi, int numberOfAuthorConfAttributes) { Collection<Experiment> experiments; Collection<Component> participants; Collection<Confidence> confidences; if (isCheckInitializedCollections()){ experiments = IntactCore.ensureInitializedExperiments(intact); participants = IntactCore.ensureInitializedParticipants(intact); confidences = IntactCore.ensureInitializedConfidences(intact); } else { experiments = intact.getExperiments(); participants = intact.getComponents(); confidences = intact.getConfidences(); } failIfInconsistentCollectionSize("experiment", experiments, psi.getExperiments()); failIfInconsistentCollectionSize("participant", participants, psi.getParticipants()); Collection<Confidence> confs = confidences; if (confs.size() > 0 && psi.getConfidences().size() + numberOfAuthorConfAttributes > 0 && confs.size() != (psi.getConfidences().size() + numberOfAuthorConfAttributes)) { throw new InconsistentConversionException("Confidence", confs.size(), psi.getConfidences().size() + numberOfAuthorConfAttributes); } }
protected void failIfInconsistentPsiConversion(Interaction intact, psidev.psi.mi.xml.model.Interaction psi) { Collection<Experiment> experiments; Collection<Component> participants; Collection<Confidence> confidences; if (isCheckInitializedCollections()){ experiments = IntactCore.ensureInitializedExperiments(intact); participants = IntactCore.ensureInitializedParticipants(intact); confidences = IntactCore.ensureInitializedConfidences(intact); } else { experiments = intact.getExperiments(); participants = intact.getComponents(); confidences = intact.getConfidences(); } failIfInconsistentCollectionSize("experiment", experiments, psi.getExperiments()); failIfInconsistentCollectionSize("participant", participants, psi.getParticipants()); Collection<Confidence> confs = confidences; if (confs.size() > 0 && psi.getConfidences().size() > 0 && (confs.size()) != psi.getConfidences().size()) { throw new InconsistentConversionException("Confidence", confs.size(), psi.getConfidences().size()); } }
public static Collection<Object> nonRedundantInteractorsFromPsiEntry(Entry psiEntry) { Map<Integer, Object> nonRedundantInteractors = new HashMap<Integer, Object>(); if( ConverterContext.getInstance().isGenerateExpandedXml() ) { // iterate to get the unique experiments/interactors for (psidev.psi.mi.xml.model.Interaction interaction : psiEntry.getInteractions()) { for (Participant participant : interaction.getParticipants()) { if (participant.getInteractor() != null){ nonRedundantInteractors.put(participant.getInteractor().getId(), participant.getInteractor()); } else if (participant.getInteraction() != null){ nonRedundantInteractors.put(participant.getInteraction().getId(), participant.getInteraction()); } } } } else { for ( psidev.psi.mi.xml.model.Interactor interactor : psiEntry.getInteractors() ) { nonRedundantInteractors.put( interactor.getId(), interactor ); } } return nonRedundantInteractors.values(); }
protected Collection<Component> getComponents(Interaction interaction, psidev.psi.mi.xml.model.Interaction psiInteraction) { List<Component> components = new ArrayList<Component>(psiInteraction.getParticipants().size()); for (Participant participant : psiInteraction.getParticipants()) { if (participant.getInteractor() == null && participant.getInteraction() == null) { throw new PsiConversionException("Participant without interactor found: "+participant+" in interaction: "+interaction);
for(Participant participant : interaction.getParticipants()) {
for ( Participant participant : interaction.getParticipants() ) {
for (psidev.psi.mi.xml.model.Participant mParticipant : mInteraction.getParticipants()) { mEntry.getInteractors().add(mParticipant.getInteractor());
protected void failIfInconsistentConversion(Interaction intact, psidev.psi.mi.xml.model.Interaction psi) { Collection<Experiment> experiments; Collection<Component> participants; Collection<Confidence> confidences; if (isCheckInitializedCollections()){ experiments = IntactCore.ensureInitializedExperiments(intact); participants = IntactCore.ensureInitializedParticipants(intact); confidences = IntactCore.ensureInitializedConfidences(intact); } else { experiments = intact.getExperiments(); participants = intact.getComponents(); confidences = intact.getConfidences(); } failIfInconsistentCollectionSize("experiment", experiments, psi.getExperiments()); failIfInconsistentCollectionSize("participant", participants, psi.getParticipants()); failIfInconsistentCollectionSize( "confidence", confidences, psi.getConfidences()); }