Skip to content

Instantly share code, notes, and snippets.

View kshefchek's full-sized avatar

Kent Shefchek kshefchek

View GitHub Profile
#!/usr/bin/env python3
import timeit
from random import randrange
from rdflib import URIRef, ConjunctiveGraph
base_iri = 'http://example.org/foo_'
subject_id = randrange(100000)
predicate_id = randrange(100000)
object_id = randrange(100000)
#!/usr/bin/env python3
""" solr-pmids.py
Set up:
pythom3 -m venv venv
source venv/bin/activate
pip install requests
"""
import logging
import requests
@kshefchek
kshefchek / get-hp-jaccards.py
Created March 3, 2020 05:51
Pairwise jaccard sim scores for all hpo classes
#!/usr/bin/env python3
"""
virtualenv venv -p /usr/bin/python3
source venv/bin/activate
pip install rdflib prefixcommons
"""
import gzip
from copy import deepcopy
from typing import Set, Optional
from rdflib import URIRef, BNode, Literal, Graph, RDFS
@kshefchek
kshefchek / gitter-cloud.md
Last active April 24, 2020 21:24
A word cloud of my 7k gitter messages for Monarch Init from 2016-2019

A word cloud of my gitter messages for Monarch Init from 2016-2019

# Clone gitter-log (credit https://github.com/DoctorBud/gitter-log)
git clone https://github.com/kshefchek/gitter-log
npm install
npm run log

# Pull out my messages
cat mylog.json | jq '.[] | select(.fromUser.username == "kshefchek")' | jq -r .text >> gitter.txt
@kshefchek
kshefchek / synthetic-patients.py
Created December 10, 2019 01:15
Synthetic patient code
def random_weighted_walk(
start: str,
graph: Graph,
end_distance: int,
travelled_cache: Optional[Dict]=None,
direction: str='outgoing',
dist_walked=0) -> str:
"""
Traverse an ontology, ending up {distance} edges away from the
starting node
@kshefchek
kshefchek / phenodigm.py
Last active October 13, 2020 00:01
python implementation of phenodigm for HPO only
from typing import Set, Union, List, Optional, Sequence, Num
from functools import reduce, partial
from collections import Hashable
#from decorators import memoized
import copy
from itertools import chain
from rdflib import URIRef, BNode, Literal, Graph, RDFS
# Union types
Num = Union[int, float]
@kshefchek
kshefchek / meta-graph.cypher
Created July 6, 2018 22:49
Creating meta graphs for monarch-lite
CALL apoc.periodic.iterate(
"MATCH (a)-[r]->(b)
WITH FILTER(lab in labels(a)
WHERE (
lab <> 'Class' AND
lab <> 'NamedIndividual' AND
lab <> 'Node' AND
lab <> 'cliqueLeader'
)) AS a_labels,
type(r) AS rel_type,
@kshefchek
kshefchek / variant2genotype.json
Last active March 2, 2018 19:26
example for strawman model for variant to genotype data
{
"entities": [
{
"id": "MGI:4362924",
"label": "Mysm1<tm1a(KOMP)Wtsi",
"taxon": "NCBITaxon:10090",
"type": {
"label": "variant allele",
"id": "GENO:0000002"
}