From 0440f233c19eb07ec3cc1267de16a0f2daeffd27 Mon Sep 17 00:00:00 2001 From: kkaris Date: Wed, 13 Dec 2023 16:44:56 -0800 Subject: [PATCH] Add function to get publication types per PubmedArticle --- indra/literature/pubmed_client.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/indra/literature/pubmed_client.py b/indra/literature/pubmed_client.py index 3ee913316f..a81c7075b1 100644 --- a/indra/literature/pubmed_client.py +++ b/indra/literature/pubmed_client.py @@ -934,4 +934,21 @@ def get_all_ids(search_term): # If there are more than 10k IDs, the CLI outputs a . for each # iteration, these have to be filtered out pmids = [e for e in elements if '.' not in e] - return pmids \ No newline at end of file + return pmids + + +def get_publication_types(article: ET.Element): + """Return the set of PublicationType for the article + + Parameters + ---------- + article : + The XML element for the article. Typically, this is a PubmedArticle + node. + + Returns + ------- + : set[str] + A set of publication type + """ + return {pt.text for pt in article.find('.//PublicationTypeList')}