Search in sources :

Example 1 with ExpressionExperimentService

use of ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService in project Gemma by PavlidisLab.

the class GeoBrowserServiceParseTest method testParse.

@Test
public void testParse() throws Exception {
    String response = "<?xml version=\"1.0\"?>\n<!DOCTYPE eSummaryResult PUBLIC \"-//NLM//DTD eSummaryResult, 29 October 2004//EN\" \"http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSummary_041029.dtd\">\n" + "<eSummaryResult> <DocSum>   <Id>200004595</Id>  <Item Name=\"GDS\" Type=\"String\"></Item>  <Item Name=\"title\" Type=\"String\">Expression profiling of motor cortex in sporadic amyotrophic lateral sclerosis</Item> " + " <Item Name=\"summary\" Type=\"String\">We used oligonucleotide microarrays to find differentially" + " expressed genes between control subjects and those affected by sporadic amyotrophic lateral sclerosis. Keywords: disease state analysis</Item>   " + " <Item Name=\"GPL\" Type=\"String\">1708</Item>  <Item Name=\"GSE\" Type=\"String\">4595</Item>  <Item Name=\"taxon\" Type=\"String\">Homo sapiens</Item>  " + "  <Item Name=\"GSM_L\" Type=\"String\"></Item>    <Item Name=\"GSM_titles_L\" Type=\"String\"></Item>   " + "  <Item Name=\"entryType\" Type=\"String\">GSE</Item>   " + "  <Item Name=\"gdsType\" Type=\"String\">Expression profiling by array</Item>   " + "  <Item Name=\"ptechType\" Type=\"String\"></Item>    <Item Name=\"valType\" Type=\"String\"></Item> " + " <Item Name=\"SSInfo\" Type=\"String\"></Item>   <Item Name=\"subsetInfo\" Type=\"String\"></Item> " + "  <Item Name=\"PDAT\" Type=\"String\">2007/03/26</Item>   <Item Name=\"suppFile\" Type=\"String\"></Item>  " + "   <Item Name=\"Samples\" Type=\"List\">       <Item Name=\"Sample\" Type=\"Structure\">    " + "       <Item Name=\"Accession\" Type=\"String\">GSM102829</Item>      " + "     <Item Name=\"Title\" Type=\"String\">Control 2</Item>       </Item>    " + "    <Item Name=\"Sample\" Type=\"Structure\">       " + "    <Item Name=\"Accession\" Type=\"String\">GSM102832</Item>     " + "      <Item Name=\"Title\" Type=\"String\">Control 5</Item>   " + "    </Item>         <Item Name=\"Sample\" Type=\"Structure\">    " + "       <Item Name=\"Accession\" Type=\"String\">GSM102835</Item>  " + "        <Item Name=\"Title\" Type=\"String\">Control 8</Item>      " + " </Item>         <Item Name=\"Sample\" Type=\"Structure\">       " + "    <Item Name=\"Accession\" Type=\"String\">GSM102838</Item>       " + "    <Item Name=\"Title\" Type=\"String\">Diseased 2</Item>      </Item>   " + "      <Item Name=\"Sample\" Type=\"Structure\">        " + "   <Item Name=\"Accession\" Type=\"String\">GSM102845</Item>   " + "        <Item Name=\"Title\" Type=\"String\">Diseased 7</Item>      </Item>   " + "      <Item Name=\"Sample\" Type=\"Structure\">         " + "  <Item Name=\"Accession\" Type=\"String\">GSM102830</Item>    " + "       <Item Name=\"Title\" Type=\"String\">Control 3</Item>       </Item>   " + "      <Item Name=\"Sample\" Type=\"Structure\">  " + "         <Item Name=\"Accession\" Type=\"String\">GSM102837</Item>     " + "      <Item Name=\"Title\" Type=\"String\">Diseased 1</Item>      </Item>   " + "      <Item Name=\"Sample\" Type=\"Structure\">         " + "  <Item Name=\"Accession\" Type=\"String\">GSM102840</Item>   " + "        <Item Name=\"Title\" Type=\"String\">Diseased 4</Item>      </Item>  " + "      <Item Name=\"Sample\" Type=\"Structure\">   " + "        <Item Name=\"Accession\" Type=\"String\">GSM102846</Item>   " + "        <Item Name=\"Title\" Type=\"String\">Diseased 8</Item>      </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">     " + "      <Item Name=\"Accession\" Type=\"String\">GSM102828</Item>       " + "    <Item Name=\"Title\" Type=\"String\">Control 1</Item>       </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">      " + "     <Item Name=\"Accession\" Type=\"String\">GSM102831</Item>    " + "       <Item Name=\"Title\" Type=\"String\">Control 4</Item>       </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">    " + "      <Item Name=\"Accession\" Type=\"String\">GSM102834</Item>   " + "       <Item Name=\"Title\" Type=\"String\">Control 7</Item>       </Item>    " + "     <Item Name=\"Sample\" Type=\"Structure\">    " + "      <Item Name=\"Accession\" Type=\"String\">GSM102841</Item>     " + "     <Item Name=\"Title\" Type=\"String\">Diseased 5</Item>      </Item>    " + "     <Item Name=\"Sample\" Type=\"Structure\">      " + "     <Item Name=\"Accession\" Type=\"String\">GSM102844</Item>    " + "      <Item Name=\"Title\" Type=\"String\">Diseased 6</Item>      </Item>    " + "     <Item Name=\"Sample\" Type=\"Structure\">     " + "      <Item Name=\"Accession\" Type=\"String\">GSM102847</Item>    " + "       <Item Name=\"Title\" Type=\"String\">Diseased 9</Item>      </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">     " + "     <Item Name=\"Accession\" Type=\"String\">GSM102833</Item>    " + "       <Item Name=\"Title\" Type=\"String\">Control 6</Item>       </Item>      " + "   <Item Name=\"Sample\" Type=\"Structure\">      " + "     <Item Name=\"Accession\" Type=\"String\">GSM102836</Item>     " + "      <Item Name=\"Title\" Type=\"String\">Control 9</Item>       </Item>    " + "     <Item Name=\"Sample\" Type=\"Structure\">     " + "      <Item Name=\"Accession\" Type=\"String\">GSM102839</Item>      " + "     <Item Name=\"Title\" Type=\"String\">Diseased 3</Item>      </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">      " + "     <Item Name=\"Accession\" Type=\"String\">GSM102849</Item>     " + "      <Item Name=\"Title\" Type=\"String\">Diseased 10</Item>         </Item>     " + "    <Item Name=\"Sample\" Type=\"Structure\">     " + "     <Item Name=\"Accession\" Type=\"String\">GSM102852</Item>    " + "       <Item Name=\"Title\" Type=\"String\">Diseased 11</Item>         </Item> " + "    </Item>     <Item Name=\"Relations\" Type=\"List\"></Item> " + " <Item Name=\"n_samples\" Type=\"Integer\">20</Item>  " + "   <Item Name=\"SeriesTitle\" Type=\"String\"></Item> " + " <Item Name=\"PlatformTitle\" Type=\"String\"></Item>   " + " <Item Name=\"PlatformTaxa\" Type=\"String\"></Item>  " + "   <Item Name=\"SamplesTaxa\" Type=\"String\"></Item> " + " <Item Name=\"PubMedIds\" Type=\"List\">   " + "      <Item Name=\"int\" Type=\"Integer\">17244347</Item>     </Item>  " + "   <Item Name=\"Projects\" Type=\"List\"></Item> </DocSum> " + " <DocSum>   <Id>100001708</Id>  <Item Name=\"GDS\" Type=\"String\">2080;2824;3268;3429;3432;3433</Item>   " + "  <Item Name=\"title\" Type=\"String\">Agilent-012391 Whole Human Genome Oligo Microarray G4112A (Feature Number version)</Item> " + " <Item Name=\"summary\" Type=\"String\">This single 44K formatted microarray represents a compiled view of the human genome as it is understood today." + " The sequence information used to design this product was derived from a broad survey of well known sources such as RefSeq, Goldenpath, Ensembl, Unigene and others." + " The resulting view of the human genome covers 41K unique genes and transcripts which have been verified and optimized by alignment to the human genome assembly " + "and by Agilent's Empirical Validation process. Arrays of this design have barcodes that begin with 16012391 or 2512391." + " Orientation: Features are numbered numbered Left-to-Right, Top-to-Bottom as scanned by an Agilent scanner (barcode on the left, DNA on the back surface," + " scanned through the glass), matching the FeatureNum output from Agilent's Feature Extraction software. The ID column represents the Agilent " + "Feature Extraction feature number. Rows and columns are numbered as scanned by an Axon Scanner (barcode on the bottom, DNA on the front surface). To match data scanned on an Axon scanner, " + "use the RefNumber column contained in the Agilent-provided GAL file as the ID_REF column in sample submissions. " + "*** A different version of this platform with the Agilent Probe names in the ID column is assigned accession number GPL6848. Protocol: see manufacturer's web site at http://www.agilent.com/</Item>   " + "  <Item Name=\"GPL\" Type=\"String\">1708</Item> " + " <Item Name=\"GSE\" Type=\"String\">2740;4809;4864;5272;5346;5966;6711;7190;8347;8511;8845;9709;9815;10198;11223;11422;12164;14063;15956;18276;18372;20062;20191;25303;25534;2035;4214;4763;7215;7315;" + "7469;8873;9014;10621;11003;11064;12154;12244;12449;12472;15110;15862;16957;18188;" + "20582;20881;3155;4595;4707;4823;4906;5176;5350;5546;7316;7329;7413;7512;8190;9170;9578;10195;10613;11108;11423;" + "11429;11975;12428;13029;15356;15838;15966;16255;23851;25143;25175;4117;4901;6427;7317;7410;7423;7960;8834;8917;" + "9637;10601;10704;12391;12622;13673;14466;15112;15363;15739;17011;18229;20147;20350;23611;24151;24639</Item>  " + "   <Item Name=\"taxon\" Type=\"String\">Homo sapiens</Item> " + "   <Item Name=\"GSM_L\" Type=\"String\"></Item>    <Item Name=\"GSM_titles_L\" Type=\"String\"></Item>   " + "  <Item Name=\"entryType\" Type=\"String\">GPL</Item>     <Item Name=\"gdsType\" Type=\"String\"></Item> " + " <Item Name=\"ptechType\" Type=\"String\">in situ oligonucleotide</Item>  " + "   <Item Name=\"valType\" Type=\"String\"></Item>  <Item Name=\"SSInfo\" Type=\"String\"></Item> " + "  <Item Name=\"subsetInfo\" Type=\"String\"></Item>   <Item Name=\"PDAT\" Type=\"String\">2004/11/17</Item>   " + "<Item Name=\"suppFile\" Type=\"String\"></Item>     <Item Name=\"Samples\" Type=\"List\"></Item> " + "   <Item Name=\"Relations\" Type=\"List\">         <Item Name=\"Relation\" Type=\"Structure\">     " + "        <Item Name=\"RelationType\" Type=\"String\">Alternative to</Item>      " + "     <Item Name=\"TargetObject\" Type=\"String\">GPL6848</Item>      </Item>     </Item>  " + "   <Item Name=\"n_samples\" Type=\"Integer\">2758</Item>   <Item Name=\"SeriesTitle\" Type=\"String\"></Item> " + " <Item Name=\"PlatformTitle\" Type=\"String\"></Item>    <Item Name=\"PlatformTaxa\" Type=\"String\"></Item>  " + "   <Item Name=\"SamplesTaxa\" Type=\"String\"></Item>  <Item Name=\"PubMedIds\" Type=\"List\"></Item>" + "  <Item Name=\"Projects\" Type=\"List\"></Item> </DocSum>  </eSummaryResult>";
    GeoBrowserServiceImpl serv = new GeoBrowserServiceImpl();
    serv.afterPropertiesSet();
    ArrayDesignService ads = createMock(ArrayDesignService.class);
    ExpressionExperimentService ees = createMock(ExpressionExperimentService.class);
    serv.arrayDesignService = ads;
    serv.expressionExperimentService = ees;
    expect(ads.findByShortName("GPL1708")).andReturn(null);
    expect(ees.findByShortName("GSE4595")).andReturn(null);
    // expect( ads.thawLite( null ) ).andReturn( null );
    replay(ads);
    serv.formatDetails(response);
}
Also used : ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) ArrayDesignService(ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService) Test(org.junit.Test)

Example 2 with ExpressionExperimentService

use of ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService in project Gemma by PavlidisLab.

the class GeoBrowserServiceParseTest method testParse2.

@Test
public void testParse2() throws Exception {
    try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/geo/geo.esummary.test1.xml");
        BufferedReader r = new BufferedReader(new InputStreamReader(is))) {
        String l;
        StringBuilder buf = new StringBuilder();
        while ((l = r.readLine()) != null) {
            buf.append(l);
        }
        String response = buf.toString();
        GeoBrowserServiceImpl serv = new GeoBrowserServiceImpl();
        serv.afterPropertiesSet();
        ArrayDesignService ads = createMock(ArrayDesignService.class);
        ExpressionExperimentService ees = createMock(ExpressionExperimentService.class);
        serv.arrayDesignService = ads;
        serv.expressionExperimentService = ees;
        expect(ads.findByShortName("GPL570")).andReturn(null);
        expect(ees.findByShortName("GSE27128")).andReturn(null);
        replay(ads);
        serv.formatDetails(response);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) ArrayDesignService(ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService) Test(org.junit.Test)

Example 3 with ExpressionExperimentService

use of ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService 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 4 with ExpressionExperimentService

use of ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService in project Gemma by PavlidisLab.

the class ExperimentalDesignImportCli method locateExpressionExperiment.

/**
 * @param shortName short name of the experiment to find.
 * @return experiment with the given short name, if it exists. Bails otherwise with {@link ubic.gemma.core.util.AbstractCLI.ErrorCode#INVALID_OPTION}.
 */
// Possible external use
@SuppressWarnings({ "unused", "WeakerAccess" })
protected ExpressionExperiment locateExpressionExperiment(String shortName) {
    if (shortName == null) {
        errorObjects.add("Expression experiment short name must be provided");
        return null;
    }
    ExpressionExperimentService eeService = this.getBean(ExpressionExperimentService.class);
    ExpressionExperiment experiment = eeService.findByShortName(shortName);
    if (experiment == null) {
        AbstractCLI.log.error("No experiment " + shortName + " found");
        this.bail(ErrorCode.INVALID_OPTION);
    }
    return experiment;
}
Also used : ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 5 with ExpressionExperimentService

use of ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService in project Gemma by PavlidisLab.

the class ExperimentalDesignImportCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception e = this.processCommandLine(args);
    if (e != null)
        return e;
    ExperimentalFactorOntologyService mos = this.getBean(OntologyService.class).getExperimentalFactorOntologyService();
    mos.startInitializationThread(true);
    while (!mos.isOntologyLoaded()) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e1) {
        // 
        }
        AbstractCLI.log.info("Waiting for EFO to load");
    }
    ExperimentalDesignImporter edImp = this.getBean(ExperimentalDesignImporter.class);
    ExpressionExperimentService ees = this.getBean(ExpressionExperimentService.class);
    expressionExperiment = ees.thawBioAssays(expressionExperiment);
    try {
        edImp.importDesign(expressionExperiment, inputStream);
    } catch (IOException e1) {
        return e1;
    }
    return null;
}
Also used : ExperimentalFactorOntologyService(ubic.basecode.ontology.providers.ExperimentalFactorOntologyService) OntologyService(ubic.gemma.core.ontology.OntologyService) ExperimentalFactorOntologyService(ubic.basecode.ontology.providers.ExperimentalFactorOntologyService) ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) ExperimentalDesignImporter(ubic.gemma.core.loader.expression.simple.ExperimentalDesignImporter)

Aggregations

ExpressionExperimentService (ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService)10 Test (org.junit.Test)4 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 ArrayDesignService (ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService)3 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 ExperimentalFactorOntologyService (ubic.basecode.ontology.providers.ExperimentalFactorOntologyService)1 ExpressionExperimentBibRefFinder (ubic.gemma.core.loader.entrez.pubmed.ExpressionExperimentBibRefFinder)1 PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)1 GeoRecord (ubic.gemma.core.loader.expression.geo.model.GeoRecord)1 GeoBrowserService (ubic.gemma.core.loader.expression.geo.service.GeoBrowserService)1 ExperimentalDesignImporter (ubic.gemma.core.loader.expression.simple.ExperimentalDesignImporter)1 OntologyService (ubic.gemma.core.ontology.OntologyService)1 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)1