Skip to content

Instantly share code, notes, and snippets.

View andreas-wilm's full-sized avatar

Andreas Wilm andreas-wilm

View GitHub Profile
@andreas-wilm
andreas-wilm / cudtools_colormap.py
Created November 21, 2014 03:28
Use colorblind friendly cudtools as colormap
import numpy as np
import matplotlib.pyplot as plt
# use the colorblind friendly colors
# https://code.google.com/p/python-cudtools/source/browse/cudtools.py
import cudtools
numlines = 20
@andreas-wilm
andreas-wilm / timestamp.c
Created February 3, 2015 06:25
Return ISO 8601 timestamp
/* -*- c-file-style: "k&r"; indent-tabs-mode: nil; -*- */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* returns a timestamp in the form of YYYY-mm-dd HH-MM.
* buf needs to be able to hold 19+1 characters (incl. \0).
* returns 0 on success -1 otherwise.
*/
@andreas-wilm
andreas-wilm / pysam_alignedpairs.py
Last active October 23, 2015 06:35
Example on how to reconstruct alignment from pysam aligned segment
# assuming:
# - refsq is set and always the same
# - bamfh is an open pysam samfile
for r in bamfh:
if r.is_unmapped:
continue
for (qapos, rpos) in r.get_aligned_pairs():
# qapos is the aligned index, i.e. this ignores clipping. add that
@andreas-wilm
andreas-wilm / timestamp.py
Last active February 2, 2016 07:16
python iso timestamp
from datetime import datetime
def timestamp():
return datetime.now().isoformat()
@andreas-wilm
andreas-wilm / fisher_pv_comb.py
Created November 18, 2015 09:10
Fisher's method for combining p-values
from math import log
from scipy import stats
def fisher_comb(pv1, pv2):
"""
Fisher's method for combining p-values:
https://en.wikipedia.org/wiki/Fisher's_method
See for example breseq-0.18b:polymorphism_statistics.r
@andreas-wilm
andreas-wilm / argparse_logging_skeleton.py
Created January 5, 2016 02:16
Repeateable -v and -q for setting logging level with argparse (Python)
#!/usr/bin/env python
# Example for using repeateable -v and -q for setting logging level
# with argparse. works with python 2 and 3. based on
# https://www.reddit.com/r/Python/comments/3nctlm/what_python_tools_should_i_be_using_on_every/
#
# masklinn: """A trick I like is using repeatable -v and -q to select
# the logging level. The logging levels are actually integers with a
# 10 increment (DEBUG is 10, CRITICAL is 50). It's very easy with
# argparse's count action or click's count=True"""
@andreas-wilm
andreas-wilm / myip.sh
Created September 15, 2017 14:33
Resolve IP
# found at #nfhack17
dig +short myip.opendns.com @resolver1.opendns.com
@andreas-wilm
andreas-wilm / install-singularity.sh
Created January 15, 2018 15:13
Install Singularity
set -euo pipefail
VERSION=2.4.2
pushd /tmp/
wget https://github.com/singularityware/singularity/releases/download/$VERSION/singularity-$VERSION.tar.gz
tar xzf singularity-${VERSION}.tar.gz
cd singularity-${VERSION}
./configure --prefix=/usr/local
make

Keybase proof

I hereby claim:

  • I am andreas-wilm on github.
  • I am andreaswilm (https://keybase.io/andreaswilm) on keybase.
  • I have a public key ASCHyaZnBYiR0MNExSduKh5LsVgFwldPfSI1mnHKOYKDZAo

To claim this, I am signing this object:

@andreas-wilm
andreas-wilm / nextflow_sample_map_str.nf
Created July 4, 2018 13:57
Nextflow: Proof of concept example for repeated function call with expected static output
#!/usr/bin/env nextflow
/* this is a minimal working example for a bug we recently ran into.
* in a nutshell: we can function (gen_sample_map_str) in every call to
* process GenomicsDB. * the function has static input and should
* produce identical output each time, but it doesn't. the question is
* why.
*
* yes, we can do tihs different, i.e. construct the string once and yes
* some things don't make sense in this current minimalistic form.