Search in sources :

Example 51 with ArrayDesign

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

the class ArrayDesignMergeCli method processOptions.

@Override
protected void processOptions() {
    super.processOptions();
    if (this.hasOption('o')) {
        // required
        String otherArrayDesignName = this.getOptionValue('o');
        String[] names = StringUtils.split(otherArrayDesignName, ',');
        this.otherArrayDesigns = new HashSet<>();
        for (String string : names) {
            ArrayDesign o = this.locateArrayDesign(string, arrayDesignService);
            if (o == null) {
                throw new IllegalArgumentException("Array design " + string + " not found");
            }
            o = this.thaw(o);
            this.otherArrayDesigns.add(o);
        }
    }
    if (this.arrayDesignsToProcess.size() > 1) {
        throw new IllegalArgumentException("Cannot be applied to more than one array design given to the '-a' option");
    }
    arrayDesign = this.arrayDesignsToProcess.iterator().next();
    arrayDesign = this.thaw(arrayDesign);
    if (this.hasOption("add")) {
        if (arrayDesign.getMergees().isEmpty()) {
            throw new IllegalArgumentException("The array given must be a merged design when using -add");
        }
    } else {
        if (this.hasOption("n")) {
            this.newName = this.getOptionValue('n');
        } else {
            throw new IllegalArgumentException("You must provide a name for the new design unless using -add");
        }
        if (this.hasOption("s")) {
            this.newShortName = this.getOptionValue('s');
        } else {
            throw new IllegalArgumentException("You must provide a short name for the new design unless using -add");
        }
    }
    arrayDesignMergeService = this.getBean(ArrayDesignMergeService.class);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignMergeService(ubic.gemma.core.loader.expression.arrayDesign.ArrayDesignMergeService)

Example 52 with ArrayDesign

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

the class ArrayDesignProbeMapperCli method batchRun.

private void batchRun(final Date skipIfLastRunLaterThan) {
    Collection<ArrayDesign> allArrayDesigns;
    if (this.taxon != null) {
        allArrayDesigns = arrayDesignService.findByTaxon(this.taxon);
    } else {
        allArrayDesigns = arrayDesignService.loadAll();
    }
    final SecurityContext context = SecurityContextHolder.getContext();
    class ADProbeMapperCliConsumer extends Consumer {

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

        @Override
        void consume(ArrayDesign x) {
            if (x.getCurationDetails().getTroubled()) {
                AbstractCLI.log.warn("Skipping troubled platform: " + x);
                errorObjects.add(x + ": " + "Skipped because it is troubled; run in non-batch-mode");
                return;
            }
            /*
                 * Note that if the array design has multiple taxa, analysis will be run on all of the sequences, not
                 * just the ones from the taxon specified.
                 */
            ArrayDesignProbeMapperCli.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++) {
        ADProbeMapperCliConsumer c1 = new ADProbeMapperCliConsumer(arrayDesigns);
        Thread k = new Thread(c1);
        threads.add(k);
        k.start();
    }
    this.waitForThreadPoolCompletion(threads);
    /*
         * All done
         */
    this.summarizeProcessing();
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) SecurityContext(org.springframework.security.core.context.SecurityContext)

Example 53 with ArrayDesign

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

the class LoadSimpleExpressionDataCli method configureArrayDesigns.

private void configureArrayDesigns(String[] fields, SimpleExpressionExperimentMetaData metaData) {
    int i;
    TechnologyType techType = TechnologyType.fromString(fields[LoadSimpleExpressionDataCli.TECHNOLOGY_TYPE_I]);
    Collection<ArrayDesign> ads = new HashSet<>();
    if (StringUtils.isBlank(fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I])) {
        // that's okay, so long as we get an array design name
        ArrayDesign ad = this.getNewArrayDesignFromName(fields);
        ad.setTechnologyType(techType);
        ad.setPrimaryTaxon(metaData.getTaxon());
        ads.add(ad);
    } else if (fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I].trim().equals("IMAGE")) {
        ArrayDesign ad = this.getNewArrayDesignFromName(fields);
        ad.setTechnologyType(techType);
        ad.setPrimaryTaxon(metaData.getTaxon());
        ads.add(ad);
        metaData.setProbeIdsAreImageClones(true);
    } else if (StringUtils.isNotBlank(fields[LoadSimpleExpressionDataCli.ARRAY_DESIGN_NAME_I])) {
        // allow for the case where there is an additional new array design to be added.
        ArrayDesign ad = this.getNewArrayDesignFromName(fields);
        ad.setTechnologyType(techType);
        ad.setPrimaryTaxon(metaData.getTaxon());
        ads.add(ad);
    } else {
        String[] allADs = fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I].split("\\+");
        for (i = 0; i < allADs.length; i++) {
            ArrayDesign ad = adService.findByShortName(allADs[i]);
            if (ad == null) {
                Collection<ArrayDesign> existingAds = adService.findByAlternateName(allADs[i]);
                if (existingAds.size() == 1) {
                    ad = existingAds.iterator().next();
                } else if (existingAds.size() > 1) {
                    throw new IllegalStateException("Array Design " + allADs[i] + " is ambiguous, it is an alternate name of more than one array design");
                }
            }
            if (ad == null) {
                throw new IllegalStateException("Array Design " + allADs[i] + " is not loaded into the system yet; load it and try again.");
            }
            ads.add(ad);
        }
    }
    metaData.setArrayDesigns(ads);
}
Also used : TechnologyType(ubic.gemma.model.expression.arrayDesign.TechnologyType) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) HashSet(java.util.HashSet)

Example 54 with ArrayDesign

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

the class LoadSimpleExpressionDataCli method getNewArrayDesignFromName.

private ArrayDesign getNewArrayDesignFromName(String[] fields) {
    this.checkForArrayDesignName(fields);
    ArrayDesign ad = ArrayDesign.Factory.newInstance();
    ad.setName(fields[LoadSimpleExpressionDataCli.ARRAY_DESIGN_NAME_I]);
    ad.setShortName(ad.getName());
    return ad;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign)

Example 55 with ArrayDesign

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

the class LoadExpressionDataCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null) {
        return err;
    }
    try {
        GeoService geoService = this.getBean(GeoService.class);
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGenerator());
        if (accessions == null && accessionFile == null) {
            return new IllegalArgumentException("You must specific either a file or accessions on the command line");
        }
        if (accessions != null) {
            AbstractCLI.log.info("Got accession(s) from command line " + accessions);
            String[] accsToRun = StringUtils.split(accessions, ',');
            for (String accession : accsToRun) {
                accession = StringUtils.strip(accession);
                if (StringUtils.isBlank(accession)) {
                    continue;
                }
                if (platformOnly) {
                    Collection<?> designs = geoService.fetchAndLoad(accession, true, true, false, true, true);
                    ArrayDesignService ads = this.getBean(ArrayDesignService.class);
                    for (Object object : designs) {
                        assert object instanceof ArrayDesign;
                        ArrayDesign ad = (ArrayDesign) object;
                        ad = ads.thawLite(ad);
                        successObjects.add(ad.getName() + " (" + ad.getExternalReferences().iterator().next().getAccession() + ")");
                    }
                } else {
                    this.processAccession(geoService, accession);
                }
            }
        }
        if (accessionFile != null) {
            AbstractCLI.log.info("Loading accessions from " + accessionFile);
            InputStream is = new FileInputStream(accessionFile);
            try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
                String accession;
                while ((accession = br.readLine()) != null) {
                    if (StringUtils.isBlank(accession)) {
                        continue;
                    }
                    this.processAccession(geoService, accession);
                }
            }
        }
        this.summarizeProcessing();
    } catch (Exception e) {
        AbstractCLI.log.error(e);
        return e;
    }
    return null;
}
Also used : InputStreamReader(java.io.InputStreamReader) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) PreprocessingException(ubic.gemma.core.analysis.preprocess.PreprocessingException) FileInputStream(java.io.FileInputStream) GeoDomainObjectGenerator(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGenerator) GeoService(ubic.gemma.core.loader.expression.geo.service.GeoService) BufferedReader(java.io.BufferedReader) ArrayDesignService(ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService)

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