Search in sources :

Example 71 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class ExpressionExperimentManipulatingCLI method readExpressionExperimentListFile.

/**
 * Load expression experiments based on a list of short names or IDs in a file. Only the first column of the file is
 * used, comments (#) are allowed.
 */
private Set<BioAssaySet> readExpressionExperimentListFile(String fileName) throws IOException {
    Set<BioAssaySet> ees = new HashSet<>();
    for (String eeName : AbstractCLIContextCLI.readListFileToStrings(fileName)) {
        ExpressionExperiment ee = eeService.findByShortName(eeName);
        if (ee == null) {
            try {
                Long id = Long.parseLong(eeName);
                ee = eeService.load(id);
                if (ee == null) {
                    AbstractCLI.log.error("No experiment " + eeName + " found");
                    continue;
                }
            } catch (NumberFormatException e) {
                AbstractCLI.log.error("No experiment " + eeName + " found");
                continue;
            }
        }
        ees.add(ee);
    }
    return ees;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) HashSet(java.util.HashSet)

Example 72 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class ExpressionExperimentManipulatingCLI method findExpressionExperimentsByQuery.

/**
 * Use the search engine to locate expression experiments.
 */
private Set<BioAssaySet> findExpressionExperimentsByQuery(String query) {
    Set<BioAssaySet> ees = new HashSet<>();
    Collection<SearchResult> eeSearchResults = searchService.search(SearchSettingsImpl.expressionExperimentSearch(query)).get(ExpressionExperiment.class);
    AbstractCLI.log.info(ees.size() + " Expression experiments matched '" + query + "'");
    // Filter out all the ee that are not of correct taxon
    for (SearchResult sr : eeSearchResults) {
        ExpressionExperiment ee = (ExpressionExperiment) sr.getResultObject();
        Taxon t = eeService.getTaxon(ee);
        if (t != null && t.getCommonName().equalsIgnoreCase(taxon.getCommonName())) {
            ees.add(ee);
        }
    }
    return ees;
}
Also used : BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) Taxon(ubic.gemma.model.genome.Taxon) SearchResult(ubic.gemma.core.search.SearchResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) HashSet(java.util.HashSet)

Example 73 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class ExpressionExperimentManipulatingCLI method experimentsFromCliList.

private void experimentsFromCliList() {
    String experimentShortNames = this.getOptionValue('e');
    String[] shortNames = experimentShortNames.split(",");
    for (String shortName : shortNames) {
        ExpressionExperiment expressionExperiment = this.locateExpressionExperiment(shortName);
        if (expressionExperiment == null) {
            AbstractCLI.log.warn(shortName + " not found");
            continue;
        }
        eeService.thawLite(expressionExperiment);
        expressionExperiments.add(expressionExperiment);
    }
    if (expressionExperiments.size() == 0) {
        AbstractCLI.log.error("There were no valid experimnents specified");
        this.bail(ErrorCode.INVALID_OPTION);
    }
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 74 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class ExpressionExperimentPrimaryPubCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = processCommandLine(args);
    if (err != null)
        return err;
    ExpressionExperimentService ees = this.getBean(ExpressionExperimentService.class);
    Persister ph = this.getPersisterHelper();
    PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
    // collect some statistics
    Collection<String> nullPubCount = new ArrayList<>();
    Collection<String> samePubCount = new ArrayList<>();
    Collection<String> diffPubCount = new ArrayList<>();
    Collection<String> failedEe = new ArrayList<>();
    ExpressionExperimentBibRefFinder finder = new ExpressionExperimentBibRefFinder();
    for (BioAssaySet bioassay : expressionExperiments) {
        if (!(bioassay instanceof ExpressionExperiment)) {
            log.info(bioassay.getName() + " is not an ExpressionExperiment");
            continue;
        }
        ExpressionExperiment experiment = (ExpressionExperiment) bioassay;
        // if ( experiment.getPrimaryPublication() != null ) continue;
        if (experiment.getPrimaryPublication() == null) {
            log.warn(experiment + " has no existing primary publication");
        }
        experiment = ees.thawLite(experiment);
        // get from GEO or get from a file
        BibliographicReference ref = fetcher.retrieveByHTTP(pubmedIds.get(experiment.getShortName()));
        if (ref == null) {
            if (this.pubmedIdFilename != null) {
                log.warn("Pubmed ID for " + experiment.getShortName() + " was not found in " + this.pubmedIdFilename);
            }
            ref = finder.locatePrimaryReference(experiment);
            if (ref == null) {
                log.error("No ref for " + experiment);
                failedEe.add(experiment.getShortName());
                continue;
            }
        }
        // collect some statistics
        if (experiment.getPrimaryPublication() == null) {
            nullPubCount.add(experiment.getShortName());
        } else if (experiment.getPrimaryPublication().getPubAccession().getAccession().equals(pubmedIds.get(experiment.getShortName()).toString())) {
            samePubCount.add(experiment.getShortName());
        } else {
            diffPubCount.add(experiment.getShortName());
        }
        try {
            log.info("Found pubAccession " + ref.getPubAccession().getAccession() + " for " + experiment);
            ref = (BibliographicReference) ph.persist(ref);
            experiment.setPrimaryPublication(ref);
            ees.update(experiment);
        } catch (Exception e) {
            log.error(experiment.getShortName() + " (id=" + experiment.getId() + ") update failed.");
            e.printStackTrace();
        }
    }
    // print statistics
    log.info("\n\n========== Summary ==========");
    log.info("Total number of experiments: " + expressionExperiments.size());
    log.info("Same publication: " + samePubCount.size());
    log.info("Diff publication: " + diffPubCount.size());
    log.info("No initial publication: " + nullPubCount.size());
    log.info("No publications found: " + failedEe.size());
    log.info("\n\n========== Details ==========");
    log.info("Diff publication: " + Arrays.toString(diffPubCount.toArray()));
    log.info("No initial publication: " + Arrays.toString(nullPubCount.toArray()));
    log.info("No publications found: " + Arrays.toString(failedEe.toArray()));
    return null;
}
Also used : ExpressionExperimentBibRefFinder(ubic.gemma.core.loader.entrez.pubmed.ExpressionExperimentBibRefFinder) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ArrayList(java.util.ArrayList) ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) Persister(ubic.gemma.persistence.persister.Persister) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) IOException(java.io.IOException)

Example 75 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class GeeqCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = super.processCommandLine(args);
    if (err != null)
        return err;
    Exception lastE = null;
    // Loads the EE with largest ID.
    long max = eeService.loadValueObjectsPreFilter(0, 1, "id", false, null).iterator().next().getId();
    long start = Long.parseLong(startArg);
    long stop = Long.parseLong(stopArg) + 1;
    String msg = "Success, no problems";
    int ran = 0;
    int errorred = 0;
    for (long i = start; i < stop; i++) {
        if (i > max) {
            msg = "Success, max ID reached before getting to stop arg: " + max;
            break;
        }
        try {
            ExpressionExperiment ee = eeService.load(i);
            if (ee != null) {
                geeqService.calculateScore(i, mode);
                ran++;
            }
        } catch (Exception e) {
            System.out.println(i + " failed: " + e.getMessage());
            errorred++;
            lastE = e;
        }
    }
    if (lastE != null) {
        Log.info(this.getClass(), "Geeq for some EEs failed, only ran " + ran + " EEs. Error on " + errorred + " EEs.");
        return lastE;
    }
    Log.info(this.getClass(), msg + ", ran " + ran + " EEs.");
    return null;
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Aggregations

ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)214 Test (org.junit.Test)71 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)42 InputStream (java.io.InputStream)36 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)29 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)29 GZIPInputStream (java.util.zip.GZIPInputStream)28 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)26 HashSet (java.util.HashSet)25 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)25 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)23 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)22 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)20 Collection (java.util.Collection)18 StopWatch (org.apache.commons.lang3.time.StopWatch)18 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)18 Taxon (ubic.gemma.model.genome.Taxon)14 Before (org.junit.Before)12 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11