/** * 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(); }
public void processExperimentParticipantIdentificationMethods(Interaction interaction, Interactor interactor){ if (interaction != null){ for (Experiment exp : interaction.getExperiments()){ this.experimentConverter.addParticipantDetectionMethodForInteractor(exp, interactor); } } }
/** * Convenience method to get the experiments - delegates the logic to the interactions * * @return Experiments */ public Collection<Experiment> getExperiments() { if (experiments != null) { return experiments; } experiments = new HashSet<Experiment>(); for (Interaction interaction : getInteractions()) { experiments.addAll(interaction.getExperiments()); } return experiments; }
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); } }
public Collection<GeneralMessage> check( Interaction interaction ) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); final Collection<Experiment> experiments = interaction.getExperiments(); if ( experiments == null ) { messages.add( new GeneralMessage( MessageDefinition.INTERACTION_WITHOUT_EXPERIMENT, interaction ) ); } else if ( experiments.size() > 1 ) { messages.add( new GeneralMessage( MessageDefinition.INTERACTION_WITH_MANY_EXPERIMENTS, interaction ) ); } else if ( experiments.isEmpty() ) { messages.add( new GeneralMessage( MessageDefinition.INTERACTION_WITHOUT_EXPERIMENT, interaction ) ); } return messages; } }
private boolean isNegative(Interaction interaction) { boolean negative = false; if (super.isNegative(interaction)) { negative = true; } else { //check its experiments for (Iterator iterator = interaction.getExperiments().iterator(); iterator.hasNext() && !negative;) { Experiment experiment = (Experiment) iterator.next(); if (isNegative(experiment)) { negative = true; } } } return negative; }
private boolean isNegative(Interaction interaction) { boolean negative = false; if (super.isNegative(interaction)) { negative = true; } else { //check its experiments for (Iterator iterator = interaction.getExperiments().iterator(); iterator.hasNext() && !negative;) { Experiment experiment = (Experiment) iterator.next(); if (isNegative(experiment)) { negative = true; } } } return negative; }
protected void saveOrUpdateExperiments(Interaction intactObject) throws PersisterException { for (Experiment experiment : intactObject.getExperiments()) { ExperimentPersister.getInstance().saveOrUpdate(experiment); } }
/**************************/ // is for find the ontology term for a specific interaction. Needs to take the host organism coming from experiment public OntologyTerm findOrganism(Interaction interaction) throws SolrServerException { // get BioSource information from interaction Collection<Experiment> exps = interaction.getExperiments(); if (exps.isEmpty()){ return null; } // TODO what do we do when we have several experiments? Experiment experiment = exps.iterator().next(); BioSource biosource = experiment.getBioSource(); // return an OntologyTerm using tax id and short label return biosource != null ? findOntologyTerm(biosource.getTaxId(), biosource.getShortLabel()) : null ; }
/** * 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; }
/** * 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; }
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()); } }
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 ); } }
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 }
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 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); } } } }
protected void traverseInteraction(Interaction interaction, IntactVisitor ... visitors) { if (interaction == null) return; for (IntactVisitor visitor : visitors) { visitor.visitInteraction(interaction); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(interaction)) { return; } traverse(interaction.getCvInteractionType(), visitors); traverse(interaction.getExperiments(), visitors); traverse(interaction.getComponents(), visitors); traverse(interaction.getConfidences(), visitors); traverse(interaction.getParameters(), visitors); }
protected void traverseInteraction(Interaction interaction, IntactVisitor ... visitors) { if (interaction == null) return; for (IntactVisitor visitor : visitors) { visitor.visitInteraction(interaction); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(interaction)) { return; } traverse(interaction.getCvInteractionType(), visitors); traverse(interaction.getExperiments(), visitors); traverse(interaction.getComponents(), visitors); traverse(interaction.getConfidences(), visitors); traverse(interaction.getParameters(), visitors); }
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()); }