if (isCollectionClonable(interaction.getComponents())) { Collection<Component> components = IntactCore.ensureInitializedParticipants(interaction); clone.getComponents().add(clonedComp); clone.setCvInteractionType(clone(interaction.getCvInteractionType())); clone.setCvInteractorType(clone(interaction.getCvInteractorType())); if (isCollectionClonable(interaction.getExperiments())) { Collection<Experiment> experiments = IntactCore.ensureInitializedExperiments(interaction); clone.addExperiment(clone(experiment)); clone.setKD(interaction.getKD()); clone.setCrc(interaction.getCrc()); if (isCollectionClonable(interaction.getConfidences())) { Collection<Confidence> confidences = IntactCore.ensureInitializedConfidences(interaction); clone.addConfidence(clone(confidence)); if (isCollectionClonable(interaction.getParameters())) { Collection<InteractionParameter> parameters = IntactCore.ensureInitializedInteractionParameters(interaction); clone.addParameter(clone(interactionParameter));
/** * 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; }
/****************************/ // enrich fields in the SolrDocument passed as parameter public void enrich ( Interaction interaction, SolrInputDocument solrDocument ) throws Exception { // check parameters and information if ( interaction == null ) { return ; } // Enrich interaction type enrichInteractionType(interaction.getCvInteractionType(), solrDocument) ; // Enrich Complex Organism fields enrichOrganism(interaction, solrDocument) ; // Enrich Complex Xref fields enrichInteractionXref(interaction.getXrefs(), solrDocument) ; }
public void onPrePersist(Interaction objToPersist) { String shortLabel = objToPersist.getShortLabel(); String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel); if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); objToPersist.setShortLabel(newShortLabel); } }
protected void syncExperiments(Interaction intactObject) { ExperimentPersister persister = ExperimentPersister.getInstance(); List<Experiment> experiments = new ArrayList<Experiment>(intactObject.getExperiments().size()); for (Experiment experiment : intactObject.getExperiments()) { Experiment exp = persister.syncIfTransient(experiment); experiments.add(exp); } intactObject.setExperiments(experiments); } }
protected void copyInteraction( Interaction source, Interaction target ) { copyProperty(source, "KD", target); copyProperty(source, "crc", target); copyProperty(source, "cvInteractionType", target); copyCollection( source.getComponents(), target.getComponents() ); copyCollection( source.getExperiments(), target.getExperiments() ); copyCollection( source.getConfidences(), target.getConfidences() ); copyCollection( source.getParameters(), target.getParameters() ); copyInteractorCommons( source, target ); // we have ommited CRC on purpose }
private void synchronizeInteraction( Interaction interaction, boolean synchronizeAnnotatedAttributes ) { interaction.setCvInteractionType( synchronize( interaction.getCvInteractionType() ) ); interaction.setCvInteractorType( synchronize( interaction.getCvInteractorType() ) ); if (IntactCore.isInitializedAndDirty(interaction.getComponents())){ Collection<Component> components = synchronizeCollection(interaction.getComponents()); interaction.getComponents().clear(); interaction.getComponents().addAll(components); } interaction.setBioSource( synchronize( interaction.getBioSource() ) ); if (IntactCore.isInitializedAndDirty(interaction.getExperiments())){ Collection<Experiment> experiment = synchronizeCollection(interaction.getExperiments()); interaction.getExperiments().clear(); interaction.getExperiments().addAll(experiment); } // cannot call setConfidences in interaction because of orphan relationship limitation if (IntactCore.isInitializedAndDirty(interaction.getConfidences())){ Collection<Confidence> confidences = synchronizeConfidences(interaction.getConfidences(), interaction); interaction.getConfidences().clear(); interaction.getConfidences().addAll(confidences); } // cannot call setParameters in interaction because of orphan relationship limitation if (IntactCore.isInitializedAndDirty(interaction.getParameters())){ Collection<InteractionParameter> interactionParameters = synchronizeInteractionParameters(interaction.getParameters(), interaction); interaction.getParameters().clear(); interaction.getParameters().addAll(interactionParameters); } if (synchronizeAnnotatedAttributes){ synchronizeAnnotatedObjectCommons( interaction ); } }
out.write( i + "<entry id=\"" + interaction.getAc() + "\">" + NEW_LINE ); out.write( ii + "<name>" + interaction.getShortLabel() + "</name>" + NEW_LINE ); if ( interaction.getFullName() != null ) { out.write( ii + "<description>" + escapeXml( interaction.getFullName() ) + "</description>" + NEW_LINE ); writeCreationDate( out, interaction.getCreated(), iii ); writeLastUpdateDate( out, interaction.getUpdated(), iii ); out.write( ii + "</dates>" + NEW_LINE ); boolean hasXrefs = !interaction.getXrefs().isEmpty(); boolean hasLinks = !interaction.getComponents().isEmpty(); for ( Xref xref : interaction.getXrefs() ) { String db = xref.getCvDatabase().getShortLabel(); String id = xref.getPrimaryId(); for ( Component c : interaction.getComponents() ) { for ( Experiment experiment : interaction.getExperiments() ) { experimentAcs.add( experiment.getAc() ); for ( Alias alias : interaction.getAliases() ) { String aliasName = escapeXml( alias.getName() ); writeField( out, alias.getCvAliasType().getShortLabel(), aliasName, iii ); writeCvTerm( out, interaction.getCvInteractionType(), iii ); for ( Experiment e : interaction.getExperiments() ) { cvs.add( e.getCvInteraction() );
for ( Iterator iterator = interaction.getXrefs().iterator(); iterator.hasNext() && imexId == null; ) { Xref xref = (Xref) iterator.next(); Collection experiments = interaction.getExperiments(); Element experimentList = session.getExperimentListElement(); Element localExperimentList = null; if ( !interaction.getComponents().isEmpty() ) { for ( Iterator iterator = interaction.getComponents().iterator(); iterator.hasNext(); ) { Component component = (Component) iterator.next(); HashSet inferedInteractions = new HashSet( 2 ); for ( Iterator iterator = interaction.getComponents().iterator(); iterator.hasNext(); ) { Component component = (Component) iterator.next(); for ( Iterator iterator2 = interaction.getExperiments().iterator(); iterator2.hasNext(); ) { Experiment experiment = (Experiment) iterator2.next(); if ( interaction.getCvInteractionType() != null ) { CvObject2xmlFactory.getInstance( session ).create( session, element, interaction.getCvInteractionType() );
if (interaction.getCvInteractionType() != null){ CrossReference type = cvObjectConverter.toCrossReference(interaction.getCvInteractionType()); if (!interaction.getConfidences().isEmpty()){ for (uk.ac.ebi.intact.model.Confidence conf : interaction.getConfidences()){ Confidence confField = confidenceConverter.intactToCalimocho(conf); if (interaction.getAc() != null){ CrossReference id = new CrossReferenceImpl(); id.setIdentifier(interaction.getAc()); for (Experiment exp : interaction.getExperiments()){ experimentConverter.intactToMitab(exp, binary, false, processPublicationDetails); Collection<InteractorXref> interactionRefs = interaction.getXrefs(); if (!interaction.getParameters().isEmpty()){ for (Parameter param : interaction.getParameters()){ psidev.psi.mi.tab.model.Parameter paramField = parameterConverter.intactToMitab(param); if (interaction.getCrc() != null){ Checksum crc = new ChecksumImpl(CRC, interaction.getCrc()); binary.getChecksums().add(crc); if (interaction.getUpdated() != null){ binary.getUpdateDate().add(interaction.getUpdated());
interaction.setOwner(getInstitution()); interaction.getExperiments().addAll(experiments); interaction.setCvInteractionType(interactionType); interaction.setCvInteractorType(interactorType); if (imexId != null && !alreadyContainsImexXref(interaction)) { final InteractorXref imexXref = createImexXref(interaction, imexId); interaction.addXref(imexXref); log.error("Interaction without any participants : " + interaction.getShortLabel()); interaction.getComponents().addAll(components); interaction.addConfidence( confidence); interaction.addParameter(parameter); interaction.addAnnotation( new Annotation( getInstitution(), new CvTopic( getInstitution(), NEGATIVE ), TRUE ) ); interaction.addAnnotation( new Annotation( getInstitution(), new CvTopic( getInstitution(), INTRA_MOLECULAR ), TRUE ) ); interaction.addAnnotation( new Annotation( getInstitution(),
List<Component> components = new ArrayList<Component>(interaction.getComponents()); Collections.sort(components, new ComponentComparator()); experiments.addAll(interaction.getExperiments()); sb.append(createUniquenessString(interaction.getCvInteractionType())); annotations.addAll(interaction.getAnnotations());
protected boolean isExpandableBasic(Interaction interaction) { if (interaction.getComponents().isEmpty()) { return false; } return true; }
private void updateExperimentParticipantDetectionMethod(Interaction interaction) { for (Experiment experiment : interaction.getExperiments()) { if (experiment.getCvIdentification() == null) { String partDetMethod = calculateParticipantDetMethod(interaction.getComponents()); if (partDetMethod != null) { final String message = "Experiment ("+ experiment.getShortLabel() +") without participant detection method. One was calculated from the components: " + partDetMethod; addMessageToContext(MessageLevel.INFO, message, true); if (log.isWarnEnabled()) { log.warn(message); } CvIdentification detMethod = CvObjectUtils.createCvObject(experiment.getOwner(), CvIdentification.class, partDetMethod, "undefined"); experiment.setCvIdentification(detMethod); } else { final String message = "Neither the Experiment nor its participants have CvIdentification (participant detection method). Using the term \"experimental particp\" (MI:0661)."; if (log.isWarnEnabled()) log.warn(": Experiment '"+experiment.getShortLabel()+ "', Interaction '"+interaction.getShortLabel()+"' - Location: "+ConverterContext.getInstance().getLocation().getCurrentLocation().pathFromRootAsString()); addMessageToContext(MessageLevel.WARN, message, true); CvIdentification detMethod = CvObjectUtils.createCvObject(experiment.getOwner(), CvIdentification.class, "MI:0661", "experimental particp"); experiment.setCvIdentification(detMethod); } } } }
if ( !cvInteractionType.equals( interaction.getCvInteractionType() ) ) { return false; if ( interaction.getCvInteractionType() != null ) { return false; if ( !kD.equals( interaction.getKD() ) ) { return false; if ( interaction.getKD() != null ) { return false; return CollectionUtils.isEqualCollection( getComponents(), interaction.getComponents() );
/** * This creates a stable (non-random) interaction */ public Interaction createDeterministicInteraction() { Interaction interaction = createInteraction("fooprey-barbait", createDeterministicProtein("A2", "barbait"), createDeterministicProtein("A1", "fooprey"), createDeterministicExperiment()); interaction.getAnnotations().add(createAnnotation("This is an annotation", CvTopic.COMMENT_MI_REF, CvTopic.COMMENT)); CvFeatureType featureType = createCvObject(CvFeatureType.class, CvFeatureType.EXPERIMENTAL_FEATURE_MI_REF, CvFeatureType.EXPERIMENTAL_FEATURE); Feature feature = createFeature("feature1", featureType); feature.setComponent(null); Range range = createRange(1, 1, 5, 5); feature.addRange(range); interaction.getComponents().iterator().next().addBindingDomain(feature); // interaction.getComponents().iterator().next().addComponentParameter(createDeterministicComponentParameter()); // interaction.addXref(createPrimaryReferenceXref( interaction , "testreference")); interaction.addConfidence( createDeterministicConfidence()); interaction.addParameter( createDeterministicInteractionParameter() ); return interaction; }
interaction.setBioSource( intactExperiment.getBioSource() ); interaction.setFullName( interactionTag.getFullname() ); interaction.setKD( kd ); interaction.addAnnotation( annotation ); interaction.addXref( xref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( xref ); interaction.addAnnotation( annotation );
/** * Used to create a unique chain of experiment labels, used to differenciate interactions * that could just have the same short label */ private String experimentLabels(Interaction interaction) { StringBuilder sb = new StringBuilder( interaction.getExperiments().size() * 21 ); // init to max size for (Experiment exp : interaction.getExperiments()) { sb.append( exp.getShortLabel() ).append( '_' ); } return sb.toString(); }
/** * 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 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; }