/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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; }
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); } }
log.debug(experiment.getShortLabel() + " was NOT accepted."); } else { log.debug(experiment.getShortLabel() + " was accepted.");
@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(); } }
@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(); } }
@Override public String toString() { StringBuffer result = new StringBuffer( 128 ); 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 ); // TODO in experiments with many interactions this can throw OutOfMemoryErrors // result.append( "Interactions (" ); // if( null != getInteractions() ) { // for( Iterator iterator = interactions.iterator(); iterator.hasNext(); ) { // Interaction interaction = (Interaction) iterator.next(); // result.append( interaction.getShortLabel() ).append( ", " ); // } // } // result.append( ')' ); // result.append( NEW_LINE ); result.append( ']' ); return result.toString(); }
@PrePersist public void synchronizeShortLabel() { if( IntactContext.currentInstanceExists() ) { if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateExperimentLabel() ) { String shortLabel = getShortLabel(); String newShortLabel = shortLabel; try { newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel, ExperimentUtils.getPubmedId( this )); } catch (Exception e) { log.error("Exception synchronizing the label, probably due to an invalid format: "+newShortLabel, e); } if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); setShortLabel(newShortLabel); } } } else { log.warn( "There is no IntAct Context initialized, skipping experiment shortlabel synchronization." ); } }
@PrePersist public void synchronizeShortLabel() { if( IntactContext.currentInstanceExists() ) { if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateExperimentLabel() ) { String shortLabel = getShortLabel(); String newShortLabel = shortLabel; try { newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel, ExperimentUtils.getPubmedId( this )); } catch (Exception e) { log.error("Exception synchronizing the label, probably due to an invalid format: "+newShortLabel, e); } if (!shortLabel.equals(newShortLabel)) { if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" ); setShortLabel(newShortLabel); } } } else { log.warn( "There is no IntAct Context initialized, skipping experiment shortlabel synchronization." ); } }
public Set getPumedIds(Set experiments) { Set pubmeds = new HashSet(); for (Iterator iterator = experiments.iterator(); iterator.hasNext();) { Experiment experiment = (Experiment) iterator.next(); boolean found = false; for (Iterator iterator1 = experiment.getXrefs().iterator(); iterator1.hasNext() && !found;) { Xref xref = (Xref) iterator1.next(); if (getCvContext().getByMiRef(CvDatabase.class, CvDatabase.PUBMED_MI_REF).equals(xref.getCvDatabase()) && getCvContext().getByMiRef(CvXrefQualifier.class, CvXrefQualifier.PRIMARY_REFERENCE_MI_REF).equals(xref.getCvXrefQualifier())) { 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 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; }
protected Experiment fetchFromDataSource(Experiment intactObject) { return getIntactContext().getDataContext().getDaoFactory() .getExperimentDao().getByShortLabel(intactObject.getShortLabel()); }
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); } } } }
/** * Add the dataset annotation for each experiment in the list * @param publications : the publications */ private void addDatasetToExperimentsAndPublication(List<Publication> publications) throws IOException, DatasetException { for (Publication p : publications){ if (!processedPublications.contains(p.getAc()) && isPublicationEligibleForDataset(p)){ processedPublications.add(p.getAc()); String pubId = p.getShortLabel(); // if publication has not been processed, we add the dataset to the publication if (this.listOfpublicationUpdated.add(pubId)){ Annotation annotation = createNewDataset(); log.info("Add dataset to " + p.getAc() + ": " + p.getShortLabel()); p.addAnnotation(annotation); for (Experiment exp : p.getExperiments()){ Annotation annotation2 = createNewDataset(); log.info("Add dataset to " + exp.getAc() + ": " + exp.getShortLabel()); exp.addAnnotation(annotation2); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(exp); } IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(p); } } } }
@Override protected void saveOrUpdateAttributes(Experiment intactObject) throws PersisterException { super.saveOrUpdateAttributes(intactObject); if (intactObject.getBioSource() != null) { BioSourcePersister.getInstance().saveOrUpdate(intactObject.getBioSource()); } if (intactObject.getCvInteraction() != null) { CvObjectPersister.getInstance().saveOrUpdate(intactObject.getCvInteraction()); } else { throw new NullPointerException("Experiment without CvInteraction: " + intactObject.getShortLabel()); } if (intactObject.getCvIdentification() != null) { CvObjectPersister.getInstance().saveOrUpdate(intactObject.getCvIdentification()); } if (intactObject.getPublication() != null) { PublicationPersister.getInstance().saveOrUpdate(intactObject.getPublication()); } for (Interaction interaction : intactObject.getInteractions()) { InteractionPersister.getInstance().saveOrUpdate(interaction); } }
/** * 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; }
/** * 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; }
/** * 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; }