Search in sources :

Example 11 with BibliographicReference

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

the class PubMedXMLParserTest method testParseMultipartAbstract.

@Test
public void testParseMultipartAbstract() {
    try {
        testStream = PubMedXMLParserTest.class.getResourceAsStream("/data/pubmed-mpabs.xml");
        Collection<BibliographicReference> brl = testParser.parse(testStream);
        BibliographicReference br = brl.iterator().next();
        assertNotNull(br.getAbstractText());
        assertTrue(br.getAbstractText().startsWith("PURPOSE: To dete"));
        assertTrue(br.getAbstractText().contains("METHODS: RGCs of Brown Norway rats were retrogradely labeled bilaterally with the " + "fluorescent dye 4-(4-(dihexadecylamino)styryl)-N"));
        assertTrue(br.getAbstractText().contains("CONCLUSIONS: The SLO is useful for in vivo imaging of rat RGCs"));
        PubMedXMLParserTest.log.info(br.getAbstractText());
    } catch (RuntimeException e) {
        this.logOrThrowException(e);
    }
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test)

Example 12 with BibliographicReference

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

the class BibliographicReferenceServiceImpl method refresh.

@Override
@Transactional
public BibliographicReference refresh(String pubMedId) {
    if (StringUtils.isBlank(pubMedId)) {
        throw new IllegalArgumentException("Must provide a pubmed ID");
    }
    BibliographicReference existingBibRef = this.findByExternalId(pubMedId, BibliographicReferenceServiceImpl.PUB_MED_DATABASE_NAME);
    if (existingBibRef == null) {
        return null;
    }
    existingBibRef = this.thaw(existingBibRef);
    String oldAccession = existingBibRef.getPubAccession().getAccession();
    if (StringUtils.isNotBlank(oldAccession) && !oldAccession.equals(pubMedId)) {
        throw new IllegalArgumentException("The pubmed accession is already set and doesn't match the one provided");
    }
    existingBibRef.getPubAccession().setAccession(pubMedId);
    BibliographicReference fresh = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(pubMedId));
    if (fresh == null || fresh.getPublicationDate() == null) {
        throw new IllegalStateException("Unable to retrieve record from pubmed for id=" + pubMedId);
    }
    assert fresh.getPubAccession().getAccession().equals(pubMedId);
    existingBibRef.setPublicationDate(fresh.getPublicationDate());
    existingBibRef.setAuthorList(fresh.getAuthorList());
    existingBibRef.setAbstractText(fresh.getAbstractText());
    existingBibRef.setIssue(fresh.getIssue());
    existingBibRef.setTitle(fresh.getTitle());
    existingBibRef.setFullTextUri(fresh.getFullTextUri());
    existingBibRef.setEditor(fresh.getEditor());
    existingBibRef.setPublisher(fresh.getPublisher());
    existingBibRef.setCitation(fresh.getCitation());
    existingBibRef.setPublication(fresh.getPublication());
    existingBibRef.setMeshTerms(fresh.getMeshTerms());
    existingBibRef.setChemicals(fresh.getChemicals());
    existingBibRef.setKeywords(fresh.getKeywords());
    existingBibRef.setPages(fresh.getPages());
    existingBibRef.setVolume(fresh.getVolume());
    this.update(existingBibRef);
    return existingBibRef;
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 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(String query) {
    // noinspection unchecked
    List<BibliographicReference> resultEntities = (List<BibliographicReference>) searchService.search(SearchSettingsImpl.bibliographicReferenceSearch(query), BibliographicReference.class);
    List<BibliographicReferenceValueObject> results = new ArrayList<>();
    for (BibliographicReference entity : resultEntities) {
        BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(entity);
        this.populateBibliographicPhenotypes(vo);
        this.populateRelatedExperiments(entity, vo);
        results.add(vo);
    }
    return results;
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with BibliographicReference

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

the class BibliographicReferenceServiceImpl method findVOByExternalId.

/**
 * @see BibliographicReferenceService#findVOByExternalId(String)
 */
@Override
@Transactional(readOnly = true)
public BibliographicReferenceValueObject findVOByExternalId(final String id) {
    try {
        BibliographicReference bibref = this.findByExternalId(id);
        if (bibref == null) {
            return null;
        }
        BibliographicReferenceValueObject bibrefVO = new BibliographicReferenceValueObject(bibref);
        this.populateBibliographicPhenotypes(bibrefVO);
        this.populateRelatedExperiments(bibref, bibrefVO);
        return bibrefVO;
    } catch (Throwable th) {
        throw new RuntimeException("Error performing 'BibliographicReferenceService.findByExternalId(String id)' --> " + th, th);
    }
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with BibliographicReference

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

the class MeshTermFetcherCli method processChunk.

private void processChunk(PubMedXMLFetcher fetcher, Collection<Integer> ids) throws IOException {
    Collection<BibliographicReference> refs = fetcher.retrieveByHTTP(ids);
    for (BibliographicReference r : refs) {
        System.out.print(r.getPubAccession().getAccession() + "\t");
        Collection<MedicalSubjectHeading> meshTerms = r.getMeshTerms();
        List<String> t = new ArrayList<>();
        for (MedicalSubjectHeading mesh : meshTerms) {
            String term = mesh.getTerm();
            if (majorTopicsOnly && !mesh.getIsMajorTopic())
                continue;
            t.add(term);
        }
        Collections.sort(t);
        System.out.print(StringUtils.join(t, "|"));
        System.out.print("\n");
    }
}
Also used : ArrayList(java.util.ArrayList) MedicalSubjectHeading(ubic.gemma.model.common.description.MedicalSubjectHeading) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

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