Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| alias gdl="git diff $(git log -n 2 | grep commit | tail -n +2 | awk '{print $NF}')" |
| #!/bin/bash | |
| # Script for installing tmux on systems where you don't have root access. | |
| # tmux will be installed in $HOME/local/bin. | |
| # It's assumed that wget and a C/C++ compiler are installed. | |
| # exit on error | |
| set -e | |
| TMUX_VERSION=1.8 |
| try: | |
| from cytoolz import frequencies | |
| except ImportError: | |
| from collections import Counter as frequencies | |
| # Works, but it's less than 3x as fast | |
| # A simple pure python counter is twice as fast as Counter anyhow.... | |
| from itertools import chain | |
| def get_qchars_counts(bampath): | |
| ''' |
| /* Assumes that both strings are of equal length. | |
| * | |
| */ | |
| int hd(char *a, char *b) { | |
| int ret = 0; | |
| while(*a) ret += (*a++ != *b++); | |
| return ret; | |
| } |
| #ifndef FALL_THROUGH_IPOW_H | |
| #define FALL_THROUGH_IPOW_H | |
| #include "stdint.h" | |
| static inline int64_t ipow(int32_t base, uint8_t exp) { | |
| static const uint8_t highest_bit_set[] = { | |
| 0, 1, 2, 2, 3, 3, 3, 3, | |
| 4, 4, 4, 4, 4, 4, 4, 4, | |
| 5, 5, 5, 5, 5, 5, 5, 5, | |
| 5, 5, 5, 5, 5, 5, 5, 5, |
| #ifndef KMER2STR_H | |
| #define KMER2STR_H | |
| #include "stdint.h" | |
| #ifndef num2nuc | |
| # ifndef NUM2NUC_STR | |
| # define NUM2NUC_STR "ACGTN" | |
| # endif | |
| # define num2nuc(x) NUM2NUC_STR[(uint8_t)x] |
| import pysam | |
| from itertools import chain | |
| def get_qchars(bampath): | |
| return set(chain.from_iterable(set(c.qual) for | |
| c in pysam.AlignmentFile(bampath))) |
| /* | |
| * :abstract: set the base in pSeq at index i in the read to the base in bSeq at index i in the read. | |
| * These 8-bit integers are the points in memory returned by bam_get_seq(p) and bam_get_seq(b), respectively. | |
| * :param: pSeq [uint8_t *] | |
| * :param: bSeq [uint8_t *] | |
| * :param: i [int/integral type] | |
| */ | |
| #define set_base(pSeq, bSeq, i) (pSeq)[(i)>>1] = ((bam_seqi(bSeq, i) << (((~i) & 1) << 2)) | (((pSeq)[(i)>>1]) & (0xf0U >> (((~i) & 1) << 2)))) | |
| /* | |
| * :abstract: set the base at index i in the read to "N". |