Search in sources :

Example 6 with LocalFile

use of ubic.gemma.model.common.description.LocalFile in project Gemma by PavlidisLab.

the class AclTestUtils method checkDeleteEEAcls.

/**
 * CHeck the entire entity graph of an ee for ACL deletion.
 *
 * @param ee ee
 */
public void checkDeleteEEAcls(ExpressionExperiment ee) {
    this.checkDeletedAcl(ee);
    this.checkDeletedAcl(ee.getRawDataFile());
    this.checkDeletedAcl(ee.getExperimentalDesign());
    for (ExperimentalFactor f : ee.getExperimentalDesign().getExperimentalFactors()) {
        this.checkDeletedAcl(f);
        for (FactorValue fv : f.getFactorValues()) {
            this.checkDeletedAcl(fv);
        }
    }
    assertTrue(ee.getBioAssays().size() > 0);
    for (BioAssay ba : ee.getBioAssays()) {
        this.checkDeletedAcl(ba);
        LocalFile rawDataFile = ba.getRawDataFile();
        for (LocalFile f : ba.getDerivedDataFiles()) {
            this.checkDeletedAcl(f);
        }
        if (rawDataFile != null) {
            this.checkDeletedAcl(rawDataFile);
        }
        BioMaterial bm = ba.getSampleUsed();
        this.checkDeletedAcl(bm);
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) LocalFile(ubic.gemma.model.common.description.LocalFile) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 7 with LocalFile

use of ubic.gemma.model.common.description.LocalFile in project Gemma by PavlidisLab.

the class AclTestUtils method checkEEAcls.

/**
 * Validate ACLs on EE
 *
 * @param ee ee
 */
public void checkEEAcls(ExpressionExperiment ee) {
    ee = expressionExperimentService.thawLite(ee);
    this.checkHasAcl(ee);
    this.checkHasAces(ee);
    ExperimentalDesign experimentalDesign = ee.getExperimentalDesign();
    this.checkHasAcl(experimentalDesign);
    this.checkHasAclParent(experimentalDesign, ee);
    this.checkLacksAces(experimentalDesign);
    if (ee.getRawDataFile() != null) {
        this.checkHasAcl(ee.getRawDataFile());
        this.checkHasAclParent(ee.getRawDataFile(), ee);
        this.checkLacksAces(ee.getRawDataFile());
    }
    for (ExperimentalFactor f : experimentalDesign.getExperimentalFactors()) {
        this.checkHasAcl(f);
        this.checkHasAclParent(f, ee);
        this.checkLacksAces(f);
        for (FactorValue fv : f.getFactorValues()) {
            this.checkHasAcl(fv);
            this.checkHasAclParent(fv, ee);
            this.checkLacksAces(fv);
        }
    }
    // make sure ACLs for the child objects are there
    assertTrue(ee.getBioAssays().size() > 0);
    for (BioAssay ba : ee.getBioAssays()) {
        this.checkHasAcl(ba);
        this.checkHasAclParent(ba, ee);
        this.checkLacksAces(ba);
        LocalFile rawDataFile = ba.getRawDataFile();
        if (rawDataFile != null) {
            this.checkHasAcl(rawDataFile);
            this.checkHasAclParent(rawDataFile, null);
            this.checkLacksAces(rawDataFile);
        }
        for (LocalFile f : ba.getDerivedDataFiles()) {
            this.checkHasAcl(f);
            this.checkHasAclParent(f, null);
            this.checkLacksAces(f);
        }
        BioMaterial bm = ba.getSampleUsed();
        this.checkHasAcl(bm);
        this.checkHasAclParent(bm, ee);
        this.checkLacksAces(bm);
        ArrayDesign arrayDesign = ba.getArrayDesignUsed();
        this.checkHasAcl(arrayDesign);
        assertTrue(this.getParentAcl(arrayDesign) == null);
        // make sure the localfiles are associated with the array design, not the ee.
        arrayDesign = arrayDesignService.thawLite(arrayDesign);
        for (LocalFile lf : arrayDesign.getLocalFiles()) {
            this.checkHasAcl(lf);
            this.checkLacksAces(lf);
            this.checkHasAclParent(lf, arrayDesign);
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) LocalFile(ubic.gemma.model.common.description.LocalFile) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 8 with LocalFile

use of ubic.gemma.model.common.description.LocalFile in project Gemma by PavlidisLab.

the class StringProteinFetcherIntegrationTest method testDownloadProteinAliasFile.

/*
     * Test fetching a small file from string in this case a taxon file.
     */
@Test
public void testDownloadProteinAliasFile() {
    Collection<LocalFile> localFile = stringProteinLinksDetailedFetcher.fetch(testFileName);
    String outputfilenamegzip;
    String outputfilename;
    stringProteinLinksDetailedFetcher.unPackFile(localFile);
    for (LocalFile file : localFile) {
        outputfilenamegzip = file.getLocalURL().getFile();
        assertNotNull(outputfilenamegzip);
        String archiveMethod = "gz";
        int lastIndexOf = outputfilenamegzip.lastIndexOf("." + archiveMethod);
        if (lastIndexOf != -1) {
            outputfilename = outputfilenamegzip.substring(0, lastIndexOf);
            // check that the file has been downloaded and unzipped
            assertTrue(new File(outputfilename).canRead());
        } else {
            fail();
        }
    }
}
Also used : LocalFile(ubic.gemma.model.common.description.LocalFile) LocalFile(ubic.gemma.model.common.description.LocalFile) File(java.io.File) Test(org.junit.Test)

Example 9 with LocalFile

use of ubic.gemma.model.common.description.LocalFile in project Gemma by PavlidisLab.

the class HttpFetcherTest method testFetch.

/*
     * Test method for 'ubic.gemma.core.loader.loaderutils.HttpFetcher.fetch(String)'
     */
public void testFetch() {
    HttpFetcher hf = new HttpFetcher();
    try {
        hf.setForce(true);
        Collection<LocalFile> results = hf.fetch("http://www.yahoo.com");
        TestCase.assertNotNull(results);
        TestCase.assertTrue(results.size() > 0 && results.iterator().next().getLocalURL() != null);
        f = new File(results.iterator().next().getLocalURL().toURI());
        TestCase.assertTrue(f.length() > 0);
    } catch (Exception e) {
        if (e.getCause() instanceof IOException) {
            HttpFetcherTest.log.error("Got IOException, skipping test");
        }
    }
}
Also used : HttpFetcher(ubic.gemma.core.loader.util.fetcher.HttpFetcher) LocalFile(ubic.gemma.model.common.description.LocalFile) IOException(java.io.IOException) LocalFile(ubic.gemma.model.common.description.LocalFile) File(java.io.File) IOException(java.io.IOException)

Example 10 with LocalFile

use of ubic.gemma.model.common.description.LocalFile in project Gemma by PavlidisLab.

the class BatchInfoParser method getBatchInfo.

public Map<BioMaterial, Date> getBatchInfo(ExpressionExperiment ee, Collection<LocalFile> files) {
    Map<String, BioAssay> assayAccessions = this.getAccessionToBioAssayMap(ee);
    if (assayAccessions.isEmpty()) {
        throw new UnsupportedOperationException("Couldn't get any scan date information, could not determine provider or it is not supported for " + ee.getShortName());
    }
    Map<BioAssay, File> bioAssays2Files = this.matchBioAssaysToRawDataFiles(files, assayAccessions);
    /*
         * Check if we should go on
         */
    if (bioAssays2Files.size() < assayAccessions.size()) {
        if (bioAssays2Files.size() > 0) {
            /*
                 * Missing a few for some reason.
                 */
            for (BioAssay ba : bioAssays2Files.keySet()) {
                if (!assayAccessions.containsKey(ba.getAccession().getAccession())) {
                    BatchInfoParser.log.warn("Missing raw data file for " + ba + " on " + ee.getShortName());
                }
            }
        }
        throw new IllegalStateException("Did not get enough raw files :got " + bioAssays2Files.size() + ", expected " + assayAccessions.size() + " while processing " + ee.getShortName());
    }
    return this.getBatchInformationFromFiles(bioAssays2Files);
}
Also used : File(java.io.File) LocalFile(ubic.gemma.model.common.description.LocalFile) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

LocalFile (ubic.gemma.model.common.description.LocalFile)40 File (java.io.File)17 IOException (java.io.IOException)11 MalformedURLException (java.net.MalformedURLException)4 HashSet (java.util.HashSet)4 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)4 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)4 URL (java.net.URL)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)3 Taxon (ubic.gemma.model.genome.Taxon)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 AffyPowerToolsProbesetSummarize (ubic.gemma.core.loader.expression.AffyPowerToolsProbesetSummarize)2 RawDataFetcher (ubic.gemma.core.loader.expression.geo.fetcher.RawDataFetcher)2 HttpFetcher (ubic.gemma.core.loader.util.fetcher.HttpFetcher)2 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)2 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1