Skip to content

Instantly share code, notes, and snippets.

View cthoyt's full-sized avatar

Charles Tapley Hoyt cthoyt

View GitHub Profile
@cthoyt
cthoyt / carolio_matches.ipynb
Last active January 23, 2024 23:25
Find matches between terms in proposed CaroliO ontology and existing OBO Foundry ontologies
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / torch_max_mem_benchmark.py
Created January 12, 2024 12:52
This is a script I was using a long time ago `torch-max-mem` relevant for https://github.com/mberr/torch-max-mem/issues/14. This cause crashes on my MPS GPU
import torch
from torch_max_mem import maximize_memory_utilization
import logging
import torch.mps
from humanize.filesize import naturalsize
logging.basicConfig(level=logging.DEBUG)
@maximize_memory_utilization()
@cthoyt
cthoyt / clo-to-sssom.ipynb
Created June 29, 2023 18:59
Extract and clean up cross-references from the Cell Line Ontology (CLO, v2.1.178)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / id_star_incomplete.py
Created June 26, 2023 09:54
Implementation of the original (incomplete) ID* algorithm from Jeremy Zucker. Still contains code comments that didn't make into final PR https://github.com/y0-causal-inference/y0/pull/140
"""This file contains code that implements the original ID* algorithm.
The algorithm is described in the paper "Complete Identification Methods for the Causal Hierarchy"
but the algorithm itself is not complete, as there are identifiable queries that cannot be
identified with this algorithm.
"""
import logging
from typing import Collection, Set, Tuple, cast
@cthoyt
cthoyt / ping_obofoundry_issues.py
Created March 3, 2023 21:23
As a follow-up to https://gist.github.com/cthoyt/95694a05190fc23b997fae62f12f96f1, this gist pings all repositories that haven't responded yet.
import time
import pystow
import requests
from bioregistry.external import get_obofoundry
from tqdm.auto import tqdm
TOKEN = pystow.get_config("github", "token")
TEXT_FORMAT = """\
@cthoyt
cthoyt / cellmarker-exploration.ipynb
Created February 6, 2023 17:05
Quick and dirty look at CellMarker (http://xteam.xbio.top/CellMarker/)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / gilda_demo.ipynb
Last active February 3, 2023 16:39
Ground chemicals suggested by David Osumi-Sutherland on Slack at https://obo-communitygroup.slack.com/archives/C01KUEWMSSC/p1675432789746889
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / find_missing_bananas.py
Created September 13, 2022 10:31
Find resources in the Bioregistry whose regular expression patterns contain a banana (i.e., a redundant prefix or prefix synonym) for curation.
import bioregistry
def main():
"""Identify resources with uncurated bananas."""
for resource in bioregistry.resources():
pattern = resource.get_pattern()
if not pattern:
continue
for peel in ":_-":
@cthoyt
cthoyt / extract_jcheminform_dois.py
Created August 25, 2022 11:59
Extract Journal of Cheminformatics DOIs from https://github.com/egonw/jcheminform-kb
"""Get Journal of Cheminformatics DOIs."""
import requests
import pystow
MODULE = pystow.module("jcheminf", "volumes")
USER = "egonw" # alternative use first-party jcheminform if it ever gets updated
REPO = "jcheminform-kb"
BRANCH = "main"
PREFIX = "https://doi.org/10.1186/"