Skip to content

Commit

Permalink
Change the retractions API and resource name
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Dec 31, 2023
1 parent b5f3a0e commit 8bed86e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
11 changes: 5 additions & 6 deletions indra/literature/pubmed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import os
import re
import time
from pathlib import Path

import tqdm
import logging
import random
import subprocess
import requests
from time import sleep
from typing import List
from pathlib import Path
from functools import lru_cache
import xml.etree.ElementTree as ET
from indra.resources import RESOURCES_PATH
Expand All @@ -30,7 +29,7 @@
pubmed_archive = "https://ftp.ncbi.nlm.nih.gov/pubmed"
pubmed_archive_baseline = pubmed_archive + "/baseline/"
pubmed_archive_update = pubmed_archive + "/updatefiles/"
RETRACTIONS_FILE = RESOURCES_PATH + "/pmid_retractions.tsv"
RETRACTIONS_FILE = os.path.join(RESOURCES_PATH, "pubmed_retractions.tsv")


# Send request can't be cached by lru_cache because it takes a dict
Expand Down Expand Up @@ -966,20 +965,20 @@ def get_publication_types(article: ET.Element):
return {pt.text for pt in article.find('.//PublicationTypeList')}


def article_is_retracted(pmid: str) -> bool:
def is_retracted(pubmed_id: str) -> bool:
"""Return True if the article with the given PMID has been retracted.
Parameters
----------
pmid :
pubmed_id :
The PMID of the paper to check.
Returns
-------
:
True if the paper has been retracted, False otherwise.
"""
return retractions.is_retracted(pmid)
return retractions.is_retracted(pubmed_id)


def generate_retractions_file(xml_path: str, download_missing: bool = False):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions indra/tests/test_pubmed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,5 @@ def test_get_substance_annotations():


def test_is_retracted():
assert pubmed_client.article_is_retracted('35463694')
assert not pubmed_client.article_is_retracted('36938926')
assert pubmed_client.is_retracted('35463694')
assert not pubmed_client.is_retracted('36938926')
5 changes: 3 additions & 2 deletions indra/tools/assemble_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from indra.preassembler import Preassembler, flatten_evidence
from indra.resources import get_resource_path
from indra.statements.validate import print_validation_report
from indra.literature.pubmed_client import article_is_retracted
from indra.literature.pubmed_client import is_retracted
import indra.tools.fix_invalidities


Expand Down Expand Up @@ -1277,6 +1277,7 @@ def filter_retracted_sources(stmts_in, **kwargs):
A list of statements to filter.
save : Optional[str]
The name of a pickle file to save the results (stmts_out) into.
Returns
-------
stmts_out : list[indra.statements.Statement]
Expand All @@ -1287,7 +1288,7 @@ def filter_retracted_sources(stmts_in, **kwargs):
ev_out = []
for ev in stmt.evidence:
pmid = ev.pmid or ev.text_refs.get('PMID')
if pmid and article_is_retracted(pmid):
if pmid and is_retracted(pmid):
continue
ev_out.append(ev)

Expand Down

0 comments on commit 8bed86e

Please sign in to comment.