Search in sources :

Example 6 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class PlatformArg method getExperiments.

/**
 * Retrieves the Datasets of the Platform that this argument represents.
 *
 * @param service   service that will be used to retrieve the persistent AD object.
 * @param eeService service to use to retrieve the EEs.
 * @return a collection of Datasets that the platform represented by this argument contains.
 */
public Collection<ExpressionExperimentValueObject> getExperiments(ArrayDesignService service, ExpressionExperimentService eeService, int limit, int offset) {
    ArrayDesign ad = this.getPersistentObject(service);
    ArrayList<ObjectFilter[]> filters = new ArrayList<>(1);
    filters.add(new ObjectFilter[] { new ObjectFilter("id", ad.getId(), ObjectFilter.is, ObjectFilter.DAO_AD_ALIAS) });
    return eeService.loadValueObjectsPreFilter(offset, limit, "id", true, filters);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayList(java.util.ArrayList) ObjectFilter(ubic.gemma.persistence.util.ObjectFilter)

Example 7 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class PersistentDummyObjectHelper method getTestExpressionExperimentWithAllDependencies.

public ExpressionExperiment getTestExpressionExperimentWithAllDependencies(ExpressionExperiment prototype) {
    ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
    ee.setShortName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
    ee.setName("Expression Experiment " + RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
    ee.setDescription("A test expression experiment");
    ee.setSource("https://www.ncbi.nlm.nih.gov/geo/");
    DatabaseEntry de1 = this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo);
    ee.setAccession(de1);
    LocalFile file = LocalFile.Factory.newInstance();
    try {
        file.setLocalURL(new URL("file:///just/a/placeholder/" + ee.getShortName()));
    } catch (MalformedURLException e) {
        log.error("Malformed URL");
    }
    ee.setRawDataFile(file);
    Collection<FactorValue> allFactorValues = new HashSet<>();
    ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
    Collection<BioMaterial> bioMaterials = this.getBioMaterials(allFactorValues);
    ee.setExperimentalDesign(ed);
    ee.setOwner(this.getTestPersistentContact());
    List<ArrayDesign> arrayDesignsUsed = new ArrayList<>(eeService.getArrayDesignsUsed(prototype));
    Collection<BioAssay> bioAssays = new HashSet<>();
    Collection<QuantitationType> quantitationTypes = this.addQuantitationTypes(new HashSet<QuantitationType>());
    eeService.thaw(prototype);
    Collection<RawExpressionDataVector> vectors = new HashSet<>();
    for (ArrayDesign ad : arrayDesignsUsed) {
        List<BioAssay> bas = this.getBioAssays(bioMaterials, ad);
        bioAssays.addAll(bas);
        ad = this.adService.thaw(ad);
        vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bas, ad));
    }
    ee.setBioAssays(bioAssays);
    assert quantitationTypes.size() > 0;
    ee.setQuantitationTypes(quantitationTypes);
    ee.setRawExpressionDataVectors(vectors);
    ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
    ee = persisterHelper.persist(ee, c);
    return ee;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) MalformedURLException(java.net.MalformedURLException) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignsForExperimentCache(ubic.gemma.persistence.util.ArrayDesignsForExperimentCache) URL(java.net.URL) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 8 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class PersistentDummyObjectHelper method getTestExpressionExperimentWithAllDependencies.

/**
 * Add an expressionExperiment to the database for testing purposes. Includes associations
 *
 * @param doSequence Should the array design get all the sequence information filled in? (true = slower)
 * @return EE
 */
public ExpressionExperiment getTestExpressionExperimentWithAllDependencies(boolean doSequence) {
    ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
    ee.setShortName(RandomStringUtils.randomAlphanumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
    ee.setName("Expression Experiment " + RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
    ee.setDescription("A test expression experiment");
    ee.setSource("https://www.ncbi.nlm.nih.gov/geo/");
    DatabaseEntry de1 = this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo);
    ee.setAccession(de1);
    LocalFile file = LocalFile.Factory.newInstance();
    try {
        file.setLocalURL(new URL("file:///just/a/placeholder/" + ee.getShortName()));
    } catch (MalformedURLException e) {
        log.error("Malformed URL");
    }
    ee.setRawDataFile(file);
    ArrayDesign adA = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
    ArrayDesign adB = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
    Collection<FactorValue> allFactorValues = new HashSet<>();
    ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
    ee.setExperimentalDesign(ed);
    ee.setOwner(this.getTestPersistentContact());
    Collection<BioAssay> bioAssays = new HashSet<>();
    Collection<BioMaterial> bioMaterials = this.getBioMaterials(allFactorValues);
    List<BioAssay> bioAssaysA = this.getBioAssays(bioMaterials, adA);
    List<BioAssay> bioAssaysB = this.getBioAssays(bioMaterials, adB);
    bioAssays.addAll(bioAssaysA);
    bioAssays.addAll(bioAssaysB);
    ee.setBioAssays(bioAssays);
    log.debug("expression experiment => design element data vectors");
    Collection<RawExpressionDataVector> vectors = new HashSet<>();
    Collection<QuantitationType> quantitationTypes = this.addQuantitationTypes(new HashSet<QuantitationType>());
    assert quantitationTypes.size() > 0;
    vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysA, adA));
    vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysB, adB));
    ee.setQuantitationTypes(quantitationTypes);
    ee.setRawExpressionDataVectors(vectors);
    ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
    ee = persisterHelper.persist(ee, c);
    return ee;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) MalformedURLException(java.net.MalformedURLException) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignsForExperimentCache(ubic.gemma.persistence.util.ArrayDesignsForExperimentCache) URL(java.net.URL) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 9 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerServiceTest method extraTests1.

private void extraTests1(ExpressionExperiment ds1) {
    Collection<Gene> geneCollection = geneService.findByOfficialSymbol("ACTA2");
    assertTrue(!geneCollection.isEmpty());
    Gene g = geneCollection.iterator().next();
    assertNotNull(g);
    long count = geneService.getCompositeSequenceCountById(g.getId());
    assertTrue(count != 0);
    Collection<CompositeSequence> compSequences = geneService.getCompositeSequencesById(g.getId());
    assertTrue(compSequences.size() != 0);
    Collection<CompositeSequence> collection = compositeSequenceService.findByGene(g);
    assertEquals(1, collection.size());
    ArrayDesign ad = experimentService.getArrayDesignsUsed(ds1).iterator().next();
    collection = compositeSequenceService.findByGene(g, ad);
    assertEquals(1, collection.size());
    Collection<CompositeSequence> css = compositeSequenceService.findByName("200974_at");
    assertTrue(!css.isEmpty());
    CompositeSequence cs = css.iterator().next();
    Collection<Gene> genes = compositeSequenceService.getGenes(cs);
    assertEquals(1, genes.size());
    assertEquals(g, genes.iterator().next());
    tableMaintenanceUtil.disableEmail();
    tableMaintenanceUtil.updateGene2CsEntries();
    Map<CompositeSequence, Collection<Gene>> gm = compositeSequenceService.getGenes(css);
    assertEquals(1, gm.size());
    assertEquals(g, gm.values().iterator().next().iterator().next());
}
Also used : Gene(ubic.gemma.model.genome.Gene) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 10 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerServiceTest method addGenes.

/**
 * Add gene annotations. Requires removing old sequence associations.
 */
private void addGenes() throws Exception {
    // fill this in with whatever.
    ExternalDatabase genbank = edService.findByName("genbank");
    assert genbank != null;
    Taxon human = taxonService.findByCommonName("human");
    assert human != null;
    File annotationFile = new File(this.getClass().getResource("/data/loader/expression/geo/meta-analysis/human.probes.for.import.txt").toURI());
    ArrayDesign gpl96 = arrayDesignService.findByShortName("GPL96");
    assertNotNull(gpl96);
    ArrayDesign gpl97 = arrayDesignService.findByShortName("GPL97");
    assertNotNull(gpl97);
    arrayDesignService.removeBiologicalCharacteristics(gpl96);
    arrayDesignProbeMapperService.processArrayDesign(gpl96, human, annotationFile, genbank, false);
    arrayDesignService.removeBiologicalCharacteristics(gpl97);
    arrayDesignProbeMapperService.processArrayDesign(gpl97, human, annotationFile, genbank, false);
    tableMaintenanceUtil.updateGene2CsEntries();
}
Also used : ExternalDatabase(ubic.gemma.model.common.description.ExternalDatabase) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) File(java.io.File)

Aggregations

ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)186 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)43 Test (org.junit.Test)32 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)26 InputStream (java.io.InputStream)25 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)24 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)24 Taxon (ubic.gemma.model.genome.Taxon)23 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)19 HashSet (java.util.HashSet)16 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 Collection (java.util.Collection)14 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 StopWatch (org.apache.commons.lang3.time.StopWatch)12 Before (org.junit.Before)12 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)12 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)9 GZIPInputStream (java.util.zip.GZIPInputStream)8 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)8 File (java.io.File)7