Skip to content

Instantly share code, notes, and snippets.

@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/)
Loading
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
Loading
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 ":_-":
"""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/"
@cthoyt
cthoyt / extract_obo_dependencies.py
Created July 5, 2022 17:04
Extract the dependencies of each OBO Foundry Ontology
"""Update the dependencies."""
import json
from pathlib import Path
from typing import Iterable, Optional
import bioontologies
import bioregistry
import click
from bioontologies.obograph import Graph
@cthoyt
cthoyt / make_author_list.py
Created June 2, 2022 10:41
Generate author list text from a Google Sheet, originally used for the Bioregistry paper.
"""Generate author list text from a Google Sheet."""
from operator import itemgetter
import click
import pandas as pd
ROLE = {"Lead": 0, "Senior": 2}
SUPERSCRIPTS = {
@cthoyt
cthoyt / ground_odisea.ipynb
Last active May 5, 2022 13:45
Ground ODiseA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.