Skip to content

Instantly share code, notes, and snippets.

@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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / bioregistry_potential_mappings.py
Created February 14, 2022 14:46
How many potential mappings are in the Bioregistry?
"""Calculate the number of possible mappings between bioregistry entries."""
from itertools import combinations
from bioregistry.external.getters import GETTERS
from bioregistry.version import VERSION
from humanize import intword
def main():
@cthoyt
cthoyt / wd-publication-ego.sparql
Created February 12, 2022 21:51
Make a graph of your papers, co-authors, and topics by quering Wikidata
#defaultView:Graph
SELECT ?s ?sLabel ?rgb ?edgelabel ?o ?oLabel
WHERE {
{
SELECT ?s ?sLabel ?rgb ?o ?oLabel
WHERE {
?o wdt:P50 wd:Q47475003, ?s .
FILTER (?s != wd:Q47475003)
OPTIONAL {
@cthoyt
cthoyt / pykeen_uncertainty_demo.ipynb
Last active January 5, 2022 11:01
PyKEEN Uncertainty Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / download_reactome.py
Created November 3, 2021 20:08
Download and parse all of Reactome with PyBioPAX
from pathlib import Path
import pandas as pd
import pybiopax
ALL_PATHWAYS = "https://reactome.org/download/current/ReactomePathways.txt"
def download_reactome(directory):
@cthoyt
cthoyt / bioregistry_formatter_trailing_slashes.py
Created September 24, 2021 11:36
Find URL format strings in the bioregistry with problematic trailing slashes
import tabulate
import bioregistry
def main():
"""Generate a curation sheet for URL format strings with problematic trailing slashes."""
rows = []
for prefix, resource in bioregistry.read_registry().items():
format_url = resource.get_format()
@cthoyt
cthoyt / pykeen_model_tweeterator.py
Created July 19, 2021 20:09
PyKEEN tweet generator
"""Generate PyKEEN model tweets."""
from textwrap import dedent
import click
from docdata import get_docdata
from pykeen.models import model_resolver
@cthoyt
cthoyt / github_has_topic.py
Created July 13, 2021 19:04
Check if the given GitHub repository has the given topic.
from typing import Optional
import requests
def has_topic(owner: str, repo: str, topic: str, token: Optional[str] = None) -> bool:
"""Check if the given GitHub repository has the given topic.
:param owner: The name of the owner/organization for the repository.
:param repo: The name of the repository.
@cthoyt
cthoyt / create_obofoundry_issues.py
Last active June 8, 2021 13:05
Add issues to OBO Foundry repositories to add `obofoundry` topic
"""
This script blasts all of the OBO Foundry Repositories with a given issue.
Use sparingly.
______________________________
/ with great power comes great \
\ responsibility /
------------------------------
\ ^__^