public int compare(Participant p1, Participant p2) { Interactor i1 = p1.getInteractor(); if( i1 == null ) { throw new IllegalArgumentException( "Both participant should hold a valid interactor." ); } Interactor i2 = p2.getInteractor(); if( i2 == null ) { throw new IllegalArgumentException( "Both participant should hold a valid interactor." ); } String name1 = getName( i1 ); String name2 = getName( i2 ); int result; if ( name1 == null ) { result = -1; } else if ( name2 == null ) { result = 1; } else { result = name1.compareTo( name2 ); } return result; } } );
jParticipant.setInteractorRef( mParticipant.getInteractorRef().getRef() ); else jParticipant.setInteractorRef( mParticipant.getInteractor().getId() ); jParticipant.setInteractor( interactorConverter.toJaxb( mParticipant.getInteractor() ) );
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 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 }
/** * @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; }
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(); }
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()); } } } }
protected String displayParticipant(Participant p) { // fetch role String role = ""; for (ExperimentalRole aRole : p.getExperimentalRoles()) { if (role.length() > 0) { role += "&"; } if (aRole.hasNames()) { role += aRole.getNames().getShortLabel(); } else { role += "?"; } } // fetch interactor String interactor = p.getInteractor().getNames().getShortLabel(); return interactor + ":" + role; }
private String displayParticipant( Participant p ) { // fetch role String role = ""; for ( ExperimentalRole aRole : p.getExperimentalRoles() ) { if ( role.length() > 0 ) { role += "&"; } if ( aRole.hasNames() ) { role += aRole.getNames().getShortLabel(); } else { role += "?"; } } // fetch interactor String interactor = p.getInteractor().getNames().getShortLabel(); return interactor + ":" + role; }
if (participant.getInteractor() == null && participant.getInteraction() == null) { throw new PsiConversionException("Participant without interactor found: "+participant+" in interaction: "+interaction);
Interactor interactor = participant.getInteractor(); String name = interactor.getNames().getShortLabel(); String type = interactor.getInteractorType().getNames().getShortLabel();
for(Participant p : interaction.getParticipants()) { if(p.hasInteractor()) { String type = getName(p.getInteractor().getInteractorType().getNames()); if(type==null) type = "protein"; //default type (if unspecified) participantTypes.add(type.toLowerCase()); + "; so we'll replace 'gene' with 'dna' (a quick fix)"); for(Participant p : interaction.getParticipants()) { if(p.hasInteractor() && p.getInteractor().getInteractorType().hasNames()) { String type = getName(p.getInteractor().getInteractorType().getNames()); if("gene".equalsIgnoreCase(type)) { p.getInteractor().getInteractorType().getNames().setShortLabel("dna");
mEntry.getInteractors().add(mParticipant.getInteractor()); participantIds.add(mParticipant.getInteractor().getId());
private void processEdge(final Participant source, final Participant target, final Interaction interaction, final Collection<Participant> nodes, CyTable nodeTable, CyTable edgeTable) { Interactor sourceInteractor = source.getInteractor(); Interactor targetInteractor = target.getInteractor(); if (sourceInteractor == null || targetInteractor == null) { return; } final CyNode sourceCyNode = id2NodeMap.get(sourceInteractor.getId()); final CyNode targetCyNode = id2NodeMap.get(targetInteractor.getId()); // PPI does not have directinarity final CyEdge edge = network.addEdge(sourceCyNode, targetCyNode, false); // TODO: what's the best value for interaction? edgeTable.getRow(edge.getSUID()).set(CyEdge.INTERACTION, "pp"); final String sourceName = nodeTable.getRow(sourceCyNode.getSUID()).get(CyNetwork.NAME, String.class); final String targetName = nodeTable.getRow(targetCyNode.getSUID()).get(CyNetwork.NAME, String.class); edgeTable.getRow(edge.getSUID()).set(CyNetwork.NAME, sourceName + " (pp) " + targetName); mapNames(edgeTable, edge.getSUID(), interaction.getNames(), null); mapAttributes(interaction.getAttributes(), edgeTable, edge.getSUID()); final Collection<InteractionType> types = interaction.getInteractionTypes(); mapInteractionType(types, edgeTable, edge.getSUID()); }
for (psidev.psi.mi.xml.model.Interaction mInteraction : mEntry.getInteractions()) { for (psidev.psi.mi.xml.model.Participant mParticipant : mInteraction.getParticipants()) { mEntry.getInteractors().add(mParticipant.getInteractor());
if (participant.getInteractor() != null){ interactor = this.interactorConverter.psiToIntact(participant.getInteractor());
for (psidev.psi.mi.xml.model.Participant mParticipant : mInteraction.getParticipants()) { if (!participantIds.contains(mParticipant.getId())) { jEntry.getInteractorList().getInteractors().add(interactorConverter.toJaxb(mParticipant.getInteractor())); participantIds.add(mParticipant.getId());
for (psidev.psi.mi.xml.model.Participant mParticipant : mInteraction.getParticipants()) { if (!participantIds.contains(mParticipant.getId())) { jEntry.getInteractorList().getInteractors().add( interactorConverter.toJaxb(mParticipant.getInteractor())); participantIds.add(mParticipant.getId());
public static Component newComponent(Institution institution, Participant participant, uk.ac.ebi.intact.model.Interaction interaction) { Interactor interactor = new InteractorConverter(institution).psiToIntact(participant.getInteractor());
entity = createParticipant(participant, participant.getInteractor(), avail, pro, false); } else if(participant.hasInteraction()) {