Search in sources :

Example 31 with BibliographicReference

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

the class PubMedXMLFetcherTest method testRetrieveByHTTPBookshelf.

/*
     * 23865096 is a NCBI bookshelf article, not a paper
     */
@Test
public final void testRetrieveByHTTPBookshelf() {
    try {
        BibliographicReference br = pmf.retrieveByHTTP(23865096);
        assertNotNull(br);
        assertEquals("Tatton-Brown, Katrina; Rahman, Nazneen", br.getAuthorList());
        assertEquals("GeneReviews", br.getPublication().substring(0, "GeneReviews".length()));
        assertEquals("EZH2-Related Overgrowth", br.getTitle());
        SimpleDateFormat f = new SimpleDateFormat("yyyy");
        assertEquals("2013", 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 32 with BibliographicReference

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

the class ExpressionExperimentDaoImpl method thawReferences.

private void thawReferences(final ExpressionExperiment expressionExperiment) {
    if (expressionExperiment.getPrimaryPublication() != null) {
        Hibernate.initialize(expressionExperiment.getPrimaryPublication());
        Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPubAccession());
        Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPubAccession().getExternalDatabase());
        Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPublicationTypes());
    }
    if (expressionExperiment.getOtherRelevantPublications() != null) {
        Hibernate.initialize(expressionExperiment.getOtherRelevantPublications());
        for (BibliographicReference bf : expressionExperiment.getOtherRelevantPublications()) {
            Hibernate.initialize(bf.getPubAccession());
            Hibernate.initialize(bf.getPubAccession().getExternalDatabase());
            Hibernate.initialize(bf.getPublicationTypes());
        }
    }
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Example 33 with BibliographicReference

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

the class BibliographicReferenceServiceImpl method loadMultipleValueObjectsFromObjects.

@Transactional(readOnly = true)
public Collection<BibliographicReferenceValueObject> loadMultipleValueObjectsFromObjects(Collection<BibliographicReference> bibRefs) {
    if (bibRefs.isEmpty()) {
        return new ArrayList<>();
    }
    Map<Long, BibliographicReferenceValueObject> idToBibRefVO = new HashMap<>();
    for (BibliographicReference bibref : bibRefs) {
        BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(bibref);
        idToBibRefVO.put(bibref.getId(), vo);
    }
    this.populateRelatedExperiments(bibRefs, idToBibRefVO);
    this.populateBibliographicPhenotypes(idToBibRefVO);
    return idToBibRefVO.values();
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 34 with BibliographicReference

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

the class BibliographicReferenceServiceImpl method search.

@Override
@Transactional(readOnly = true)
public List<BibliographicReferenceValueObject> search(SearchSettingsValueObject settings) {
    SearchSettings ss = SearchSettingsImpl.bibliographicReferenceSearch(settings.getQuery());
    // noinspection unchecked
    List<BibliographicReference> resultEntities = (List<BibliographicReference>) searchService.search(ss, BibliographicReference.class);
    List<BibliographicReferenceValueObject> results = new ArrayList<>();
    // only return associations with the selected entity types.
    for (BibliographicReference entity : resultEntities) {
        BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(entity);
        if (settings.getSearchPhenotypes() || settings.getSearchBibrefs()) {
            this.populateBibliographicPhenotypes(vo);
            if (!vo.getBibliographicPhenotypes().isEmpty() || settings.getSearchBibrefs()) {
                results.add(vo);
            }
        }
        if (settings.getSearchExperiments() || settings.getSearchBibrefs()) {
            this.populateRelatedExperiments(entity, vo);
            if (!vo.getExperiments().isEmpty() || settings.getSearchBibrefs()) {
                results.add(vo);
            }
        }
        if (settings.getSearchBibrefs() && !settings.getSearchPhenotypes() && !settings.getSearchExperiments()) {
            results.add(vo);
        }
    }
    return results;
}
Also used : SearchSettings(ubic.gemma.model.common.search.SearchSettings) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with BibliographicReference

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

the class PubMedSearch method searchAndRetrieveByHTTP.

/**
 * Search based on terms
 *
 * @param searchTerms search terms
 * @return BibliographicReference representing the publication
 * @throws IOException IO problems
 */
public Collection<BibliographicReference> searchAndRetrieveByHTTP(Collection<String> searchTerms) throws IOException, SAXException, ParserConfigurationException {
    StringBuilder builder = new StringBuilder();
    builder.append(uri);
    builder.append("&term=");
    for (String string : searchTerms) {
        builder.append(string);
        builder.append("+");
    }
    URL toBeGotten = new URL(StringUtils.chomp(builder.toString()));
    log.info("Fetching " + toBeGotten);
    ESearchXMLParser parser = new ESearchXMLParser();
    Collection<String> ids = parser.parse(toBeGotten.openStream());
    Collection<BibliographicReference> results = fetchById(ids);
    log.info("Fetched " + results.size() + " references");
    return results;
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) URL(java.net.URL)

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