Skip to content
Snippets Groups Projects
Commit 7a74aa2c authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add patent info web service, and harden a bit pubmed info parsing

parent 0d865563
No related branches found
No related tags found
No related merge requests found
from bioservices.eutils import EUtils from bioservices.eutils import EUtils
import requests
def get_pubmed_info(pmid): def get_pubmed_info(pmid):
eu = EUtils() eu = EUtils()
...@@ -8,8 +9,26 @@ def get_pubmed_info(pmid): ...@@ -8,8 +9,26 @@ def get_pubmed_info(pmid):
authors_list = [a['LastName']+ ' ' + a['Initials'] for a in article['AuthorList']['Author']] authors_list = [a['LastName']+ ' ' + a['Initials'] for a in article['AuthorList']['Author']]
authors = ', '.join(authors_list) authors = ', '.join(authors_list)
journal_name = article['Journal']['Title'] journal_name = article['Journal']['Title']
biblio_year = article['Journal']['JournalIssue']['PubDate']['Year'] biblio_date = article['Journal']['JournalIssue']['PubDate']
if 'Year' in biblio_date:
biblio_year = biblio_date['Year']
else:
biblio_year = biblio_date['MedlineDate'][0:3]
return {'title':title, return {'title':title,
'journal_name':journal_name, 'journal_name':journal_name,
'biblio_year':biblio_year, 'biblio_year':biblio_year,
'authors_list': authors} 'authors_list': authors}
def get_epo_info(patent_number):
resp = requests.get('http://ops.epo.org/3.1/rest-services/published-data/publication/docdb/{}/biblio.json'.format(patent_number))
data = resp.json()
exchange_doc = data['ops:world-patent-data']['exchange-documents']['exchange-document']
if isinstance(exchange_doc, list):
exchange_doc = exchange_doc[0]
title = [el['$'] for el in exchange_doc['bibliographic-data']['invention-title'] if el['@lang']=='en']
authors = [i['inventor-name']['name']['$'] for i in exchange_doc['bibliographic-data']['parties']['inventors']['inventor'] if i['@data-format']=='original']
biblio_year = [el['date']['$'][:4] for el in exchange_doc['bibliographic-data']['publication-reference']['document-id'] if el['@document-id-type']=='epodoc'][0]
return {'title': title,
'journal_name': None,
'biblio_year': biblio_year,
'authors_list': authors}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment