Skip to content

Instantly share code, notes, and snippets.

from pysam import VariantFile
import time
def count_oldvar_reg(vcffile_reg, labels=["OLDVARS", "OLDVARS_A", "OLDVARS_B"]):
t_start = time.time()
bcf_in = VariantFile(vcffile_reg)
total = 0
reg = 0
for rec in bcf_in:

Handy commands

Extract bam according to a bed file

bedtools intersect -abam path/to/input.bam -b path/to/regions.bed > out.bam

Extract region of a VCF

def _save_more_extensions(filename, extensions=['png', 'svg', 'pdf']):
for ext in extensions:
comp_filename = "{0}.{1}".format(filename, ext)
plt.savefig(comp_filename, dpi=300)
print "Saved plot: {0}".format(comp_filename)
#!/bin/sh
#
# purge-old-kernels - remove old kernel packages
# Copyright (C) 2012 Dustin Kirkland <kirkland@ubuntu.com>
#
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
# Kees Cook <kees@ubuntu.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@mattions
mattions / .screenrc
Created May 9, 2015 18:59
Sane screen rc default
hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]'
startup_message off
termcapinfo xterm* ti@:te@
backtick 1 5 5 true
termcapinfo rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'
/*!
* Bootstrap v3.2.0 (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*//*! normalize.css v3.0.1 | MIT License | git.io/normalize */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:cont
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import time
data = []
for n_elements in [100, 1000, 10000, 100000]:
a = range(n_elements)
sa = set(a)
b = np.array(a) + 50
{% if is_paginated %}
<div class="col-md-offset-4">
<ul class="pagination pagination-centered">
{% if page_obj.has_previous %}
<li><a href="?page=1"><<</a></li>
<li><a href="?{{queries.urlencode}}&amp;page={{ page_obj.previous_page_number }}"><</a></li>
{% endif %}
{% for i in paginator.page_range %}
<li {% if page_obj.number == i %} class="active" {% endif %}><a href="?{{queries.urlencode}}&amp;page={{i}}">{{i}}</a></li>
{
"metadata": {
"name": "",
"signature": "sha256:5835de2e10cb99253cfa1841c86b02e6b9ee8b2fb21e513bbaec771e6e006c1b"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
import json
import base64
import hashlib
import hmac
def _prepare_headers(payload, api_key, api_secret):
# payload = parameters-dictionary -> JSON encode -> base64
payload_json = json.dumps(payload)
payload_encoded = base64.encodestring(payload_json)
# signature = HMAC-SHA384(payload, api-secret) as hexadecimal