Search in sources :

Example 46 with ArrayDesign

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

the class ExpressionDataFileServiceImpl method getGeneAnnotationsAsStrings.

/**
 * @return Map of composite sequence ids to an array of strings: [probe name, genes symbol(s), gene Name(s), gemma
 * id(s), ncbi id(s)].
 */
private Map<Long, String[]> getGeneAnnotationsAsStrings(Collection<ArrayDesign> ads) {
    Map<Long, String[]> annotations = new HashMap<>();
    for (ArrayDesign arrayDesign : ads) {
        arrayDesign = arrayDesignService.thaw(arrayDesign);
        annotations.putAll(ArrayDesignAnnotationServiceImpl.readAnnotationFileAsString(arrayDesign));
    }
    return annotations;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign)

Example 47 with ArrayDesign

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

the class ExpressionDataFileServiceImpl method writeDataFile.

/**
 * @param compress if true, file will be output in GZIP format.
 */
private File writeDataFile(ExpressionExperiment ee, boolean filtered, File f, boolean compress) throws IOException {
    ExpressionDataFileServiceImpl.log.info("Creating new expression data file: " + f.getName());
    ExpressionDataDoubleMatrix matrix = this.getDataMatrix(ee, filtered);
    Collection<ArrayDesign> arrayDesigns = expressionExperimentService.getArrayDesignsUsed(ee);
    Map<CompositeSequence, String[]> geneAnnotations = this.getGeneAnnotationsAsStringsByProbe(arrayDesigns);
    this.writeMatrix(f, geneAnnotations, matrix, compress);
    return f;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionDataDoubleMatrix(ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 48 with ArrayDesign

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

the class ExpressionDataMatrixServiceImpl method getFilteredMatrix.

@Override
public ExpressionDataDoubleMatrix getFilteredMatrix(String arrayDesignName, FilterConfig filterConfig, Collection<ProcessedExpressionDataVector> dataVectors) {
    ArrayDesign ad = arrayDesignService.findByShortName(arrayDesignName);
    if (ad == null) {
        throw new IllegalArgumentException("No platform named '" + arrayDesignName + "'");
    }
    Collection<ArrayDesign> arrayDesignsUsed = new HashSet<>();
    arrayDesignsUsed.add(ad);
    return this.getFilteredMatrix(filterConfig, dataVectors, arrayDesignsUsed);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) HashSet(java.util.HashSet)

Example 49 with ArrayDesign

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

the class ArrayDesignAnnotationFileCli method processAllADs.

/**
 * Goes over all the AD's in the database (possibly limited by taxon) and creates annotation 3 annotation files for
 * each AD that is not merged into or subsumed by another AD. Uses the Accession ID (GPL???) for the name of the
 * annotation file. Appends noParents, bioProcess, allParents to the file name.
 */
private void processAllADs() throws IOException {
    Collection<ArrayDesign> allADs = this.arrayDesignService.loadAll();
    for (ArrayDesign ad : allADs) {
        ad = arrayDesignService.thawLite(ad);
        if (ad.getCurationDetails().getTroubled()) {
            AbstractCLI.log.warn("Troubled: " + ad + " (skipping)");
            continue;
        }
        Taxon taxon = null;
        if (this.taxonName != null) {
            TaxonService taxonService = this.getBean(TaxonService.class);
            taxon = taxonService.findByCommonName(taxonName);
            if (taxon == null) {
                throw new IllegalArgumentException("Unknown taxon: " + taxonName);
            }
        }
        Collection<Taxon> adTaxa = arrayDesignService.getTaxa(ad.getId());
        /*
             * If using taxon, check it.
             */
        if (taxon != null && !adTaxa.contains(taxon)) {
            continue;
        }
        this.processOneAD(ad);
    }
}
Also used : TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon)

Example 50 with ArrayDesign

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

the class ArrayDesignBlatCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null)
        return err;
    final Date skipIfLastRunLaterThan = this.getLimitingDate();
    if (!this.arrayDesignsToProcess.isEmpty()) {
        if (this.blatResultFile != null && this.arrayDesignsToProcess.size() > 1) {
            throw new IllegalArgumentException("Cannot provide a blat result file when multiple arrays are being analyzed");
        }
        for (ArrayDesign arrayDesign : this.arrayDesignsToProcess) {
            if (!this.needToRun(skipIfLastRunLaterThan, arrayDesign, ArrayDesignSequenceAnalysisEvent.class)) {
                AbstractCLI.log.warn(arrayDesign + " was last run more recently than " + skipIfLastRunLaterThan);
                return null;
            }
            arrayDesign = this.thaw(arrayDesign);
            Collection<BlatResult> persistedResults;
            try {
                if (this.blatResultFile != null) {
                    Collection<BlatResult> blatResults = this.getBlatResultsFromFile(arrayDesign);
                    if (blatResults == null || blatResults.size() == 0) {
                        throw new IllegalStateException("No blat results in file!");
                    }
                    AbstractCLI.log.info("Got " + blatResults.size() + " blat records");
                    persistedResults = arrayDesignSequenceAlignmentService.processArrayDesign(arrayDesign, taxon, blatResults);
                    this.audit(arrayDesign, "BLAT results read from file: " + blatResultFile);
                } else {
                    // Run blat from scratch.
                    persistedResults = arrayDesignSequenceAlignmentService.processArrayDesign(arrayDesign, this.sensitive);
                    this.audit(arrayDesign, "Based on a fresh alignment analysis; BLAT score threshold was " + this.blatScoreThreshold + "; sensitive mode was " + this.sensitive);
                }
                AbstractCLI.log.info("Persisted " + persistedResults.size() + " results");
            } catch (IOException e) {
                this.errorObjects.add(e);
            }
        }
    } else if (taxon != null) {
        Collection<ArrayDesign> allArrayDesigns = arrayDesignService.findByTaxon(taxon);
        AbstractCLI.log.warn("*** Running BLAT for all " + taxon.getCommonName() + " Array designs *** [" + allArrayDesigns.size() + " items]");
        final SecurityContext context = SecurityContextHolder.getContext();
        /*
             * Here is our task runner.
             */
        class BlatCliConsumer extends Consumer {

            private BlatCliConsumer(BlockingQueue<ArrayDesign> q) {
                super(q, context);
            }

            @Override
            void consume(ArrayDesign x) {
                x = arrayDesignService.thaw(x);
                ArrayDesignBlatCli.this.processArrayDesign(skipIfLastRunLaterThan, x);
            }
        }
        BlockingQueue<ArrayDesign> arrayDesigns = new ArrayBlockingQueue<>(allArrayDesigns.size());
        arrayDesigns.addAll(allArrayDesigns);
        Collection<Thread> threads = new ArrayList<>();
        for (int i = 0; i < this.numThreads; i++) {
            Consumer c1 = new BlatCliConsumer(arrayDesigns);
            Thread k = new Thread(c1);
            threads.add(k);
            k.start();
        }
        this.waitForThreadPoolCompletion(threads);
        /*
             * All done
             */
        this.summarizeProcessing();
    } else {
        this.bail(ErrorCode.MISSING_ARGUMENT);
    }
    return null;
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) IOException(java.io.IOException) IOException(java.io.IOException) Date(java.util.Date) ArrayDesignSequenceAnalysisEvent(ubic.gemma.model.common.auditAndSecurity.eventType.ArrayDesignSequenceAnalysisEvent) SecurityContext(org.springframework.security.core.context.SecurityContext) Collection(java.util.Collection) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

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