Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 4, 2024
1 parent a7ee406 commit 879c401
Show file tree
Hide file tree
Showing 2 changed files with 2,609 additions and 2,609 deletions.
10 changes: 5 additions & 5 deletions src/pyobo/resources/so.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def get_so_name(so_id: str) -> str | None:


@lru_cache(maxsize=1)
def load_so() -> Mapping[tuple[str, str], str]:
def load_so() -> dict[str, str]:
"""Load the Sequence Ontology names."""
if not os.path.exists(SO_PATH):
download_so()
with open(SO_PATH) as file:
return {
(prefix, identifier): name
for prefix, identifier, name in csv.reader(file, delimiter="\t")
identifier: name
for identifier, name in csv.reader(file, delimiter="\t")
}


Expand All @@ -48,11 +48,11 @@ def download_so():
identifier = uri.removeprefix(SO_URI_PREFIX)
name = node.get("lbl")
if name:
rows.append(("so", identifier, name))
rows.append((identifier, name))

with open(SO_PATH, "w") as file:
writer = csv.writer(file, delimiter="\t")
writer.writerows(sorted(rows))
writer.writerows(sorted(rows, key=lambda x: int(x[0])))


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 879c401

Please sign in to comment.