Search in sources :

Example 11 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class ExpressionExperimentSetServiceImpl method initAutomaticallyGeneratedExperimentSet.

/**
 * Instantiate non-persistent experiment set with description = "Automatically generated for ## EEs.". Mostly for
 * use in Gene2GenePopulationServiceImpl.intializeNewAnalysis(Collection, Taxon, Collection,
 * String, int). By convention, these sets should not be modifiable.
 */
@Override
public ExpressionExperimentSet initAutomaticallyGeneratedExperimentSet(Collection<ExpressionExperiment> expressionExperiments, Taxon taxon) {
    ExpressionExperimentSet eeSet;
    eeSet = ExpressionExperimentSet.Factory.newInstance();
    eeSet.setTaxon(taxon);
    eeSet.setName(this.getMasterSetName(taxon));
    eeSet.setDescription(String.format(ExpressionExperimentSetService.AUTOMATICALLY_GENERATED_EXPERIMENT_GROUP_DESCRIPTION, String.valueOf(expressionExperiments.size())));
    eeSet.getExperiments().addAll(expressionExperiments);
    return eeSet;
}
Also used : ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet)

Example 12 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class ExpressionExperimentSetValueObjectHelperImpl method convertToEntity.

/*
     * @see
     * ubic.gemma.core.expression.experiment.ExpressionExperimentSetValueObjectHelper#convertToLightValueObject(ubic.gemma
     * .model.analysis.expression.ExpressionExperimentSet)
     */
@Override
public ExpressionExperimentSet convertToEntity(ExpressionExperimentSetValueObject setVO) {
    if (setVO == null) {
        return null;
    }
    ExpressionExperimentSet entity;
    if (setVO.getId() == null || setVO.getId() < 0) {
        entity = ExpressionExperimentSet.Factory.newInstance();
        entity.setId(null);
    } else {
        entity = expressionExperimentSetService.load(setVO.getId());
    }
    entity.setDescription(setVO.getDescription());
    Collection<ExpressionExperiment> experiments = expressionExperimentService.load(setVO.getExpressionExperimentIds());
    if (experiments.isEmpty()) {
        throw new IllegalArgumentException("The value object must have some experiments associated before it can be converted and persisted");
    }
    Collection<BioAssaySet> bas = new HashSet<BioAssaySet>(experiments);
    entity.setExperiments(bas);
    entity.setName(setVO.getName());
    if (setVO.getTaxonId() != null && setVO.getTaxonId() >= 0) {
        Taxon tax = taxonService.load(setVO.getTaxonId());
        entity.setTaxon(tax);
    } else {
        Log.debug("Trying to convert DatabaseBackedExpressionExperimentSetValueObject with id =" + setVO.getId() + " to ExpressionExperimentSet entity. Unmatched ValueObject.getTaxonId() was :" + setVO.getTaxonId());
    }
    return entity;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) HashSet(java.util.HashSet)

Example 13 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class ExpressionExperimentSearchServiceImpl method getAllTaxonExperimentGroup.

@Override
public List<SearchResultDisplayObject> getAllTaxonExperimentGroup(Long taxonId) {
    List<SearchResultDisplayObject> setResults = new LinkedList<>();
    Taxon taxon = taxonService.load(taxonId);
    Collection<ExpressionExperimentSet> sets = expressionExperimentSetService.findByName("Master set for " + taxon.getCommonName().toLowerCase());
    SearchResultDisplayObject newSRDO;
    for (ExpressionExperimentSet set : sets) {
        expressionExperimentSetService.thaw(set);
        if (set.getTaxon().getId().equals(taxonId)) {
            ExpressionExperimentSetValueObject eevo = expressionExperimentSetService.loadValueObject(set);
            newSRDO = new SearchResultDisplayObject(eevo);
            newSRDO.setUserOwned(securityService.isPrivate(set));
            ((ExpressionExperimentSetValueObject) newSRDO.getResultValueObject()).setIsPublic(securityService.isPublic(set));
            setResults.add(newSRDO);
        }
    }
    Collections.sort(setResults);
    return setResults;
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) SearchResultDisplayObject(ubic.gemma.core.search.SearchResultDisplayObject)

Example 14 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class ExpressionExperimentSetServiceTest method testUpdate.

@Test
public void testUpdate() {
    Long eeSetId = eeSet.getId();
    String newName = "newName";
    String newDesc = "newDesc";
    Collection<BioAssaySet> newMembers = new HashSet<>();
    newMembers.add(ee1);
    eeSet.setName(newName);
    eeSet.setDescription(newDesc);
    eeSet.setExperiments(newMembers);
    expressionExperimentSetService.update(eeSet);
    ExpressionExperimentSet updatedSet = expressionExperimentSetService.load(eeSetId);
    // need VO otherwise was getting lazy loading issues
    ExpressionExperimentSetValueObject setVO = expressionExperimentSetService.loadValueObject(updatedSet);
    assertEquals(newName, setVO.getName());
    assertEquals(newDesc, setVO.getDescription());
    // experiment IDs are not populated by default.
    assertEquals(1, setVO.getSize().intValue());
    Collection<ExpressionExperiment> eesInSet = expressionExperimentSetService.getExperimentsInSet(eeSet.getId());
    assertEquals(1, eesInSet.size());
    assertTrue(eesInSet.contains(ee1));
}
Also used : ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) HashSet(java.util.HashSet) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 15 with ExpressionExperimentSet

use of ubic.gemma.model.analysis.expression.ExpressionExperimentSet in project Gemma by PavlidisLab.

the class SearchServiceImpl method filterByTaxon.

/**
 * @param excludeWithoutTaxon if true: If the SearchResults have no "getTaxon" method then the results will get
 *                            filtered out Results with no taxon associated will also get removed.
 */
private void filterByTaxon(SearchSettings settings, Collection<SearchResult> results, boolean excludeWithoutTaxon) {
    if (settings.getTaxon() == null) {
        return;
    }
    Collection<SearchResult> toRemove = new HashSet<>();
    Taxon t = settings.getTaxon();
    if (results == null)
        return;
    for (SearchResult sr : results) {
        Object o = sr.getResultObject();
        try {
            Taxon currentTaxon;
            if (o instanceof ExpressionExperiment) {
                ExpressionExperiment ee = (ExpressionExperiment) o;
                currentTaxon = expressionExperimentService.getTaxon(ee);
            } else if (o instanceof ExpressionExperimentSet) {
                ExpressionExperimentSet ees = (ExpressionExperimentSet) o;
                currentTaxon = ees.getTaxon();
            } else if (o instanceof Gene) {
                Gene gene = (Gene) o;
                currentTaxon = gene.getTaxon();
            } else if (o instanceof GeneSet) {
                GeneSet geneSet = (GeneSet) o;
                currentTaxon = geneSetService.getTaxon(geneSet);
            } else if (o instanceof CharacteristicValueObject) {
                CharacteristicValueObject charVO = (CharacteristicValueObject) o;
                currentTaxon = taxonDao.findByCommonName(charVO.getTaxon());
            } else {
                Method m = o.getClass().getMethod("getTaxon");
                currentTaxon = (Taxon) m.invoke(o);
            }
            if (currentTaxon == null || !currentTaxon.getId().equals(t.getId())) {
                if (currentTaxon == null) {
                    // Sanity check for bad data in db (could happen if EE has no samples). Can happen that
                    // searchResults have a vaild getTaxon method
                    // but the method returns null (shouldn't make it this far)
                    SearchServiceImpl.log.debug("Object has getTaxon method but it returns null. Obj is: " + o);
                }
                toRemove.add(sr);
            }
        } catch (SecurityException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            /*
                 * In case of a programming error where the results don't have a taxon at all, we assume we should
                 * filter them out but issue a warning.
                 */
            if (excludeWithoutTaxon) {
                toRemove.add(sr);
                SearchServiceImpl.log.warn("No getTaxon method for: " + o.getClass() + ".  Filtering from results. Error was: " + e);
            }
        }
    }
    results.removeAll(toRemove);
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) Taxon(ubic.gemma.model.genome.Taxon) Method(java.lang.reflect.Method) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) InvocationTargetException(java.lang.reflect.InvocationTargetException) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) SearchSettingsValueObject(ubic.gemma.model.common.search.SearchSettingsValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) GeneEvidenceValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) GeneSet(ubic.gemma.model.genome.gene.GeneSet)

Aggregations

ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)18 HashSet (java.util.HashSet)6 Transactional (org.springframework.transaction.annotation.Transactional)6 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)6 Taxon (ubic.gemma.model.genome.Taxon)6 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)4 Test (org.junit.Test)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 Gene (ubic.gemma.model.genome.Gene)3 ArrayList (java.util.ArrayList)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 Element (org.w3c.dom.Element)2 ExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject)2 AclObjectIdentity (gemma.gsec.acl.domain.AclObjectIdentity)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 LinkedList (java.util.LinkedList)1 Acl (org.springframework.security.acls.model.Acl)1 CoexpressionMetaValueObject (ubic.gemma.core.analysis.expression.coexpression.CoexpressionMetaValueObject)1 CoexpressionValueObjectExt (ubic.gemma.core.analysis.expression.coexpression.CoexpressionValueObjectExt)1