Skip to content

Instantly share code, notes, and snippets.

Avatar

Nezar Abdennur nvictus

View GitHub Profile
@nvictus
nvictus / gillespie_nrm.py
Last active Oct 1, 2020
Next-Reaction Method variant of the Gillespie stochastic simulation algorithm.
View gillespie_nrm.py
from pqdict import pqdict
from numpy import array, zeros, log, seterr
from numpy.random import rand
from collections import Counter
from matplotlib import pyplot as plt
seterr(divide="ignore")
class Reaction(object):
@nvictus
nvictus / pqdict_dijkstra_example.py
Last active Apr 17, 2019
Python: Dijkstra's algorithm using the pqdict module
View pqdict_dijkstra_example.py
from pqdict import minpq
def dijkstra(graph, source, target=None):
dist = {} #lengths of the shortest paths to each node
pred = {} #predecessor node in each shortest path
# Store distance scores in a priority queue dictionary
pq = minpq()
for node in graph:
if node == source:
View Zimm-Braggin'.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View rs1421085.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:240c9e9ee33e20d02a36
CONDA_DIR="$HOME/miniconda"
alias workon='source $CONDA_DIR/bin/activate'
# function workon () {
# source "$CONDA_DIR/bin/activate" "$1"
# }
function __conda_user_setup () {
_workon_tab_completion_bash () {
@nvictus
nvictus / example-ucsc.ipynb
Last active Sep 2, 2016
UCSC genome browser to matplotlib
View example-ucsc.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / lexbisect.py
Last active Jan 14, 2016
Bisection search on lexically sorted sequences in Python.
View lexbisect.py
def lexbisect(arrays, values, side='left', lo=0, hi=None):
"""
Bisection search on lexically sorted arrays.
Parameters
----------
arrays : sequence of k 1-D array-like
Each "array" can be any sequence that supports scalar integer indexing,
as long as the arrays have the same length and their values are
lexsorted from left to right.
View cooler_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / runlength.py
Last active Mar 12, 2020
NumPy run-length encoding / decoding
View runlength.py
"""Run Length Encoding utilities for NumPy arrays.
Authors
-------
- Nezar Abdennur
- Anton Goloborodko
"""
from __future__ import division, print_function
import numpy as np
@nvictus
nvictus / post_mortem_hook.py
Created Aug 7, 2016
Post mortem exception hook with ipdb
View post_mortem_hook.py
def set_postmortem_hook():
import sys, traceback, ipdb
def _excepthook(exc_type, value, tb):
traceback.print_exception(exc_type, value, tb)
print()
ipdb.pm()
sys.excepthook = _excepthook
You can’t perform that action at this time.