target.setCreatedDate(source.getCreatedDate()); target.setShortName(source.getShortName()); target.setInteractionType(source.getInteractionType()); target.setUpdatedDate(source.getUpdatedDate()); target.getAnnotations().clear(); target.getAnnotations().addAll(source.getAnnotations()); target.getChecksums().clear(); target.getChecksums().addAll(source.getChecksums()); target.getXrefs().clear(); target.getXrefs().addAll(source.getXrefs()); target.getIdentifiers().clear(); target.getIdentifiers().addAll(source.getIdentifiers()); target.getParticipants().clear(); if (!createNewParticipant){ target.getParticipants().addAll(source.getParticipants()); for (Object o : source.getParticipants()){ Participant p = (Participant)o; Participant clone = new DefaultParticipant(p.getInteractor()); ParticipantCloner.copyAndOverrideBasicParticipantProperties(p, clone, true); target.getParticipants().add(clone);
public void setInteractionAndAddParticipant(I interaction) { if (this.interaction != null){ this.interaction.removeParticipant(this); } if (interaction != null){ interaction.addParticipant(this); } }
/** * This method will copy basic properties from the Interaction source in the complex target. * It will erase existing annotations, xrefs, checksums and identifiers * This method does not copy the participants of the source * @param source * @param target */ public static void copyAndOverrideBasicComplexPropertiesWithInteractionProperties(Interaction source, Complex target){ if (source != null && target != null){ target.setInteractionType(source.getInteractionType()); target.setCreatedDate(source.getCreatedDate()); target.setUpdatedDate(source.getUpdatedDate()); if (source.getShortName() != null){ target.setShortName(source.getShortName()); } // copy collections target.getAnnotations().clear(); target.getAnnotations().addAll(source.getAnnotations()); target.getXrefs().clear(); target.getXrefs().addAll(source.getXrefs()); target.getIdentifiers().clear(); target.getIdentifiers().addAll(source.getIdentifiers()); target.getChecksums().clear(); target.getChecksums().addAll(source.getChecksums()); } }
CvTerm type1 = interaction1.getInteractionType(); CvTerm type2 = interaction2.getInteractionType(); String rigid1 = interaction1.getRigid(); String rigid2 = interaction2.getRigid(); if (rigid1 != null && rigid2 != null){ if (!rigid1.equals(rigid2)){ if (!interaction1.getIdentifiers().isEmpty() && !interaction2.getIdentifiers().isEmpty()){ return ComparatorUtils.findAtLeastOneMatchingIdentifier(interaction1.getIdentifiers(), interaction2.getIdentifiers()); String shortname1 = interaction1.getShortName(); String shortname2 = interaction2.getShortName(); if (shortname1 != null && shortname2 != null){ return shortname1.equals(shortname2);
getParserListener().onSeveralCvTermsFound(interactionType, interactionType.iterator().next(), interactionType.size()+" interaction types found. Only the first one will be loaded."); interaction.setInteractionType(interactionType.iterator().next()); interaction.setInteractionType(interactionType.iterator().next()); interaction.getXrefs().addAll(xrefI); interaction.getAnnotations().addAll(annotI); getParserListener().onSeveralCreatedDateFound(created); interaction.setCreatedDate(created.iterator().next().getDate()); interaction.setCreatedDate(created.iterator().next().getDate()); getParserListener().onSeveralUpdatedDateFound(update); interaction.setUpdatedDate(update.iterator().next().getDate()); interaction.setUpdatedDate(update.iterator().next().getDate()); interaction.getChecksums().addAll(checksumI);
/** * By default, a complex expansion can only expand interactions having at least one participant and where the provided interaction is * not null. * @param interaction : the interaction we want to expand * @return true if this complex expansion method can expand such an interaction, false otherwise. */ public boolean isInteractionExpandable(T interaction) { if (interaction == null || interaction.getParticipants().isEmpty()){ return false; } return true; }
public void write(I object) throws IOException { Xref preferredIdentifier = !object.getIdentifiers().isEmpty() ? (Xref)object.getIdentifiers().iterator().next() : null; String[] keyValues = generateInteractionIdentifier(object, preferredIdentifier); String id = null; if (object.getInteractionType() != null){ MIJsonUtils.writeSeparator(writer); MIJsonUtils.writePropertyKey("interactionType", writer); getCvWriter().write(object.getInteractionType()); MIJsonUtils.writeOpenArray(writer); Iterator<Participant> participantIterator = object.getParticipants().iterator(); while (participantIterator.hasNext()){ getParticipantWriter().write(participantIterator.next());
protected void initialiseInteractionIdentifiers(Collection<MitabXref> interactionIds, T interaction){ Iterator<MitabXref> refsIterator = interactionIds.iterator(); while (refsIterator.hasNext()){ MitabXref ref = refsIterator.next(); if (XrefUtils.isXrefFromDatabase(ref, Xref.IMEX_MI, Xref.IMEX) && XrefUtils.doesXrefHaveQualifier(ref, Xref.IMEX_PRIMARY_MI, Xref.IMEX_PRIMARY)){ interaction.getXrefs().add(ref); } else if (XrefUtils.isXrefFromDatabase(ref, Checksum.RIGID_MI, Checksum.RIGID) || XrefUtils.isXrefFromDatabase(ref, null, Checksum.IRIGID)){ createChecksumFromId(interaction, ref); } else{ interaction.getIdentifiers().add(ref); } } }
else if (interaction.getInteractionType() != null){ sentence = new Sentence(interaction.getInteractionType(), extractInteractionDetectionMethodFrom(interaction)); for (Object obj : interaction.getParticipants()) { Participant component = (Participant)obj; if (targetMi.contains(component.getBiologicalRole() sentence.addInteractionAc(interaction instanceof IntactPrimaryObject ? ((IntactPrimaryObject)interaction).getAc() : interaction.getShortName());
public Collection<Xref> getIdentifiers() { return wrappedInteraction.getIdentifiers(); }
protected void buildInteractionkey(I interaction) { this.stringBuilder.setLength(0); this.interactorAcs.clear(); // read ordered set of interactor acs for (Object obj : interaction.getParticipants()) { Participant component = (Participant)obj; interactorAcs.add(component.getInteractor() instanceof IntactInteractor ? ((IntactInteractor) component.getInteractor()).getAc() : component.getInteractor().getShortName()); } for (String prL : interactorAcs) { stringBuilder.append(" "); stringBuilder.append(prL); } // interaction type stringBuilder.append(interaction.getInteractionType().getMIIdentifier()); // experiment CvTerm method = extractInteractionDetectionMethodFrom(interaction); if (method != null) { stringBuilder.append(" "); stringBuilder.append(method.getMIIdentifier()); } }
/** * * @param interaction : the interaction to wrap */ public AbstractBinaryInteractionWrapper(I interaction){ if (interaction == null){ throw new IllegalArgumentException("The wrappedInteraction of a AbstractBinaryInteractionWrapper cannot be null"); } if (interaction.getParticipants().size() > 2){ throw new IllegalArgumentException("The wrappedInteraction of a AbstractBinaryInteractionWrapper cannot have more than two participants"); } this.wrappedInteraction = interaction; Annotation annot = InteractionUtils.collectComplexExpansionMethodFromAnnotations(interaction.getAnnotations()); this.annotations = new AnnotationList(); ((AnnotationList)this.annotations).addAllOnly(interaction.getAnnotations()); if (annot != null){ this.complexExpansion = annot.getTopic(); ((AnnotationList)this.annotations).removeOnly(complexExpansion); } }
public CvTerm getInteractionType() { return wrappedInteraction.getInteractionType(); }
public Collection<Xref> getXrefs() { return wrappedInteraction.getXrefs(); }
public String getShortName() { return wrappedInteraction.getShortName(); }
public Collection<Checksum> getChecksums() { return wrappedInteraction.getChecksums(); }
public void setInteractionType(CvTerm term) { wrappedInteraction.setInteractionType(term); }
public void setCreatedDate(Date created) { wrappedInteraction.setCreatedDate(created); }
protected void addParticipant(Participant participant, Interaction interaction) { interaction.addParticipant(participant); }
protected void initialiseExpansionMethod(Collection<MitabCvTerm> expansion, T interaction){ if (expansion.size() > 1){ if (getParserListener() != null){ getParserListener().onSeveralCvTermsFound(expansion, expansion.iterator().next(), expansion.size()+" complex expansions found. Only the first one will be loaded."); } interaction.getAnnotations().add(new MitabAnnotation(expansion.iterator().next())); } else if (!expansion.isEmpty()){ interaction.getAnnotations().add(new MitabAnnotation(expansion.iterator().next())); } }