/** * 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); } } } }
public Publication clonePublication(Publication publication) throws IntactClonerException { if (publication == null) return null; Publication clone = new Publication(); clonerManager.addClone(publication, clone); if (isCollectionClonable(publication.getExperiments())) { Collection<Experiment> experiments = IntactCore.ensureInitializedExperiments(publication); for (Experiment e : experiments) { clone.addExperiment(clone(e)); } } if (isCollectionClonable(publication.getLifecycleEvents())) { Collection<LifecycleEvent> events = IntactCore.ensureInitializedLifecycleEvents(publication); for (LifecycleEvent event : events) { clone.addLifecycleEvent(clone(event)); } } clone.setStatus(clone(publication.getStatus())); clone.setCurrentOwner(clone(publication.getCurrentOwner())); clone.setCurrentReviewer(clone(publication.getCurrentReviewer())); return clone; }
/** * Equality for Experiments is currently based on equality for <code>AnnotatedObjects</code> and BioSources only. * * @param o The object to check * * @return true if the parameter equals this object, false otherwise * * @see AnnotatedObject */ @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } if ( !super.equals( o ) ) { return false; } final Experiment that = ( Experiment ) o; if ( !bioSource.equals( that.bioSource ) ) { return false; } if ( publication != null ? !publication.equals( that.publication ) : that.publication != null ) { return false; } return true; }
@Override protected Publication syncAttributes(Publication intactObject) { Collection<Experiment> experiments = new ArrayList<Experiment>( intactObject.getExperiments().size() ); for ( Experiment experiment : intactObject.getExperiments() ) { experiments.add( ExperimentPersister.getInstance().syncIfTransient( experiment ) ); } intactObject.setExperiments( experiments ); return super.syncAttributes( intactObject ); } }
private boolean isPublicationEligibleForDataset(Publication p){ // the publication is not excluded by the selector if (this.selector.getPublicationsIdToExclude().contains(p.getShortLabel())){ return false; } // all the experiments must contain less than 100 interactions for (Experiment exp : p.getExperiments()){ if (this.selector.getMaxNumberOfInteractionsPerExperiment() <= exp.getInteractions().size()){ return false; } } return true; }
private void synchronizePublication( Publication publication, boolean synchronizeAnnotatedAttributes ) { if (IntactCore.isInitializedAndDirty(publication.getExperiments())){ Collection<Experiment> experiments = synchronizeCollection(publication.getExperiments()); publication.getExperiments().clear(); publication.getExperiments().addAll(experiments); } publication.setStatus( synchronize( publication.getStatus() ) ); publication.setCurrentOwner( synchronizeUser(publication.getCurrentOwner()) ); publication.setCurrentReviewer( synchronizeUser(publication.getCurrentReviewer()) ); final List<LifecycleEvent> events = publication.getLifecycleEvents(); if (IntactCore.isInitializedAndDirty( events )){ Collection<LifecycleEvent> synchedEvents = new ArrayList<LifecycleEvent>( events.size() ); for ( LifecycleEvent event : events ) { synchedEvents.add( synchronizeEvent(event) ); } events.clear(); events.addAll( synchedEvents ); } if (synchronizeAnnotatedAttributes){ synchronizeAnnotatedObjectCommons( publication ); } }
log.info("Start processing publication : " + publication.getShortLabel()); if (publication.getExperiments().isEmpty()){ log.info("Skip publication " + publication.getShortLabel() + " because does not contain any experiments"); return null; Iterator<Experiment> iterator = publication.getExperiments().iterator(); createPublicationEntry(publicationEntries, publication.getCreated(), publication.getShortLabel(), this.currentNegativeStringBuilder, true); createPublicationEntry(publicationEntries, publication.getCreated(), publication.getShortLabel(), this.currentStringBuilder, false);
public static boolean isToBeReviewed(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.TO_BE_REVIEWED.equals(a.getCvTopic().getShortLabel())) { return true; } } for (Experiment experiment : publication.getExperiments()) { if (ExperimentUtils.isToBeReviewed(experiment)) { return true; } } return false; }
/** * Finds a publication based on its properties. * * @param publication the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForPublication( Publication publication ) { // TODO add primary-reference first, then shortlabel Query query = getEntityManager().createQuery( "select pub.ac from Publication pub where pub.shortLabel = :shortLabel" ); query.setParameter( "shortLabel", publication.getShortLabel() ); return getFirstAcForQuery( query, publication ); }
if (!isBibRefSet && publication.getXrefs().isEmpty() && publication.getShortLabel() != null){ Xref xref = new Xref(); xref.setPrimaryRef(new DbReference(CvDatabase.PUBMED, CvDatabase.PUBMED_MI_REF, publication.getShortLabel(), CvXrefQualifier.PRIMARY_REFERENCE, CvXrefQualifier.PRIMARY_REFERENCE_MI_REF)); bibref.setXref(xref); isBibRefSet = true; else if (!isBibRefSet && publication.getXrefs().isEmpty() && !publication.getAnnotations().isEmpty()){ PsiConverterUtils.populateAttributes( publication, bibref, annotationConverter ); else if (!isBibRefSet && !publication.getXrefs().isEmpty()){ PsiConverterUtils.populateXref(publication, bibref, publicationXrefConverter);
public GeneratedEntry addPublication(Publication publication) { if (publication != null) { for (Experiment experiment : publication.getExperiments()) { addExperiment(experiment); } } else { throw new IntactException("No publication is null"); } return this; }
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)); final Publication publication = createPublicationRandom(); experiment.setPublication(publication); publication.addExperiment(experiment); experiment.addXref(createPrimaryReferenceXref(experiment, experiment.getPublication().getShortLabel())); return experiment; }
public static boolean isAccepted(Publication publication) { if (publication == null) { throw new NullPointerException("You must give a non null publication"); } if (publication.getStatus() != null) { final String statusId = publication.getStatus().getIdentifier(); return CvPublicationStatusType.ACCEPTED.identifier().equals(statusId) || CvPublicationStatusType.ACCEPTED_ON_HOLD.identifier().equals(statusId) || CvPublicationStatusType.READY_FOR_RELEASE.identifier().equals(statusId) || CvPublicationStatusType.RELEASED.identifier().equals(statusId); } for (Annotation a : publication.getAnnotations()) { if (a.getCvTopic() != null && CvTopic.ACCEPTED.equals(a.getCvTopic().getShortLabel())) { return true; } } return ExperimentUtils.areAllAccepted(publication.getExperiments()); }
/** * Retrieves the experiment from a publication, initializing them if necessary. * * @param publication the publication * @return The returned experiments are ensured to be initialized * @since 2.4.0 */ public static Collection<Experiment> ensureInitializedExperiments(Publication publication) { Collection<Experiment> experiments; if (IntactCore.isInitialized(publication.getExperiments())) { experiments = publication.getExperiments(); } else { experiments = IntactContext.getCurrentInstance().getDaoFactory().getExperimentDao().getByPubAc(publication.getAc()); } return experiments; }
protected void copyPublication( Publication source, Publication target ) { copyCollection( source.getExperiments(), target.getExperiments() ); copyCollection( source.getLifecycleEvents(), target.getLifecycleEvents() ); copyProperty(source, "currentOwner", target); copyProperty(source, "currentReviewer", target); copyProperty(source, "publicationId", target); copyProperty(source, "status", target); }
public void addLifecycleEvent( LifecycleEvent event ) { if( event.getPublication() != null && event.getPublication() != this ) { throw new IllegalArgumentException( "You are trying to add an event to publication "+ event.getPublication().getAc() +" that already belong to an other " + "publication " + getAc() ); } event.setPublication( this ); lifecycleEvents.add( event ); }
Collection<PublicationXref> pubRefs = pub.getXrefs(); Collection<Annotation> pubAnnotations = AnnotatedObjectUtils.getPublicAnnotations(pub); Institution institution = pub.getOwner(); if (pub.getCreated() != null){ binary.getCreationDate().add(pub.getCreated());
/** * Ensures that the lifecycle events are initialized. * @param publication The publication * @return the initialized events * @since 2.5.0 */ public static List<LifecycleEvent> ensureInitializedLifecycleEvents(Publication publication) { List<LifecycleEvent> events; if (IntactCore.isInitialized(publication.getLifecycleEvents())) { events = publication.getLifecycleEvents(); } else { events = IntactContext.getCurrentInstance().getDaoFactory().getLifecycleEventDao().getByPublicationAc(publication.getAc()); } return events; }
public void extractPublicationAnnotationsAndXrefsAbsentFromExperiment(Publication pub, ExperimentDescription expDesc, Experiment exp){ AnnotationConverterConfig configAnnotation = ConverterContext.getInstance().getAnnotationConfig(); if (pub.getAnnotations().isEmpty() && pub.getXrefs().isEmpty()){ return; for (Annotation attr : pub.getAnnotations()){ if (!configAnnotation.isExcluded(attr.getCvTopic())) { Attribute attribute = annotationConverter.intactToPsi(attr); if (!pub.getXrefs().isEmpty()){ Set<DbReference> convertedRefs = PsiConverterUtils.toDbReferences(pub.getXrefs(), publicationXrefConverter);
public Publication createPublication(String pmid) { Publication pub = new Publication(getInstitution(), pmid); return pub; }