Skip to content

Instantly share code, notes, and snippets.


Nezar Abdennur nvictus

View GitHub Profile
nvictus /
Last active Oct 1, 2020
Next-Reaction Method variant of the Gillespie stochastic simulation algorithm.
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
class Reaction(object):
nvictus / loadnpy.js
Last active Aug 5, 2020
NumPy binary file parser for javascript
View loadnpy.js
// Client-side parser for .npy files
// See the specification:
var NumpyLoader = (function () {
function asciiDecode(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
function readUint16LE(buffer) {
var view = new DataView(buffer);
var val = view.getUint8(0);
nvictus /
Last active Jun 16, 2020
motif PFM/PWM dataframe reader
import numpy as np
import pandas as pd
def _probability_mat_to_information_mat(prob_df, bg_df):
Converts a probability matrix to an information matrix.
Taken from logomaker (
nvictus /
Last active Jun 13, 2020
preferred numbers
def geomprog(start, mul):
Generate a geometric progression.
Beginning with integer `start`, generate an unbounded geometric
progression with ratio `mul`.
start = int(start)
yield start
nvictus /
Created Mar 16, 2020 — forked from GaelVaroquaux/
Estimating entropy and mutual information with scikit-learn
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
import numpy as np
nvictus /
Last active Mar 12, 2020
NumPy run-length encoding / decoding
"""Run Length Encoding utilities for NumPy arrays.
- Nezar Abdennur
- Anton Goloborodko
from __future__ import division, print_function
import numpy as np
nvictus /
Last active Jan 22, 2020 — forked from nokados/
Paginator for pandas.DataFrame in Jupyter Notebook
Forked from:
* Added slider control to scroll through pages of really large dataframes.
* Reduce flicker by making events trigger widget element updates instead of
clearing output and re-rendering.
* Add support for dataframe CSS styling.
* Register custom pandas accessor
nvictus / godsnot.json
Created Dec 24, 2019
A large palette of reasonably distinct colors
View godsnot.json
nvictus / cool.r
Last active Oct 25, 2019
coolR: a cooler reader for R
View cool.r
# Notes
# -----
# * Cooler's stored bin IDs are 0-based. However, for consistency with R, this API should take
# 1-based indexing as input for table row and matrix range queries.
# * See Ilya's implementation:
nvictus /
Created Aug 7, 2016
Post mortem exception hook with ipdb
def set_postmortem_hook():
import sys, traceback, ipdb
def _excepthook(exc_type, value, tb):
traceback.print_exception(exc_type, value, tb)
sys.excepthook = _excepthook
You can’t perform that action at this time.