This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ffmpeg -i in.mov -pix_fmt rgb8 -r 10 output.gif && gifsicle -O3 output.gif -o output.gif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Callable, Optional | |
class wait_callable_true(object): | |
"""Wait until a callable evaluates to a truthy statement, then continue. | |
This object can be used as a function or as a context manager. | |
Args: | |
callable: A function which should eventually return a truthy value. | |
call_rate: The rate at which to test the callable, optional. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.stats as stats | |
__all__ = [ | |
'gaussian_1d_mixture', | |
'gaussian_2d_mixture'] | |
def gaussian_1d_mixture(arr, cov_factor=0.2): | |
"""A Gaussian kernel density estimation with a tuneable covariance factor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations, product | |
def hamming_circle(word, n, alphabet): | |
"""Create all words of hamming distance `n` in a given alphabet from a | |
target word. | |
Examples | |
--- | |
>>> sorted(hamming_circle('abc', 0, 'abc')) | |
['abc'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cyvcf2 import VCFReader | |
from snv_spectrum import Snv | |
reader = VCFReader(str(root / 'all.ann.vcf')) | |
samples = reader.samples | |
for variant in reader: | |
for sample, depth, alt_depth, gt_base in zip( | |
samples, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# drawHelix.sh <input.fa> | |
# | |
# Reads a fasta input file and stream a B-Form DNA | |
# helix with the sequence to STDOUT | |
# | |
## __ __ __ ___ | |
### |__) | / \ /__` \ / |\ | | /\ \_/ | |
#### |__) | \__/ .__/ | | \| | /~~\ / \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import threading | |
import time | |
# Really though just use a library for this: | |
# https://github.com/ManrajGrover/halo | |
# | |
class Spinner: | |
"""https://stackoverflow.com/a/39504463/3727678""" | |
busy = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pipe in the karyotype chromosomes | |
# Prefix each chromosome name with `chr` if necessary | |
# Slice the contigs from the source indexed FASTA with samtools | |
# Output to file | |
build="${build}" | |
echo {1..20} X Y M \ | |
| xargs printf -- 'chr%s ' \ | |
| xargs samtools faidx "${build}".fa \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Bio.Seq import Seq | |
from Bio.Seq import reverse_complement | |
dna_bases = ('A', 'C', 'G', 'T') | |
purines = ('A', 'G') | |
pyrimidines = ('C', 'T') | |
transitions = ('A>T', 'C>G', 'G>C', 'T>A') | |
transversions = ('A>C', 'A>G', 'C>A', 'C>T', 'G>A', 'G>T', 'T>C', 'T>G') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import csv | |
import textwrap | |
import matplotlib.pyplot as plt | |
from collections import Counter | |
class ReadError(LookupError): | |
"""Raise this when a property of a read is called for and no data exists""" | |
pass |