Skip to content

Instantly share code, notes, and snippets.

View cjain7's full-sized avatar

Chirag Jain cjain7

View GitHub Profile
@malonge
malonge / sam2delta.py
Created December 29, 2018 03:43
Convert a SAM file to a MUMmer delta file
#!/usr/bin/python3
import argparse
from collections import defaultdict
"""
This utility converts a SAM file to a nucmer delta file.
SAM files must contain an NM tag, which is default in minimap2 alignments.
"""
@lh3
lh3 / inthash.c
Last active December 11, 2022 07:27
Invertible integer hash functions
/*
For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means
hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of
hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x.
*/
// Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot.
uint64_t hash_64(uint64_t key, uint64_t mask)
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
@l-modolo
l-modolo / reads_length_dist.sh
Created October 31, 2013 09:31
compute reads length distribution from a fastq file
#!/bin/sh
# compute reads length distribution from a fastq file
awk 'NR%4 == 2 {lengths[length($0)]++} END {for (l in lengths) {print l, lengths[l]}}' file.fastq
@epinna
epinna / .gdbinit
Created January 14, 2013 08:54 — forked from apetresc/.gdbinit
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@donny-dont
donny-dont / aligned_allocator.cpp
Created December 13, 2011 09:11
An aligned allocator for placing SIMD types in std::vector
#ifdef _WIN32
#include <malloc.h>
#endif
#include <cstdint>
#include <vector>
#include <iostream>
/**
* Allocator for aligned data.