Search in sources :

Example 1 with GeoService

use of ubic.gemma.core.loader.expression.geo.service.GeoService in project Gemma by PavlidisLab.

the class ArrayDesignSequenceProcessorTest method testFetchAndLoadWithIdentifiers.

@Test
public void testFetchAndLoadWithIdentifiers() throws Exception {
    String fastacmdExe = Settings.getString(SimpleFastaCmd.FASTA_CMD_ENV_VAR);
    if (fastacmdExe == null) {
        log.warn("No fastacmd executable is configured, skipping test");
        return;
    }
    File fi = new File(fastacmdExe);
    if (!fi.canRead()) {
        log.warn(fastacmdExe + " not found, skipping test");
        return;
    }
    GeoService geoService = this.getBean(GeoService.class);
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
    @SuppressWarnings("unchecked") final Collection<ArrayDesign> ads = (Collection<ArrayDesign>) geoService.fetchAndLoad("GPL226", true, true, false, true, true);
    result = ads.iterator().next();
    result = arrayDesignService.thaw(result);
    // have to specify taxon as this has two taxons in it
    try (InputStream f = this.getClass().getResourceAsStream("/data/loader/expression/arrayDesign/identifierTest.txt")) {
        Collection<BioSequence> res = app.processArrayDesign(result, f, new String[] { "testblastdb", "testblastdbPartTwo" }, FileTools.resourceToPath("/data/loader/genome/blast"), taxon, true);
        assertNotNull(res);
        for (BioSequence sequence : res) {
            assertNotNull(sequence.getSequence());
        }
        for (CompositeSequence cs : result.getCompositeSequences()) {
            assert cs.getBiologicalCharacteristic() != null;
        }
    }
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) InputStream(java.io.InputStream) GeoService(ubic.gemma.core.loader.expression.geo.service.GeoService) Collection(java.util.Collection) File(java.io.File) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 2 with GeoService

use of ubic.gemma.core.loader.expression.geo.service.GeoService 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)

Example 3 with GeoService

use of ubic.gemma.core.loader.expression.geo.service.GeoService in project Gemma by PavlidisLab.

the class ArrayDesignSequenceProcessorTest method testFetchAndLoadWithSequences.

@Test
public void testFetchAndLoadWithSequences() throws Exception {
    GeoService geoService = this.getBean(GeoService.class);
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
    @SuppressWarnings("unchecked") final Collection<ArrayDesign> ads = (Collection<ArrayDesign>) geoService.fetchAndLoad("GPL226", true, true, false);
    result = ads.iterator().next();
    result = arrayDesignService.thaw(result);
    try {
        Collection<BioSequence> res = app.processArrayDesign(result, new String[] { "testblastdb", "testblastdbPartTwo" }, FileTools.resourceToPath("/data/loader/genome/blast"), false);
        assertNotNull(res);
        for (BioSequence sequence : res) {
            assertNotNull(sequence.getSequence());
        }
    } catch (Exception e) {
        if (StringUtils.isNotBlank(e.getMessage()) && e.getMessage().contains("not found")) {
            log.error("fastacmd is not installed or is misconfigured.  Test skipped");
            return;
        }
        throw e;
    }
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) GeoService(ubic.gemma.core.loader.expression.geo.service.GeoService) Collection(java.util.Collection) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 4 with GeoService

use of ubic.gemma.core.loader.expression.geo.service.GeoService in project Gemma by PavlidisLab.

the class AbstractArrayDesignProcessingTest method setupArrayDesign.

@Before
public void setupArrayDesign() {
    ad = arrayDesignService.findByShortName(AbstractArrayDesignProcessingTest.ACCESSION);
    if (ad == null) {
        // first load small twoc-color
        GeoService geoService = this.getBean(GeoService.class);
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGenerator());
        try {
            @SuppressWarnings("unchecked") final Collection<ArrayDesign> ads = (Collection<ArrayDesign>) geoService.fetchAndLoad(AbstractArrayDesignProcessingTest.ACCESSION, true, true, false, true, true);
            ad = ads.iterator().next();
        } catch (Exception e) {
            if (e.getCause() instanceof FileNotFoundException) {
                log.warn("problem with initializing array design for test: " + e.getCause().getMessage());
                return;
            }
            throw e;
        }
    }
    ad = arrayDesignService.thaw(ad);
}
Also used : GeoDomainObjectGenerator(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGenerator) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) GeoService(ubic.gemma.core.loader.expression.geo.service.GeoService) FileNotFoundException(java.io.FileNotFoundException) Collection(java.util.Collection) FileNotFoundException(java.io.FileNotFoundException) Before(org.junit.Before)

Aggregations

GeoService (ubic.gemma.core.loader.expression.geo.service.GeoService)4 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)4 Collection (java.util.Collection)3 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)2 GeoDomainObjectGenerator (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGenerator)2 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)2 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 Before (org.junit.Before)1 PreprocessingException (ubic.gemma.core.analysis.preprocess.PreprocessingException)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1 ArrayDesignService (ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService)1