Search in sources :

Example 1 with PubMedXMLFetcher

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher in project Gemma by PavlidisLab.

the class SearchServiceTest method testSearchByBibRefId.

@Test
public void testSearchByBibRefId() {
    try {
        this.setup();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String id;
    if (ee.getPrimaryPublication() == null) {
        PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
        BibliographicReference bibref = fetcher.retrieveByHTTP(21878914);
        bibref = (BibliographicReference) persisterHelper.persist(bibref);
        ee.setPrimaryPublication(bibref);
        eeService.update(ee);
        id = "21878914";
    } else {
        id = ee.getPrimaryPublication().getPubAccession().getAccession();
    }
    log.info("indexing ...");
    IndexerTaskCommand c = new IndexerTaskCommand();
    c.setIndexBibRef(true);
    indexerTask.setTaskCommand(c);
    indexerTask.execute();
    SearchSettings settings = SearchSettings.Factory.newInstance();
    settings.noSearches();
    settings.setQuery(id);
    settings.setSearchExperiments(true);
    settings.setUseCharacteristics(false);
    Map<Class<?>, List<SearchResult>> found = this.searchService.search(settings);
    assertTrue(!found.isEmpty());
    for (SearchResult sr : found.get(ExpressionExperiment.class)) {
        if (sr.getResultObject().equals(ee)) {
            this.tearDown();
            return;
        }
    }
    this.tearDown();
    fail("Didn't get expected result from search");
}
Also used : IndexerTaskCommand(ubic.gemma.core.tasks.maintenance.IndexerTaskCommand) SearchSettings(ubic.gemma.model.common.search.SearchSettings) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 2 with PubMedXMLFetcher

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher 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 3 with PubMedXMLFetcher

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher in project Gemma by PavlidisLab.

the class GeoServiceImpl method getPubMedInfo.

private void getPubMedInfo(Collection<ExpressionExperiment> result) {
    for (ExpressionExperiment experiment : result) {
        BibliographicReference pubmed = experiment.getPrimaryPublication();
        if (pubmed == null)
            continue;
        PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
        try {
            pubmed = fetcher.retrieveByHTTP(Integer.parseInt(pubmed.getPubAccession().getAccession()));
        } catch (Exception e) {
            AbstractGeoService.log.warn("Filed to get data from pubmed, continuing without it.");
            AbstractGeoService.log.error(e, e);
        }
        if (pubmed == null)
            continue;
        experiment.setPrimaryPublication(pubmed);
    }
}
Also used : PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException)

Example 4 with PubMedXMLFetcher

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher in project Gemma by PavlidisLab.

the class SearchServiceTest method testSearchByBibRefIdProblemsB.

@Test
public void testSearchByBibRefIdProblemsB() {
    try {
        this.setup();
    } catch (Exception e) {
        e.printStackTrace();
    }
    PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
    BibliographicReference bibref = fetcher.retrieveByHTTP(22780917);
    bibref = (BibliographicReference) persisterHelper.persist(bibref);
    assertTrue(bibref.getAbstractText().contains("d to chromosome 22q12. Our results confirm chromosome 22q12 as the solitary locus for FFEVF"));
    IndexerTaskCommand c = new IndexerTaskCommand();
    c.setIndexBibRef(true);
    indexerTask.setTaskCommand(c);
    indexerTask.execute();
    SearchSettings settings = SearchSettings.Factory.newInstance();
    settings.noSearches();
    settings.setQuery("confirm chromosome 22q12");
    settings.setSearchBibrefs(true);
    Map<Class<?>, List<SearchResult>> found = this.searchService.search(settings);
    assertTrue(!found.isEmpty());
    for (SearchResult sr : found.get(BibliographicReference.class)) {
        if (sr.getResultObject().equals(bibref)) {
            this.tearDown();
            return;
        }
    }
    this.tearDown();
    fail("Didn't get expected result from search");
}
Also used : IndexerTaskCommand(ubic.gemma.core.tasks.maintenance.IndexerTaskCommand) SearchSettings(ubic.gemma.model.common.search.SearchSettings) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 5 with PubMedXMLFetcher

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher in project Gemma by PavlidisLab.

the class SearchServiceTest method testSearchByBibRefIdProblems.

@Test
public void testSearchByBibRefIdProblems() {
    try {
        this.setup();
    } catch (Exception e) {
        e.printStackTrace();
    }
    PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
    BibliographicReference bibref = fetcher.retrieveByHTTP(9600966);
    bibref = (BibliographicReference) persisterHelper.persist(bibref);
    assertTrue(bibref.getAbstractText().contains("ase proved to be a de novo mutation. In the third kindred, affected brothers both have a"));
    IndexerTaskCommand c = new IndexerTaskCommand();
    c.setIndexBibRef(true);
    indexerTask.setTaskCommand(c);
    indexerTask.execute();
    SearchSettings settings = SearchSettings.Factory.newInstance();
    settings.noSearches();
    settings.setQuery("de novo mutation");
    settings.setSearchBibrefs(true);
    Map<Class<?>, List<SearchResult>> found = this.searchService.search(settings);
    assertTrue(!found.isEmpty());
    for (SearchResult sr : found.get(BibliographicReference.class)) {
        if (sr.getResultObject().equals(bibref)) {
            this.tearDown();
            return;
        }
    }
    this.tearDown();
    fail("Didn't get expected result from search");
}
Also used : IndexerTaskCommand(ubic.gemma.core.tasks.maintenance.IndexerTaskCommand) SearchSettings(ubic.gemma.model.common.search.SearchSettings) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Aggregations

PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)7 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)6 Test (org.junit.Test)3 IndexerTaskCommand (ubic.gemma.core.tasks.maintenance.IndexerTaskCommand)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 SearchSettings (ubic.gemma.model.common.search.SearchSettings)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ExpressionExperimentBibRefFinder (ubic.gemma.core.loader.entrez.pubmed.ExpressionExperimentBibRefFinder)1 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)1 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)1 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)1 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)1 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)1 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)1 ExperimentalDesign (ubic.gemma.model.expression.experiment.ExperimentalDesign)1 Taxon (ubic.gemma.model.genome.Taxon)1 Persister (ubic.gemma.persistence.persister.Persister)1 ExpressionExperimentService (ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService)1