Skip to content

Instantly share code, notes, and snippets.

View mwatts15's full-sized avatar
🏠
Working from home

Mark Watts mwatts15

🏠
Working from home
View GitHub Profile
@mwatts15
mwatts15 / insert_worm_yarom.py
Last active September 8, 2020 06:22
YAROM version of insert_worm.py
import yarom as Y
import traceback
import sqlite3
SQLITE_DB_LOC = '../aux_data/celegans.db'
LINEAGE_LIST_LOC = '../aux_data/C. elegans Cell List - WormAtlas.tsv'
MUSCLE_LINEAGE_LIST_LOC = '../aux_data/muscle_names_to_lineage'
WORM = None
NETWORK = None
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mwatts15
mwatts15 / query.py
Created February 26, 2015 21:47
A thing for doing graph queries
import yarom as Y
import rdflib as R
from rdflib.tools.rdf2dot import rdf2dot
from pprint import pprint as PP
from time import time
from object_name_dict import onames as ONAMES
from object_name_dict import pnames as PNAMES
import sys
@mwatts15
mwatts15 / traversals.py
Created January 30, 2015 19:07
Demo graph traversals for mapping object graphs to RDF
from __future__ import print_function
import pprint as PP
class A(object):
def __init__(self):
self.o = dict()
self.p = dict()
self.var = None
self.ident = None
@property
@mwatts15
mwatts15 / issue-92.py
Last active August 29, 2015 14:14
See openworm/PyOpenWorm #92
import sys
import PyOpenWorm as P
if len(sys.argv) > 1:
P.connect(conf={'rdf.source':'default'})
P.loadData('../WormData.n3')
else:
P.connect('default.conf')
def should_match(y, x):
@mwatts15
mwatts15 / README.patch
Last active August 29, 2015 14:14
See openworm/PyOpenWorm issue #91
diff --git a/PyOpenWorm/neuron.py b/PyOpenWorm/neuron.py
index d693f32..de6a7b4 100644
--- a/PyOpenWorm/neuron.py
+++ b/PyOpenWorm/neuron.py
@@ -82,7 +82,6 @@ class Connection(P.Property):
int
The number of connections matching the paramters given
"""
- # XXX: Turn this into a COUNT query
options = dict()
diff --git a/PyOpenWorm/neuron.py b/PyOpenWorm/neuron.py
index d693f32..32b52e8 100644
--- a/PyOpenWorm/neuron.py
+++ b/PyOpenWorm/neuron.py
@@ -82,7 +82,6 @@ class Connection(P.Property):
int
The number of connections matching the paramters given
"""
- # XXX: Turn this into a COUNT query
options = dict()
@mwatts15
mwatts15 / pascal_primes.rkt
Created September 1, 2014 15:39
Colors Pascal's triangle by the largest prime factor
#lang racket
(require pict)
(require racket/draw)
(require racket/fixnum)
(define (slop f l)
(cond
((null? l) '())
(#t (cons (f l) (slop f (cdr l))))))
@mwatts15
mwatts15 / Sleepycat_updown.py
Last active August 29, 2015 14:05
How long does it take to open and close a Sleepycat (Berkeley DB) store versus a persisted ZODB store?
import rdflib as R
from subprocess import call
from time import time
def median(mylist):
# from http://stackoverflow.com/questions/10482339/how-to-find-median
sorts = sorted(mylist)
length = len(sorts)
if not length % 2:
return (sorts[length / 2] + sorts[length / 2 - 1]) / 2.0
@mwatts15
mwatts15 / test_graph_changes.py
Last active August 29, 2015 14:02
Testing changes to a graph
import rdflib as R
from random import randint,sample
import subprocess
from subprocess import PIPE
import os
# Load in the graph
g = R.ConjunctiveGraph(identifier=R.URIRef("http://somehost.com/default_graph"))
graph_uri = R.URIRef("http://somehost.com/default_graph")
YOUR_TEST_GRAPH = 'changes_test.nq'
YOUR_TEST_GRAPH_FORMAT = 'nquads'