Esempio n. 1
0
def get_pubmed_from_doi(doi):
    'try to get pubmed dict for this DOI, or None if not found'
    import pubmed
    xml = pubmed.search_pubmed(doi, retmax='1', field='LID')
    try:
        d, root = pubmed.dict_from_xml(xml, pubmedID='!Id')
    except KeyError: # some DOI not properly indexed in pubmed?!?!
        xml = pubmed.search_pubmed(doi, retmax='1')
        try:
            d, root = pubmed.dict_from_xml(xml, pubmedID='!Id')
        except KeyError:
            pass
        else: # have to check whether title matches
            pubmedDict = pubmed.get_pubmed_dict(d['pubmedID'])
            if pubmedDict.get('title')[:50].lower() == \
               doiDict.get('title')[:50].lower():
                return pubmedDict
            
    else:
        return pubmed.get_pubmed_dict(d['pubmedID'])
Esempio n. 2
0
def doi_dict_from_xml(xml, title='title', year='publication_date.year',
                      volume='journal_volume.volume',
                      source_url='doi_data.resource', **kwargs):
    import pubmed
    d, root = pubmed.dict_from_xml(xml, title=title, year=year, volume=volume,
                                   source_url=source_url, **kwargs)
    authorNames = [] # extract list of author names
    for o in root.findall('.//person_name'):
        authorNames.append(safe_text(o, 'given_name') + ' ' +
                           safe_text(o, 'surname'))
    d['authorNames'] = authorNames
    return d