Skip to content

Commit

Permalink
Merge branch 'main' into update-wagstails
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Nov 20, 2024
2 parents 5d05e7f + 3101a1b commit 79d063a
Show file tree
Hide file tree
Showing 20 changed files with 883 additions and 829 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ body:
Include full errors, stack traces, and/or relevant logs.
validations:
required: true
- type: textarea
attributes:
label: Acceptance Criteria
description: |
Provide the criteria that must be met in order for this issue to be considered fixed.
Be specific, and consider potential edge cases.
validations:
required: true
- type: textarea
attributes:
label: Possible reason(s)
Expand Down
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ body:
Why do you need this feature? For example: "I'm always frustrated when..."
validations:
required: true
- type: textarea
attributes:
label: Acceptance Criteria
description: |
Provide the criteria that must be met in order for this issue to be considered fixed.
Be specific, and consider potential edge cases.
validations:
required: true
- type: textarea
attributes:
label: Proposed solution
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
THERAPY_TEST: true
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -55,3 +55,23 @@ jobs:

- name: Check style
run: python3 -m ruff check . && ruff format --check .

precommit_hooks:
runs-on: ubuntu-latest
strategy:
matrix:
hook:
- "end-of-file-fixer"
- "trailing-whitespace"
- "mixed-line-ending"
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- uses: pre-commit/[email protected]
with:
extra_args: ${{ matrix.hook }} --all-files
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/build/

# PyBuilder
.pybuilder/
Expand All @@ -91,7 +92,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ repos:
- id: check-merge-conflict
- id: detect-aws-credentials
args: [ --allow-missing-credentials ]
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0 # ruff version
hooks:
Expand Down
1 change: 0 additions & 1 deletion analysis/approval_status/approval_status_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ def ApprovalStatus(Enum):
FDA_PRESCRIPTION = "fda_prescription"
FDA_DISCONTINUED = "fda_discontinued"
FDA_TENTATIVE = "fda_tentative"

27 changes: 22 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ classifiers = [
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.10"
requires-python = ">=3.11"
description = "VICC normalization routines for therapeutics"
license = {file = "LICENSE"}
dependencies = [
Expand All @@ -41,9 +41,10 @@ etl = [
"wikibaseintegrator>=0.12.0",
"wags-tails~=0.2.0",
"tqdm",
"rich"
"rich",
"pyyaml"
]
test = ["pytest", "pytest-cov", "pytest-mock"]
test = ["pytest", "pytest-cov", "pytest-mock", "isodate"]
dev = ["pre-commit>=3.7.1", "ruff==0.5.0", "lxml", "xmlformatter", "types-pyyaml"]

[project.urls]
Expand Down Expand Up @@ -163,16 +164,32 @@ ignore = [
# ANN001 - missing-type-function-argument
# ANN2 - missing-return-type
# ANN102 - missing-type-cls
# D100 - undocumented-public-module
# D102 - undocumented-public-class
# S101 - assert
# B011 - assert-false
# N805 - invalid-first-argument-name-for-method
# RUF001 - ambiguous-unicode-character-string
# INP001 - implicit-namespace-package
# SLF001 - private-member-access
# PERF401 - manual-list-comprehension
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011", "INP001", "SLF001", "PERF401"]
"tests/*" = [
"ANN001",
"ANN2",
"ANN102",
"D100",
"D102",
"S101",
"B011",
"INP001",
"SLF001",
"PERF401"
]
"tests/unit/test_emit_warnings.py" = ["RUF001"]
"src/therapy/schemas.py" = ["ANN001", "ANN201", "N805"]

[tool.ruff.lint.flake8-annotations]
mypy-init-return = true

[tool.ruff.format]
docstring-code-format = true
2 changes: 1 addition & 1 deletion src/therapy/database/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def delete_source(self, src_name: SourceName) -> None:
"concept_id": record["concept_id"],
}
)
except ClientError as e: # noqa: PERF203
except ClientError as e:
raise DatabaseWriteError(e) from e

def complete_write_transaction(self) -> None:
Expand Down
15 changes: 8 additions & 7 deletions src/therapy/etl/guidetopharmacology.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _transform_ligands(self, data: dict) -> None:
"PubChem CID",
"UniProt ID",
"Ensembl ID",
"ChEMBL ID",
"Ligand Subunit IDs",
"Ligand Subunit Name",
"Ligand Subunit UniProt IDs",
Expand Down Expand Up @@ -114,14 +115,14 @@ def _transform_ligands(self, data: dict) -> None:
)
if row[10]:
associated_with.append(f"{NamespacePrefix.UNIPROT.value}:{row[10]}")
if row[16]:
aliases.append(self._process_name(row[16])) # IUPAC
if row[17]:
# International Non-proprietary Name assigned by the WHO
aliases.append(self._process_name(row[17]))
aliases.append(self._process_name(row[17])) # IUPAC
if row[18]:
# International Non-proprietary Name assigned by the WHO
aliases.append(self._process_name(row[18]))
if row[19]:
# synonyms
synonyms = row[18].split("|")
synonyms = row[19].split("|")
for s in synonyms:
if "&" in s and ";" in s:
name_code = s[s.index("&") : s.index(";") + 1]
Expand All @@ -130,9 +131,9 @@ def _transform_ligands(self, data: dict) -> None:
s = s.replace(name_code, "")
s = html.unescape(s)
aliases.append(self._process_name(s))
if row[20]:
if row[21]:
associated_with.append(
f"{NamespacePrefix.INCHIKEY.value}:{row[20]}"
f"{NamespacePrefix.INCHIKEY.value}:{row[21]}"
)

if associated_with:
Expand Down
4 changes: 1 addition & 3 deletions src/therapy/etl/wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def _get_latest_version() -> str:
:return: formatted string for the current date
"""
return datetime.datetime.now(tz=datetime.timezone.utc).strftime(
DATE_VERSION_PATTERN
)
return datetime.datetime.now(tz=datetime.UTC).strftime(DATE_VERSION_PATTERN)

def _get_data_handler(self, data_path: Path | None = None) -> DataSource:
"""Construct data handler instance for source. Overwrites base class method
Expand Down
8 changes: 4 additions & 4 deletions src/therapy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _fetch_records(
raise KeyError(msg)
(response, src) = self._add_record(response, match, match_type)
matched_sources.add(src)
except ClientError as e: # noqa: PERF203
except ClientError as e:
logger.error(e.response["Error"]["Message"])

return response, matched_sources
Expand Down Expand Up @@ -339,7 +339,7 @@ def search(
response = self._get_search_response(query_str, query_sources, infer)

response["service_meta_"] = ServiceMeta(
response_datetime=datetime.datetime.now(tz=datetime.timezone.utc),
response_datetime=datetime.datetime.now(tz=datetime.UTC),
).model_dump()
return SearchService(**response)

Expand All @@ -358,7 +358,7 @@ def _add_merged_meta(self, response: NormalizationService) -> NormalizationServi
for src in sources:
try:
src_name = SourceName(PREFIX_LOOKUP[src])
except KeyError: # noqa: PERF203
except KeyError:
# not an imported source
continue
else:
Expand Down Expand Up @@ -522,7 +522,7 @@ def _prepare_normalized_response(self, query: str) -> dict[str, Any]:
"match_type": MatchType.NO_MATCH,
"warnings": self._emit_char_warnings(query),
"service_meta_": ServiceMeta(
response_datetime=datetime.datetime.now(tz=datetime.timezone.utc)
response_datetime=datetime.datetime.now(tz=datetime.UTC)
),
}

Expand Down
16 changes: 8 additions & 8 deletions tests/data/drugbank/drugbank_5.1.10.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DrugBank ID,Accession Numbers,Common name,CAS,UNII,Synonyms,Standard InChI Key
DB00515,APRD00359,Cisplatin,15663-27-1,Q20Q21Q62J,CDDP | Cis-DDP | cis-diamminedichloroplatinum(II) | Cisplatin | cisplatino,LXZZYRPGZAFOLE-UHFFFAOYSA-L
DB00522,APRD00818,Bentiromide,37106-97-1,239IF5W61J,Bentiromide | Bentiromido | Bentiromidum | BTPABA | PFT,SPPTWHFVYKCNNK-FQEVSTJZSA-N
DB01143,APRD00021,Amifostine,20537-88-6,ILA426L95O,Amifostina | Amifostine | Amifostine anhydrous | Amifostinum | Aminopropylaminoethyl thiophosphate | Ethiofos,JKOQGQFVAUAYPM-UHFFFAOYSA-N
DB01174,APRD00184,Phenobarbital,50-06-6,YQE403BP4D,"5-ethyl-5-phenyl-2,4,6(1H,3H,5H)-pyrimidinetrione | 5-Ethyl-5-phenyl-pyrimidine-2,4,6-trione | 5-Ethyl-5-phenylbarbituric acid | 5-ethyl-5-phenylpyrimidine-2,4,6(1H,3H,5H)-trione | 5-Phenyl-5-ethylbarbituric acid | Fenobarbital | Phenobarbital | Phenobarbitol | Phenobarbitone | Phenobarbituric Acid | Phenyläthylbarbitursäure | Phenylethylbarbiturate | Phenylethylbarbituric Acid | Phenylethylbarbitursäure | Phenylethylmalonylurea",DDBREPKUVSBGFI-UHFFFAOYSA-N
DB06145,,Spiramycin,24916-50-5,033ECH6IFG,Demycarosylturimycin H | Foromacidin A | Foromacidine A | Spiramycin 1 | Spiramycin A | Spiramycin I,ACTOXUHEUCPTEW-CEUOBAOPSA-N
DB12117,,Mitometh,107465-03-2,H8MTN7XVC2,DDP,MOTIYCLHZZLHHQ-UHFFFAOYSA-N
DB14257,,Aloe ferox leaf,,0D145J8EME,Aloe (Aloe Ferox) | Aloe Candelabrum Leaf | Aloe Capensis | Aloe Ferox Dry Leaf Juice | Aloe Ferox Juice | Aloe Ferox Leaf Extract | Aloe Ferox Leaf Exudate | Aloe Ferox Leaf Gel | Aloe Ferox Leaf Juice | Aloe Ferox Leaf Juice Extract | Aloe Ferox Leaf Juice Powder | Aloe Ferox Leaf Powder | Aloe Ferox Leaf Preparation | Aloe Folii Extractus (Aloe Ferox) | Aloe Folium (Aloe Ferox) | Aloe Galpinii Leaf | Aloe Herba (Aloe Ferox) | Aloe Horrida Leaf | Aloe Muricata Leaf | Aloe Pallancae Leaf | Aloe Pseudoferox Leaf | Aloe Subferox Leaf | Aloe Supralaevis Leaf | Aloes (Aloe Ferox) | Busipho Ferox Leaf | Cape Aloe Leaf | Cape Aloes | Lu Hui (Aloe Ferox) | Luhui (Aloe Ferox) | New Aloe | Pachidendron Ferox Leaf | Pachidendron Pseudoferox Leaf | Pachidendron Supralaeve Leaf,
DrugBank ID,Accession Numbers,Common name,CAS,UNII,Synonyms,Standard InChI Key
DB00515,APRD00359,Cisplatin,15663-27-1,Q20Q21Q62J,CDDP | Cis-DDP | cis-diamminedichloroplatinum(II) | Cisplatin | cisplatino,LXZZYRPGZAFOLE-UHFFFAOYSA-L
DB00522,APRD00818,Bentiromide,37106-97-1,239IF5W61J,Bentiromide | Bentiromido | Bentiromidum | BTPABA | PFT,SPPTWHFVYKCNNK-FQEVSTJZSA-N
DB01143,APRD00021,Amifostine,20537-88-6,ILA426L95O,Amifostina | Amifostine | Amifostine anhydrous | Amifostinum | Aminopropylaminoethyl thiophosphate | Ethiofos,JKOQGQFVAUAYPM-UHFFFAOYSA-N
DB01174,APRD00184,Phenobarbital,50-06-6,YQE403BP4D,"5-ethyl-5-phenyl-2,4,6(1H,3H,5H)-pyrimidinetrione | 5-Ethyl-5-phenyl-pyrimidine-2,4,6-trione | 5-Ethyl-5-phenylbarbituric acid | 5-ethyl-5-phenylpyrimidine-2,4,6(1H,3H,5H)-trione | 5-Phenyl-5-ethylbarbituric acid | Fenobarbital | Phenobarbital | Phenobarbitol | Phenobarbitone | Phenobarbituric Acid | Phenyläthylbarbitursäure | Phenylethylbarbiturate | Phenylethylbarbituric Acid | Phenylethylbarbitursäure | Phenylethylmalonylurea",DDBREPKUVSBGFI-UHFFFAOYSA-N
DB06145,,Spiramycin,24916-50-5,033ECH6IFG,Demycarosylturimycin H | Foromacidin A | Foromacidine A | Spiramycin 1 | Spiramycin A | Spiramycin I,ACTOXUHEUCPTEW-CEUOBAOPSA-N
DB12117,,Mitometh,107465-03-2,H8MTN7XVC2,DDP,MOTIYCLHZZLHHQ-UHFFFAOYSA-N
DB14257,,Aloe ferox leaf,,0D145J8EME,Aloe (Aloe Ferox) | Aloe Candelabrum Leaf | Aloe Capensis | Aloe Ferox Dry Leaf Juice | Aloe Ferox Juice | Aloe Ferox Leaf Extract | Aloe Ferox Leaf Exudate | Aloe Ferox Leaf Gel | Aloe Ferox Leaf Juice | Aloe Ferox Leaf Juice Extract | Aloe Ferox Leaf Juice Powder | Aloe Ferox Leaf Powder | Aloe Ferox Leaf Preparation | Aloe Folii Extractus (Aloe Ferox) | Aloe Folium (Aloe Ferox) | Aloe Galpinii Leaf | Aloe Herba (Aloe Ferox) | Aloe Horrida Leaf | Aloe Muricata Leaf | Aloe Pallancae Leaf | Aloe Pseudoferox Leaf | Aloe Subferox Leaf | Aloe Supralaevis Leaf | Aloes (Aloe Ferox) | Busipho Ferox Leaf | Cape Aloe Leaf | Cape Aloes | Lu Hui (Aloe Ferox) | Luhui (Aloe Ferox) | New Aloe | Pachidendron Ferox Leaf | Pachidendron Pseudoferox Leaf | Pachidendron Supralaeve Leaf,
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"# GtoPdb Version: 2023.2 - published: 2023-08-07"
"Ligand id" "Name" "Species" "Type" "PubChem SID" "PubChem CID" "ChEMBl ID" "Chebi ID" "UniProt id" "Ensembl ID" "IUPAC name" "INN" "CAS" "DrugBank ID" "Drug Central ID"
"2169" "arginine vasotocin" "" "Peptide" "135652004" "68649" "" "" "" "" "L-cysteinyl-L-tyrosyl-(3S)-DL-isoleucyl-L-glutaminyl-L-asparagyl-L-cysteinyl-DL-prolyl-L-arginyl-glycinamide (1->6)-disulfide" "argiprestocin" "113-80-4" "" ""
"240" "cisapride" "" "Synthetic organic" "135650104" "2769" "CHEMBL1729" "CHEBI:151790" "" "" "4-amino-5-chloro-N-[1-[3-(4-fluorophenoxy)propyl]-3-methoxypiperidin-4-yl]-2-methoxybenzamide" "cisapride" "81098-60-4" "DB00604" "660"
"5343" "cisplatin" "" "Inorganic" "178102005" "441203" "CHEMBL11359" "CHEBI:27899" "" "" "" "cisplatin" "15663-27-1" "DB00515" ""
"3303" "L745870" "" "Synthetic organic" "178100340" "5311200" "CHEMBL267014" "" "" "" "3-[[4-(4-chlorophenyl)piperazin-1-yl]methyl]-1H-pyrrolo[2,3-b]pyridine" "" "158985-00-3" "" ""
"2804" "phenobarbital" "" "Synthetic organic" "135650817" "4763" "CHEMBL40" "CHEBI:8069" "" "" "5-ethyl-5-phenyl-1,3-diazinane-2,4,6-trione" "phenobarbital" "50-06-6" "DB01174" "2134"
"5260" "rolipram" "" "Synthetic organic" "178101944" "5092" "CHEMBL63" "CHEBI:104872" "" "" "4-[3-(cyclopentyloxy)-4-methoxyphenyl]pyrrolidin-2-one" "rolipram" "61413-54-5" "DB04149|DB03606" ""
"# GtoPdb Version: 2024.3 - published: 2024-10-03"
"Ligand id" "Name" "Species" "Type" "PubChem SID" "PubChem CID" "ChEMBl ID" "Chebi ID" "UniProt id" "Ensembl ID" "IUPAC name" "INN" "CAS" "DrugBank ID" "Drug Central ID"
"2169" "arginine vasotocin" "" "Peptide" "135652004" "68649" "" "" "" "" "L-cysteinyl-L-tyrosyl-(3S)-DL-isoleucyl-L-glutaminyl-L-asparagyl-L-cysteinyl-DL-prolyl-L-arginyl-glycinamide (1->6)-disulfide" "argiprestocin" "113-80-4" "" ""
"240" "cisapride" "" "Synthetic organic" "135650104" "2769" "CHEMBL1729" "CHEBI:151790" "" "" "4-amino-5-chloro-N-[1-[3-(4-fluorophenoxy)propyl]-3-methoxypiperidin-4-yl]-2-methoxybenzamide" "cisapride" "81098-60-4" "DB00604" "660"
"5343" "cisplatin" "" "Inorganic" "178102005" "441203" "CHEMBL11359" "CHEBI:27899" "" "" "" "cisplatin" "15663-27-1" "DB00515" ""
"3303" "L745870" "" "Synthetic organic" "178100340" "5311200" "CHEMBL267014" "" "" "" "3-[[4-(4-chlorophenyl)piperazin-1-yl]methyl]-1H-pyrrolo[2,3-b]pyridine" "" "158985-00-3" "" ""
"2804" "phenobarbital" "" "Synthetic organic" "135650817" "4763" "CHEMBL40" "CHEBI:8069" "" "" "5-ethyl-5-phenyl-1,3-diazinane-2,4,6-trione" "phenobarbital" "50-06-6" "DB01174" "2134"
"5260" "rolipram" "" "Synthetic organic" "178101944" "5092" "CHEMBL63" "CHEBI:104872" "" "" "4-[3-(cyclopentyloxy)-4-methoxyphenyl]pyrrolidin-2-one" "rolipram" "61413-54-5" "DB04149|DB03606" ""
8 changes: 0 additions & 8 deletions tests/data/guidetopharmacology/gtop_ligands_2023.2.tsv

This file was deleted.

Loading

0 comments on commit 79d063a

Please sign in to comment.