Skip to content

Commit

Permalink
< or > in res range
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruibin-Liu committed Dec 15, 2023
1 parent e2fe4b6 commit 94b529e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 13 additions & 5 deletions pyuniprot/Uniprot.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def _get_category_lines(self) -> None:
record_name: str = line[2:20].strip()
if record_name != "":
one_record: dict[str, str | int | SeqRange | None] = {}
site_or_range: int | SeqRange | None = None
site_or_range: str | int | SeqRange | None = None
seq_ids: list[str] = [
seq_id for seq_id in line[20:].strip().split("..")
]
Expand All @@ -584,16 +584,24 @@ def _get_category_lines(self) -> None:
isoform = seq_ids[0].split(":")[0]
if len(seq_ids) == 1:
name: str = "at_site"
site_or_range = int(seq_ids[0].split(":")[-1])

try:
site_or_range = int(seq_ids[0].split(":")[-1])
except ValueError:
site_or_range = seq_ids[0].split(":")[-1]
else:
name = "in_range"
seq_start: int | str = "?"
seq_end: int | str = "?"
if "?" not in seq_ids[0]:
seq_start = int(seq_ids[0].split(":")[-1])
try:
seq_start = int(seq_ids[0].split(":")[-1])
except ValueError:
seq_start = seq_ids[0].split(":")[-1]
if "?" not in seq_ids[1]:
seq_end = int(seq_ids[1].split(":")[-1])
try:
seq_end = int(seq_ids[1].split(":")[-1])
except ValueError:
seq_end = seq_ids[1].split(":")[-1]
site_or_range = SeqRange(seq_start, seq_end)
one_record[name] = site_or_range
one_record["isoform"] = isoform
Expand Down
3 changes: 0 additions & 3 deletions tests/test_uniprot.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,3 @@ def test_empty_resid():
.seq_begin
== ""
), "Q9NPA5 first PDB resids are not ''."


test_empty_resid()

0 comments on commit 94b529e

Please sign in to comment.