Search in sources :

Example 1 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference 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 BibliographicReference

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

the class PubMedXMLFetcherTest method testRetrieveByHTTP.

@Test
public final void testRetrieveByHTTP() {
    try {
        BibliographicReference br = pmf.retrieveByHTTP(15173114);
        assertNotNull(br);
        assertEquals("Lee, Homin K; Hsu, Amy K; Sajdak, Jon; Qin, Jie; Pavlidis, Paul", br.getAuthorList());
        assertEquals("Genome Res", br.getPublication());
        assertEquals("Coexpression analysis of human genes across many microarray data sets.", br.getTitle());
        SimpleDateFormat f = new SimpleDateFormat("mm/HH/MM/dd/yyyy");
        assertEquals("00/00/06/01/2004", f.format(br.getPublicationDate()));
    } catch (RuntimeException e) {
        this.checkCause(e);
    }
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 3 with BibliographicReference

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

the class PubMedXMLFetcherTest method testRetrieveByHTTP2.

@Test
public final void testRetrieveByHTTP2() {
    try {
        BibliographicReference br = pmf.retrieveByHTTP(24850731);
        assertNotNull(br);
        assertEquals("Iwata-Yoshikawa, Naoko; Uda, Akihiko; Suzuki, Tadaki; Tsunetsugu-Yokota, Yasuko; Sato, Yuko; " + "Morikawa, Shigeru; Tashiro, Masato; Sata, Tetsutaro; Hasegawa, Hideki; Nagata, Noriyo", br.getAuthorList());
        assertEquals("J Virol", br.getPublication());
    } catch (RuntimeException e) {
        this.checkCause(e);
    }
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test)

Example 4 with BibliographicReference

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

the class BibRefUpdaterCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception ex = super.processCommandLine(args);
    if (ex != null)
        return ex;
    BibliographicReferenceService bibliographicReferenceService = this.getBean(BibliographicReferenceService.class);
    Collection<Long> bibrefIds = new ArrayList<>();
    if (this.hasOption("pmids")) {
        for (String s : StringUtils.split(this.getOptionValue("pmids"), ",")) {
            BibliographicReference found = bibliographicReferenceService.findByExternalId(s);
            if (found == null) {
                log.warn("Did not find " + s);
                continue;
            }
            bibrefIds.add(found.getId());
        }
    } else {
        log.info("Updating all bibrefs in the system ...");
        bibrefIds = bibliographicReferenceService.listAll();
    }
    log.info("There are " + bibrefIds.size() + " to update");
    for (Long id : bibrefIds) {
        BibliographicReference bibref = bibliographicReferenceService.load(id);
        if (bibref == null) {
            log.info("No reference with id=" + id);
            continue;
        }
        bibref = bibliographicReferenceService.thaw(bibref);
        try {
            BibliographicReference updated = bibliographicReferenceService.refresh(bibref.getPubAccession().getAccession());
            log.info(updated);
        } catch (Exception e) {
            log.info("Failed to update: " + bibref + " (" + e.getMessage() + ")");
        }
        try {
            Thread.sleep(RandomUtils.nextInt(1000));
        } catch (InterruptedException e) {
            return e;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BibliographicReferenceService(ubic.gemma.core.annotation.reference.BibliographicReferenceService)

Example 5 with BibliographicReference

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

the class BibliographicReferenceServiceTest method testfind.

@Test
public final void testfind() {
    BibliographicReference result = this.bibliographicReferenceService.find(testBibRef);
    assertNotNull(result);
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Aggregations

BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)45 Test (org.junit.Test)18 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)9 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)6 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)5 SearchSettings (ubic.gemma.model.common.search.SearchSettings)4 ArrayList (java.util.ArrayList)3 IndexerTaskCommand (ubic.gemma.core.tasks.maintenance.IndexerTaskCommand)3 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)3 MedicalSubjectHeading (ubic.gemma.model.common.description.MedicalSubjectHeading)3 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 URL (java.net.URL)2 Date (java.util.Date)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ExternalDatabase (ubic.gemma.model.common.description.ExternalDatabase)2