Search in sources :

Example 26 with ArrayDesign

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

the class SimpleExpressionDataLoaderServiceTest method testLoad.

@Test
public final void testLoad() throws Exception {
    Taxon taxon = this.getTaxon("mouse");
    SimpleExpressionExperimentMetaData metaData = new SimpleExpressionExperimentMetaData();
    ArrayDesign ad = ArrayDesign.Factory.newInstance();
    ad.setShortName(RandomStringUtils.randomAlphabetic(5));
    ad.setName(RandomStringUtils.randomAlphabetic(5));
    ad.setPrimaryTaxon(taxon);
    ad.setTechnologyType(TechnologyType.ONECOLOR);
    Collection<ArrayDesign> ads = new HashSet<>();
    ads.add(ad);
    metaData.setArrayDesigns(ads);
    metaData.setTaxon(taxon);
    metaData.setShortName(RandomStringUtils.randomAlphabetic(5));
    metaData.setName(RandomStringUtils.randomAlphabetic(5));
    metaData.setDescription("Simple expression data loader service test - load");
    metaData.setQuantitationTypeName("testing");
    metaData.setGeneralType(GeneralType.QUANTITATIVE);
    metaData.setScale(ScaleType.LOG2);
    metaData.setType(StandardQuantitationType.AMOUNT);
    metaData.setIsRatio(true);
    try (InputStream data = this.getClass().getResourceAsStream("/data/testdata.txt")) {
        ee = service.create(metaData, data);
    }
    ee = eeService.thaw(ee);
    assertNotNull(ee);
    assertEquals(30, ee.getRawExpressionDataVectors().size());
    assertEquals(12, ee.getBioAssays().size());
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) InputStream(java.io.InputStream) Taxon(ubic.gemma.model.genome.Taxon) SimpleExpressionExperimentMetaData(ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData) HashSet(java.util.HashSet) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 27 with ArrayDesign

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

the class DatabaseViewGeneratorImpl method generateDatasetView.

private void generateDatasetView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
    DatabaseViewGeneratorImpl.log.info("Generating dataset summary view");
    /*
         * Get handle to output file
         */
    File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_SUMMARY_VIEW_BASENAME);
    DatabaseViewGeneratorImpl.log.info("Writing to " + file);
    try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
        writer.write("GemmaDsId\tSource\tSourceAccession\tShortName\tName\tDescription\ttaxon\tManufacturer\n");
        /*
             * Print out their names etc.
             */
        int i = 0;
        for (ExpressionExperiment ee : experiments) {
            ee = expressionExperimentService.thawLite(ee);
            DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
            String acc = "";
            String source = "";
            if (ee.getAccession() != null && ee.getAccession().getAccession() != null) {
                acc = ee.getAccession().getAccession();
                source = ee.getAccession().getExternalDatabase().getName();
            }
            Long gemmaId = ee.getId();
            String shortName = ee.getShortName();
            String name = ee.getName();
            String description = ee.getDescription();
            description = StringUtils.replaceChars(description, '\t', ' ');
            description = StringUtils.replaceChars(description, '\n', ' ');
            description = StringUtils.replaceChars(description, '\r', ' ');
            Taxon taxon = expressionExperimentService.getTaxon(ee);
            if (taxon == null)
                continue;
            Collection<ArrayDesign> ads = expressionExperimentService.getArrayDesignsUsed(ee);
            StringBuilder manufacturers = new StringBuilder();
            // TODO could cache the arrayDesigns to make faster, thawing ad is time consuming
            for (ArrayDesign ad : ads) {
                ad = arrayDesignService.thawLite(ad);
                if (ad.getDesignProvider() == null) {
                    DatabaseViewGeneratorImpl.log.debug("Array Design: " + ad.getShortName() + " has no design provoider assoicated with it. Skipping");
                    continue;
                }
                manufacturers.append(ad.getDesignProvider().getName()).append(",");
            }
            writer.write(String.format("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", gemmaId, source, acc, shortName, name, description, taxon.getCommonName(), StringUtils.removeEnd(manufacturers.toString(), ",")));
            if (limit != null && (limit > 0 && ++i > limit))
                break;
        }
    }
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GZIPOutputStream(java.util.zip.GZIPOutputStream)

Example 28 with ArrayDesign

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

the class AffyDataFromCelCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception e = super.processCommandLine(args);
    if (e != null)
        return e;
    DataUpdater serv = this.getBean(DataUpdater.class);
    // This can be done for multiple experiments under some conditions; we get this one just  to test for some multi-platform situations
    Collection<ArrayDesign> arrayDesignsUsed = this.eeService.getArrayDesignsUsed(this.expressionExperiments.iterator().next());
    if (StringUtils.isNotBlank(aptFile)) {
        if (this.expressionExperiments.size() > 1) {
            throw new IllegalArgumentException("Can't use " + AffyDataFromCelCli.APT_FILE_OPT + " unless you are doing just one experiment");
        }
        ExpressionExperiment thawedEe = (ExpressionExperiment) this.expressionExperiments.iterator().next();
        thawedEe = this.eeService.thawLite(thawedEe);
        if (arrayDesignsUsed.size() > 1) {
            throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.APT_FILE_OPT + " for experiment that uses multiple platforms");
        }
        ArrayDesign ad = arrayDesignsUsed.iterator().next();
        try {
            AbstractCLI.log.info("Loading data from " + aptFile);
            if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
                serv.addAffyExonArrayData(thawedEe, aptFile);
            } else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
                serv.addAffyData(thawedEe, aptFile);
            } else {
                throw new IllegalArgumentException("Option " + AffyDataFromCelCli.APT_FILE_OPT + " only valid if you are using an exon array.");
            }
        } catch (Exception exception) {
            return exception;
        }
        return null;
    }
    if (StringUtils.isNotBlank(cdfFile)) {
        if (arrayDesignsUsed.size() > 1) {
            throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.CDF_FILE_OPT + " for experiment that uses multiple platforms");
        }
    }
    for (BioAssaySet ee : this.expressionExperiments) {
        try {
            Collection<ArrayDesign> adsUsed = this.eeService.getArrayDesignsUsed(ee);
            /*
                 * if the audit trail already has a DataReplacedEvent, skip it, unless --force. Ignore this for
                 * multiplatform studies (at our peril)
                 */
            if (adsUsed.size() == 1 && !force && this.checkForAlreadyDone(ee)) {
                AbstractCLI.log.warn(ee + ": Already has been recomputed from raw data, skipping (use 'force' to override')");
                this.errorObjects.add(ee + ": Already has been computed from raw data");
                continue;
            }
            ExpressionExperiment thawedEe = (ExpressionExperiment) ee;
            thawedEe = this.eeService.thawLite(thawedEe);
            ArrayDesign ad = adsUsed.iterator().next();
            /*
                 * Even if there are multiple platforms, we assume they are all the same type. If not, that's your
                 * problem :) (seriously, we could check...)
                 */
            if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
                AbstractCLI.log.info(thawedEe + " looks like affy exon array");
                serv.addAffyExonArrayData(thawedEe);
                this.successObjects.add(thawedEe.toString());
                AbstractCLI.log.info("Successfully processed: " + thawedEe);
            } else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
                AbstractCLI.log.info(thawedEe + " looks like a affy 3-prime array");
                serv.reprocessAffyThreePrimeArrayData(thawedEe);
                this.successObjects.add(thawedEe.toString());
                AbstractCLI.log.info("Successfully processed: " + thawedEe);
            } else {
                AbstractCLI.log.warn(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
                this.errorObjects.add(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
            }
        } catch (Exception exception) {
            AbstractCLI.log.error(exception, exception);
            this.errorObjects.add(ee + " " + exception.getLocalizedMessage());
        }
    }
    super.summarizeProcessing();
    return null;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) DataUpdater(ubic.gemma.core.loader.expression.geo.DataUpdater) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 29 with ArrayDesign

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

the class ArrayDesignBioSequenceDetachCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null)
        return err;
    for (ArrayDesign arrayDesign : this.arrayDesignsToProcess) {
        this.getArrayDesignService().removeBiologicalCharacteristics(arrayDesign);
        this.audit(arrayDesign);
    }
    return null;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign)

Example 30 with ArrayDesign

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

the class ArrayDesignMapSummaryCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null)
        return err;
    ArrayDesignMapResultService arrayDesignMapResultService = this.getBean(ArrayDesignMapResultService.class);
    for (ArrayDesign arrayDesign : this.arrayDesignsToProcess) {
        ArrayDesign thawed = this.thaw(arrayDesign);
        Collection<CompositeSequenceMapSummary> results = arrayDesignMapResultService.summarizeMapResults(thawed);
        System.out.println(CompositeSequenceMapSummary.HEADER);
        for (CompositeSequenceMapSummary summary : results) {
            System.out.println(summary);
        }
    }
    return null;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignMapResultService(ubic.gemma.core.analysis.sequence.ArrayDesignMapResultService) CompositeSequenceMapSummary(ubic.gemma.core.analysis.sequence.CompositeSequenceMapSummary)

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