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; }
/** * Build a new Interaction with no participants but holding a copy of all other attributes of the given interaction. * <br/> WARNING: all attributes of the newly created interaction are the same as the source's (that is same object * instance). This is not an object clone. * * @param source the source interaction. * @return a target interaction which is a copy of the source interaction but the participants or * inferredInteractions. */ protected Interaction copyInteraction(Interaction source) { Interaction target = new Interaction(); // clone inner attributes target.setId(source.getId()); target.setImexId(source.getImexId()); // objects target.setNames(source.getNames()); target.setXref(source.getXref()); // collections target.getConfidences().addAll(source.getConfidences()); target.getExperiments().addAll(source.getExperiments()); target.getInteractionTypes().addAll(source.getInteractionTypes()); // added with mitab 27 target.setModelled(source.isModelled()); target.setIntraMolecular(source.isIntraMolecular()); target.setNegative(source.isNegative()); target.getParameters().addAll(source.getParameters()); target.getAttributes().addAll(source.getAttributes()); target.setAvailability(source.getAvailability()); return target; }
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()); } } } }
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; }
jInteraction.setId( mInteraction.getId() ); jInteraction.setImexId( mInteraction.getImexId() ); if ( mInteraction.hasNames() ) { jInteraction.setNames( namesConverter.toJaxb( mInteraction.getNames() ) ); if ( mInteraction.hasXref() ) { jInteraction.setXref( xrefConverter.toJaxb( mInteraction.getXref() ) ); if ( mInteraction.hasAvailability() ) { jInteraction.setAvailability( availabilityConverter.toJaxb( mInteraction.getAvailability() ) ); mInteraction.hasExperimentRefs() ) { if ( jInteraction.getExperimentList() == null ) { jInteraction.setExperimentList( new ExperimentList() ); for ( ExperimentRef mExperiment : mInteraction.getExperimentRefs() ) { if( ! ids.contains( mExperiment.getRef() ) ) { ids.add( mExperiment.getRef() ); for ( ExperimentDescription mExperiment : mInteraction.getExperiments() ) { final psidev.psi.mi.xml254.jaxb.ExperimentDescription exp = experimentDescriptionConverter.toJaxb( mExperiment ); if ( mInteraction.getParticipants() != null ) { if ( jInteraction.getParticipantList() == null ) { jInteraction.setParticipantList( new ParticipantList() ); for ( Participant mParticipant : mInteraction.getParticipants() ) { jInteraction.getParticipantList().getParticipants().add( participantConverter.toJaxb( mParticipant ) );
psidev.psi.mi.xml.model.Interaction mInteraction = new psidev.psi.mi.xml.model.Interaction(); mInteraction.setId( jInteraction.getId() ); mInteraction.setImexId( jInteraction.getImexId() ); mInteraction.setNames( namesConverter.fromJaxb( jInteraction.getNames() ) ); mInteraction.setXref( xrefConverter.fromJaxb( jInteraction.getXref() ) ); mInteraction.setAvailability( availabilityConverter.fromJaxb( jInteraction.getAvailability() ) ); mInteraction.getExperimentRefs().add( experimentRef ); } else { mInteraction.getExperiments().add( mExperiment ); for ( psidev.psi.mi.xml254.jaxb.Participant jParticipant : jInteraction.getParticipantList().getParticipants() ) { Participant participant = participantConverter.fromJaxb( jParticipant ); mInteraction.getParticipants().add( participant ); for ( psidev.psi.mi.xml254.jaxb.InferredInteraction jInferredInteraction : jInteraction.getInferredInteractionList().getInferredInteractions() ) { mInteraction.getInferredInteractions().add( inferredInteractionConverter.fromJaxb( jInferredInteraction ) ); mInteraction.getInteractionTypes().add( cvTypeConverter.fromJaxb( jIntereractionType, InteractionType.class ) ); mInteraction.setModelled( jInteraction.isModelled() ); } else {
if (interaction.getParticipants().size() > 2) { log.error("interaction (id:" + interaction.getId() + ") could not be converted to MITAB25 as it does not have exactly 1 or 2 participants."); return null; if (interaction.getParticipants().size() == 1 && interaction.isIntraMolecular()) { Iterator<Participant> pi = interaction.getParticipants().iterator(); pA = pi.next(); interactorA = getInteractorConverter().toMitab(pA); } else if (interaction.getParticipants().size() == 1 && !interaction.isIntraMolecular()) { Iterator<Participant> pi = interaction.getParticipants().iterator(); pA = pi.next(); pB = pA; Iterator<Participant> pi = interaction.getParticipants().iterator(); pA = pi.next(); pB = pi.next(); if (interaction.hasXref()) { Collection<DbReference> sourceRefs = XrefUtils.searchByType(interaction.getXref(), "source reference", "MI:0685"); for (Attribute attr : interaction.getAttributes()) { if ("source reference:label".equals(attr.getName())) { text = attr.getValue(); if (interaction.hasXref()) { Collection<DbReference> interactionAcs = XrefUtils.searchByType(interaction.getXref(), IDENTITY, IDENTITY_REF);
if (interaction.hasNames()) { Names names = interaction.getNames(); name = (names.hasFullName()) ? names.getFullName() : ""; shortName = (names.hasShortLabel()) ? names.getShortLabel() : ""; if (interaction.hasInteractionTypes()) { for(CvType interactionType : interaction.getInteractionTypes()) { if (interaction.hasExperiments()) { bpEvidences = createBiopaxEvidences(interaction); for(Participant p : interaction.getParticipants()) { if(p.hasInteractor()) { String type = getName(p.getInteractor().getInteractorType().getNames()); LOG.warn("Interaction: " + interaction.getId() + ", name(s): " + shortName + " " + name + "; has both 'gene' and physical entity type participants: " + participantTypes + "; 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()); for (Participant participant : interaction.getParticipants()) { if (interaction.hasAttributes()) { for (Attribute attribute : interaction.getAttributes()) { bpInteraction = createComplex(bpParticipants, interaction.getImexId(), interaction.getId()); } else if(isGeneticInteraction) {
Interaction interaction = new psidev.psi.mi.xml.model.Interaction(); interaction.setId(IdentifierGenerator.getInstance().nextId()); interaction.setXref(xref); if (interaction.getXref() == null) { interaction.setXref(new Xref(sourceReference)); } else { interaction.getXref().getSecondaryRef().add(sourceReference); interaction.getParticipants().add(participant); numberOfInteraction++; interactionName.setShortLabel(shortLabel); interaction.setNames(interactionName); interaction.getInteractionTypes().addAll(getInteractionTypes(binaryInteraction)); interaction.getExperiments().add(experimentDescription); interaction.getConfidences().add(confidence); if (interaction.getXref() == null) { interaction.setXref(new Xref()); interaction.getXref().getSecondaryRef().addAll(secondaryRefs); for (Annotation annotation : annotations) {
interaction.setImexId(imexXref.getPrimaryId()); ExperimentDescription expDescription = experimentConverter.intactToPsi(exp); if( ConverterContext.getInstance().isGenerateExpandedXml() ) { interaction.getExperiments().add(expDescription); } else { interaction.getExperimentRefs().add(new ExperimentRef(expDescription.getId())); interaction.getParticipants().add(participant); InferredInteraction iTestInteraction = new InferredInteraction(Arrays.asList(iParticipantSecond, iParticipantFirst)); if(!(interaction.getInferredInteractions().contains(iInteraction) || interaction.getInferredInteractions().contains(iTestInteraction))){ interaction.getInferredInteractions().add(iInteraction); interaction.getInteractionTypes().add(interactionType); interaction.getConfidences().add( confidence); if (!interaction.getAttributes().contains(authConf)){ interaction.getAttributes().add(authConf); interaction.getParameters().add(parameter); Component c = intactObject.getComponents().iterator().next(); if (c.getStoichiometry() == 1f || (c.getStoichiometry() == 0 && containsRole(c.getExperimentalRoles(), new String[]{CvExperimentalRole.SELF_PSI_REF, PUTATIVE_SELF_PSI_REF}))){ interaction.setIntraMolecular(true);
if ( interaction.hasExperimentRefs() ) { for ( Iterator<ExperimentRef> itex = interaction.getExperimentRefs().iterator(); itex.hasNext(); ) { ExperimentRef eref = itex.next(); throw new PsimiXmlReaderException("The interaction "+interaction.getId()+" refers to the experiment " + eref.getRef() + " but this experiment cannot be found by the parser." + " Please check that you are not mixing the expanded PSI xml schema and the compact PSI xml schema together. Either all the experiments are described at the beginning of the file and" + " all the interactions then use references to pre-declared experiments or all the experiments are only described at the level of the interactions and no experiment reference can be used."); interaction.getExperiments().add( ed ); for ( Participant p : interaction.getParticipants() ) { resolveReferences( file, p , interaction); if ( interaction.hasInferredInteractions() ) { for ( InferredInteraction ii : interaction.getInferredInteractions() ) { if ( ii.hasExperimentRefs() ) { for ( Iterator<ExperimentRef> itex = ii.getExperimentRefs().iterator(); itex.hasNext(); ) { ExperimentRef eref = itex.next(); if( ! interaction.getExperiments().isEmpty() ) { ExperimentDescription ed = findExperimentDescriptionInInteraction(eref, interaction); }else { throw new PsimiXmlReaderException( "An interaction (id="+ interaction.getId()+") contains an inferredInteraction which refers to experiment ref "+ eref.getRef() +"," + "however, this experiment isn't defined in this interaction." + " This is not a supported use of the PSI-MI XML format." ); ExperimentDescription ed = getExperimentById( file, eref.getRef() ); if (ed == null){
IntactConverterUtils.populateNames(psiObject.getNames(), interaction, aliasConverter); IntactConverterUtils.populateXref(psiObject.getXref(), interaction, xrefConverter); IntactConverterUtils.populateAnnotations(psiObject, interaction, getInstitution(), annotationConverter); String imexId = psiObject.getImexId(); if (imexId != null && !alreadyContainsImexXref(interaction)) { final InteractorXref imexXref = createImexXref(interaction, imexId); for (psidev.psi.mi.xml.model.Confidence psiConfidence : psiObject.getConfidences()){ Confidence confidence = confConverter.psiToIntact( psiConfidence ); for (psidev.psi.mi.xml.model.Parameter psiParameter : psiObject.getParameters()){ InteractionParameter parameter = paramConverter.psiToIntact( psiParameter ); interaction.addParameter(parameter); if( psiObject.isNegative() ) { interaction.addAnnotation( new Annotation( getInstitution(), new CvTopic( getInstitution(), NEGATIVE ), if( psiObject.isIntraMolecular() ) { interaction.addAnnotation( new Annotation( getInstitution(), new CvTopic( getInstitution(), INTRA_MOLECULAR ), if( psiObject.isModelled() ) { interaction.addAnnotation( new Annotation( getInstitution(), new CvTopic( getInstitution(), MODELLED ), throw new PsiConversionException("Problem converting PSI interaction to Intact: "+psiObject.getNames(), t);
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; }
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); } }
Collection<Interaction> interactions = new ArrayList<Interaction>(); if (interaction.getParticipants().isEmpty()) { return interactions; log.debug("interaction " + interaction.getId() + "/" + interaction.getImexId() + " was binary or intra molecular, no further processing involved."); interactions.add(interaction); log.debug("interaction " + interaction.getId() + "/" + interaction.getImexId() + " was inter molecular, reset stoichiometry of one of interactors"); interactions.add(interaction); } else { Participant[] participants = interaction.getParticipants().toArray( new Participant[]{ } ); log.debug( participants.length + " participant(s) found." );
/** * 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; }
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()); }
private Set<Evidence> createBiopaxEvidences(Interaction interaction) { Set<Evidence> evidences = new HashSet<Evidence>(); for (ExperimentDescription experimentDescription : interaction.getExperiments()) { interaction.getImexId(), interaction.getId(), experimentDescription.getId());
System.out.println( interaction.getNames().getShortLabel() ); for ( Participant participant : interaction.getParticipants() ) {
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(); }