Skip to content

Instantly share code, notes, and snippets.

View nvictus's full-sized avatar

Nezar Abdennur nvictus

  • UMass Chan Medical School
  • Greater Boston Area
View GitHub Profile
@nvictus
nvictus / ucsc.py
Created August 26, 2016 21:02
UCSC fetcher
# -*- coding: utf-8 -*-
"""
Request snapshots from the UCSC Genome Browser.
"""
from __future__ import division, print_function, unicode_literals
from collections import OrderedDict
import sys
import re
@nvictus
nvictus / cooler-from-sparse-text.ipynb
Last active April 7, 2017 18:17
cooler-from-sparse-text.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / tbwarn.py
Last active June 20, 2017 21:24
print traceback in warnings
import traceback
import warnings
import sys
def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
log = file if hasattr(file,'write') else sys.stderr
traceback.print_stack(file=log)
log.write(warnings.formatwarning(message, category, filename, lineno, line))
@nvictus
nvictus / load-dense-contact-matrix.ipynb
Last active July 16, 2017 19:16
load dense contact matrix
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / .inputrc
Last active May 1, 2018 17:18
linux inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@nvictus
nvictus / post_mortem_hook.py
Created August 7, 2016 07:15
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)
print()
ipdb.pm()
sys.excepthook = _excepthook
@nvictus
nvictus / godsnot.json
Created December 24, 2019 21:19
A large palette of reasonably distinct colors
[
"#000000",
"#FFFF00",
"#1CE6FF",
"#FF34FF",
"#FF4A46",
"#008941",
"#006FA6",
"#A30059",
"#FFDBE5",
@nvictus
nvictus / pandas_jupyter_paginator.py
Last active January 22, 2020 11:13 — forked from nokados/pandas_jupyter_paginator.py
Paginator for pandas.DataFrame in Jupyter Notebook
"""
Forked from: https://gist.github.com/nokados/e8f0a64b55099f2f07a50f2b090c91c7
Changes
* 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
nvictus / mutual_info.py
Created March 16, 2020 16:24 — forked from GaelVaroquaux/mutual_info.py
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