Skip to content

Instantly share code, notes, and snippets.

# Efficient computation of the pairwise divergence matrix.
import time
import itertools
import msprime
import tskit
import numba
import numpy as np
import sys
import tskit
import numpy as np
import numba
@numba.njit
def _normalise(B):
K = np.zeros_like(B)
N = K.shape[0]
@jeromekelleher
jeromekelleher / branch_grm.py
Last active October 14, 2022 16:30
Compute branch GRM using numba
import sys
import tskit
import numpy as np
import numba
@numba.njit
def sv_tables_init(parent_array):
# This is an implementation of Schieber and Vishkin's nearest common ancestor
# algorithm from TAOCP volume 4A, pg.164-167 [K11]_. Preprocesses the
@jeromekelleher
jeromekelleher / better_animate_edges.py
Created April 14, 2019 14:21
Animate trees evolving along a chromosome
import pathlib
import subprocess
import tempfile
import tskit
import msprime
def draw_transitioning_tree(tree, filename, edge_colours):
tree.draw(
@jeromekelleher
jeromekelleher / animate_edges.py
Created April 13, 2019 17:18
Animate trees evolving along a tree sequence
import pathlib
import subprocess
import msprime
def draw_partial_tree(tables, edges, filename):
tables.edges.clear()
for edge in edges:
tables.edges.add_row(*edge)
@jeromekelleher
jeromekelleher / gist:074ac7f7e0f0c95a7be4
Created August 13, 2015 11:44
Stacktrace of htslib error.
(gdb) run scripts/download_data.py
Starting program: /usr/bin/python scripts/download_data.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Cleaning out directory '/home/jk/work/github/server/ga4gh-downloaded-data/dataset1/reads/low-coverage'
Downloading index for 'ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/phase3/data/HG00096/alignment/HG00096.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam'
[M::test_and_fetch] downloading file 'ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/phase3/data/HG00096/alignment/HG00096.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam.bai' to local directory
Writing 'HG00096.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam'
*** buffer overflow detected ***: /usr/bin/python terminated
======= Backtrace: =========