/** * Builds a SHALLOW copy of the Experiment parameter. This means that a new Experiment instance is returned, but you * should be aware that the object references it contains <b>point to the objects referenced in the original object * </b>. * * @param experiment The Experiment you want a shallow copy of * * @return Experiment a new Experiment instance containing new references to the parameter object's attributes. * * @throws NullPointerException thrown if required items are not present in the parameter Experiment instance. */ public static Experiment getShallowCopy( Experiment experiment ) { Experiment ex = new Experiment( experiment.getOwner(), experiment.getShortLabel(), experiment.getBioSource() ); ex.ac = ( experiment.getAc() ); ex.setAnnotations( experiment.getAnnotations() ); ex.setCvInteraction( experiment.getCvInteraction() ); ex.setCvIdentification( experiment.getCvIdentification() ); ex.setFullName( experiment.getFullName() ); ex.setRelatedExperiment( experiment.getRelatedExperiment() ); ex.setXrefs( experiment.getXrefs() ); ex.setPublication( experiment.getPublication() ); return ex; }
private void synchronizeExperiment( Experiment experiment, boolean synchronizeAnnotatedAttributes ) { experiment.setPublication( synchronize( experiment.getPublication() ) ); if (IntactCore.isInitializedAndDirty(experiment.getInteractions())){ Collection<Interaction> interactions = synchronizeCollection(experiment.getInteractions()); experiment.getInteractions().clear(); experiment.getInteractions().addAll(interactions); } experiment.setCvIdentification(synchronize(experiment.getCvIdentification())); experiment.setCvInteraction( synchronize( experiment.getCvInteraction() ) ); experiment.setBioSource( synchronize( experiment.getBioSource() ) ); if (synchronizeAnnotatedAttributes){ synchronizeAnnotatedObjectCommons( experiment ); } }
public Experiment createExperimentEmpty(String shortLabel) { Experiment experiment = new Experiment(getInstitution(), shortLabel, createBioSourceRandom()); experiment.setCvInteraction(createCvObject(CvInteraction.class, CvInteraction.COSEDIMENTATION_MI_REF, CvInteraction.COSEDIMENTATION)); experiment.setCvIdentification(createCvObject(CvIdentification.class, CvIdentification.PREDETERMINED_MI_REF, CvIdentification.PREDETERMINED)); experiment.setPublication(createPublicationRandom()); experiment.addXref(createPrimaryReferenceXref(experiment, experiment.getPublication().getShortLabel())); return experiment; }
public void addExperiment( Experiment experiment ) { if ( experiment == null ) { throw new NullPointerException( "experiment must not be null." ); } if ( !experiments.contains( experiment ) ) { if ( experiment.getPublication() != this ) { throw new IllegalStateException( "You cannot overwrite an Experiment's publication (experiment:"+ experiment.getAc() +"). " + "You must first unlink the underlying experiments from their publication" ); } else { experiment.setPublication( this ); } experiments.add( experiment ); } }
protected void traverseExperiment(Experiment experiment, IntactVisitor ... visitors) { if (experiment == null) return; for (IntactVisitor visitor : visitors) { visitor.visitExperiment(experiment); } // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(experiment)) { return; } traverse(experiment.getCvIdentification(), visitors); traverse(experiment.getCvInteraction(), visitors); traverse(experiment.getBioSource(), visitors); traverse(experiment.getPublication(), visitors); traverse(experiment.getInteractions(), visitors); }
sb.append(experiment.getShortLabel()); sb.append(createUniquenessString(experiment.getCvIdentification())); sb.append(createUniquenessString(experiment.getCvInteraction())); sb.append(createUniquenessString(experiment.getBioSource())); experiment.getAnnotations().clear(); experiment.getAnnotations().addAll(annotations);
out.write( i + "<entry id=\"" + experiment.getAc() + "\">" + NEW_LINE ); out.write( ii + "<name>" + experiment.getShortLabel() + "</name>" + NEW_LINE ); if ( experiment.getFullName() != null ) { out.write( ii +"<description>" + escapeXml( experiment.getFullName() ) + "</description>" + NEW_LINE ); writeCreationDate( out, experiment.getCreated(), iii ); writeLastUpdateDate( out, experiment.getUpdated(), iii ); out.write( ii + "</dates>" + NEW_LINE ); boolean hasXrefs = !experiment.getXrefs().isEmpty(); boolean hasLinks = !experiment.getInteractions().isEmpty(); for ( Xref xref : experiment.getXrefs() ) { String db = xref.getCvDatabase().getShortLabel(); String id = xref.getPrimaryId(); for ( Interaction interaction : experiment.getInteractions() ) { for ( Alias alias : experiment.getAliases() ) { String aliasName = escapeXml( alias.getName() ); writeField( out, alias.getCvAliasType().getShortLabel(), aliasName, iii ); writeCvTerm( out, experiment.getCvInteraction(), iii ); writeCvTerm( out, experiment.getCvIdentification(), iii ); for ( Interaction interaction : experiment.getInteractions() ) { cvs.add( interaction.getCvInteractionType() );
experiment = new Experiment( institution, shortlabel, biosource ); experiment.setFullName( experimentDescription.getFullname() ); experiment.setCvIdentification( cvIdentification ); experiment.setCvInteraction( cvInteraction ); ControlledVocabularyRepository.getPrimaryXrefQualifier() ); experiment.addXref( primaryXref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( primaryXref ); ControlledVocabularyRepository.getSeeAlsoXrefQualifier() ); experiment.addXref( seeAlsoXref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( seeAlsoXref ); experiment.addAnnotation( annotation ); null ); experiment.addXref( xref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( xref ); cache.put( experiment.getShortLabel(), experiment );
@Override protected boolean update(Experiment candidateObject, Experiment objectToUpdate) throws PersisterException { for (Interaction interaction : candidateObject.getInteractions()) { objectToUpdate.getInteractions().add(interaction); if (objectToUpdate.getPublication() == null && candidateObject.getPublication() != null) { objectToUpdate.setPublication(candidateObject.getPublication()); PublicationPersister.getInstance().saveOrUpdate(candidateObject.getPublication()); Collection<ExperimentXref> objToUpdateXrefs = objectToUpdate.getXrefs(); for (ExperimentXref xref : candidateObject.getXrefs()) { if (!objToUpdateXrefs.contains(xref)) { objectToUpdate.addXref(xref); for (ExperimentAlias alias : candidateObject.getAliases()) { objectToUpdate.addAlias(alias);
@Override public String toString() { StringBuffer result = new StringBuffer( 512 ); result.append( "Experiment [AC: " + this.getAc() + " Shortlabel: " + getShortLabel() ); result.append( " BioSource: " + ( getBioSource() == null ? "-" : getBioSource().getShortLabel() ) ); result.append( NEW_LINE ); result.append( "CvIdentification: " + ( cvIdentification == null ? "-" : cvIdentification.getShortLabel() ) ); result.append( NEW_LINE ); result.append( "CvInteraction: " + ( cvInteraction == null ? "NOT SPECIFIED" : cvInteraction.getShortLabel() ) ); result.append( NEW_LINE ); result.append( ']' ); return result.toString(); } }
if (log.isInfoEnabled()) log.info("Updating experiment: "+experiment.getAc()+" ("+experiment.getShortLabel()+")"); experiment = getDataContext().getDaoFactory().getExperimentDao().getByAc(experiment.getAc()); experiment = getDataContext().getDaoFactory().getExperimentDao().getByAc(experiment.getAc()); Collection<ExperimentXref> xrefs = experiment.getXrefs(); for (Iterator<ExperimentXref> iterator = xrefs.iterator(); iterator.hasNext();) { ExperimentXref experimentXref = iterator.next(); ExperimentXref xref = new ExperimentXref(experiment.getOwner(), newt, bioSourceToAdd.getTaxId(), bioSourceToAdd.getLabel(), null, targetSpeciesQualifier); experiment.addXref(xref);
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); } } } }
public Experiment createExperimentEmpty(String shortLabel, String pubId) { Experiment experiment = new Experiment(getInstitution(), shortLabel, createBioSourceRandom()); experiment.setCvInteraction(createCvObject(CvInteraction.class, CvInteraction.COSEDIMENTATION_MI_REF, CvInteraction.COSEDIMENTATION)); experiment.setCvIdentification(createCvObject(CvIdentification.class, CvIdentification.PREDETERMINED_MI_REF, CvIdentification.PREDETERMINED)); Publication publication = createPublication(pubId); publication.addExperiment(experiment); experiment.addXref(createPrimaryReferenceXref(experiment, pubId)); return experiment; }
/** * Collects all Xref having a CvXrefQualifier( target-species ) linked to the given experiement. * * @param experiment * * @return a Collection of Xref. never null. */ public List<ExperimentXref> getTargetSpeciesXrefs( Experiment experiment ) { List<ExperimentXref> targets = new ArrayList<ExperimentXref>(); for ( ExperimentXref xref : experiment.getXrefs() ) { if ( targetSpeciesQualifier.equals( xref.getCvXrefQualifier() ) ) { targets.add( xref ); } } return targets; }
/** * Retrieves the interactions from an experiment, initializing them if necessary. * * @param experiment the experiment * @return The returned interactions are ensured to be initialized * @since 2.4.0 */ public static Collection<Interaction> ensureInitializedInteractions(Experiment experiment) { Collection<Interaction> interactions; if (IntactCore.isInitialized(experiment.getInteractions())) { interactions = experiment.getInteractions(); } else { interactions = IntactContext.getCurrentInstance().getDaoFactory().getInteractionDao().getByExperimentAc(experiment.getAc(), 0, Integer.MAX_VALUE); } return interactions; }
public Set<String> getPumedIds(Set<Experiment> experiments, final boolean stopOnceOneFound ) { Set<String> pubmeds = new HashSet<String>(); for ( Experiment experiment : experiments ) { boolean found = false; for (Iterator iterator1 = experiment.getXrefs().iterator(); iterator1.hasNext() && !found;) { Xref xref = (Xref) iterator1.next(); if (getPubmed().equals(xref.getCvDatabase()) && getPrimaryReference().equals(xref.getCvXrefQualifier())) { if( stopOnceOneFound ) { found = true; } pubmeds.add(xref.getPrimaryId()); } } // xref if (found == false) { getOut().println("ERROR: " + experiment.getShortLabel() + " " + CvDatabase.PUBMED + " has no (" + CvXrefQualifier.PRIMARY_REFERENCE + ") assigned."); } } // experiments return pubmeds; }
public void intactToMitab(Experiment exp, BinaryInteraction binary, boolean processParticipantDetMethod, boolean processPublication){ if (exp != null && binary != null){ // process publication Publication pub = exp.getPublication(); if (pub != null && processPublication){ publicationConverter.intactToMitab(pub, binary); } // convert interaction detection method if (exp.getCvInteraction() != null){ CrossReference detMethod = cvObjectConverter.toCrossReference(exp.getCvInteraction()); if (detMethod != null){ binary.getDetectionMethods().add(detMethod); } } // process organism if (exp.getBioSource() != null){ Organism organism = organismConverter.intactToMitab(exp.getBioSource()); if (organism != null){ binary.setHostOrganism(organism); } } // process participant detection method if (processParticipantDetMethod){ processParticipantDetectionMethod(exp, binary); } } }
/** * get the value what will be used as ID of the experiment. * * @param experiment the experiment for which we need an ID. * * @return the ID of the experiment. */ public String getExperimentId( Experiment experiment ) { // TODO test that. // TODO what if no AC available ? shortlabel (could be redondant) ? Object pointer/HashCode (will be unique in the scope of the document) ? return experiment.getAc(); } }
protected void updateShortLabel(Experiment experiment) { String shortLabel = experiment.getShortLabel(); String newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel); if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); experiment.setShortLabel(newShortLabel); } }
/** * Answers the following question: "Is the given shortlabel refering to a negative experiment ?". * * @param experimentLabel the experiment shortlabel. * * @return true if the label refers to a negative experiment, false otherwise. */ private boolean isNegative( String experimentLabel ) { for ( Experiment experiment : getNegativeExperiments() ) { if ( experiment.getShortLabel().equals( experimentLabel ) ) { return true; } } return false; }