Skip to content

Instantly share code, notes, and snippets.

View gatoravi's full-sized avatar

Avinash R gatoravi

View GitHub Profile
@gatoravi
gatoravi / go_notes.md
Last active September 26, 2015 17:58
Notes from "Building Large Systems with Go" Unsession by Mark Mandel at StrangeLoop 2015

#Formatting Go code

  • go fmt
  • go vet
  • golint

#Package manager options

  • gb
  • go get
  • git clone
@gatoravi
gatoravi / Parse_VCF_BCFs_with_htslib_C++.md
Last active November 16, 2020 10:28
Parse VCF/BCFs with htslib (C++)

#Gist of the gist This is a simple example showing how htslib can be used to parse VCF/BCF files in C++. Compiling options are shown in compile_and_run.sh, this assumes that you have compiled htslib into a static library - libhts.a, post a comment if you'd like help doing that.

The program takes a VCF file and spits out chromosome, position and number_of_alleles for each record in the VCF.

This test in the Samtools repo - [https://github.com/samtools/htslib/blob/1.2.1/test/test-vcf-api.c] also has some useful examples, note you might have to switch to the master branch version of that file to keep up with the currently rapidly evolving htslib API.

#Acknowledgements

@gatoravi
gatoravi / vim_tabs_spaces
Created October 13, 2015 22:00
Switching from tabs to spaces and vice-versa in Vim
http://vim.wikia.com/wiki/Converting_tabs_to_spaces
To switch to Tabs from Spaces
:set noexpandtab
Switch to spaces
:set expandtab
:set tabstop=4
@gatoravi
gatoravi / get_count_with_sufficient_coverage.cc
Last active November 4, 2015 15:47 — forked from anonymous/get_count_with_sufficient_coverage.cc
Parse 'samtools depth' and obtain lines with sufficient coverage. Assumes two samples in the output. Same as, awk '$3 >= cutoff && $4 >= cutoff'
#include <stdint.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
void usage() {
cerr << "Usage: ./get_count_with_sufficient_coverage samtools_depth_file cutoff[INT]";
cerr << "Assumes 2 samples.";
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
@gatoravi
gatoravi / CMakeLists.txt
Last active November 30, 2015 05:46
capnp example using cmake
include_directories(../src/mash/capnp/)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_MODULE_PATH
".;${CMAKE_MODULE_PATH}")
find_package(CapnProto REQUIRED)
include_directories(${CAPNP_INCLUDE_DIRS})
add_definitions(${CAPNP_DEFINITIONS})
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS MinHash.capnp)
@gatoravi
gatoravi / tsv_to_vcf.sh
Created March 21, 2016 21:21
Convert hcc1395 tsv to vcf
awk '{ gsub("\,", "");gsub("\"", ""); gsub ("\r", "\n"); print }' SupplementaryData1_Tier1_SNVs.txt | awk 'BEGIN { print "##fileformat=VCFv4.1\n#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO" } !/Chrom/ { if($1 !~ /GL/) print $1"\t"$2"\t.\t"$4"\t"$5"\t.\tPASS\t." }' > hcc1395_somatic.vcf
@gatoravi
gatoravi / biology_books.md
Last active March 29, 2016 21:04
Books on Biology

Essential cell biology / Bruce Alberts [and others].

Coming to Life: How Genes Drive Development by Christiane Nüsslein-Volhard

@gatoravi
gatoravi / regtools_docker_install.sh
Created April 20, 2016 21:49
List of commands to install regtools on a Docker Ubuntu image
sudo apt-get install git
sudo apt-get install cmake
sudo apt-get update
sudo apt-get install zlib1g-dev
sudo apt-get install g++
cd /home && mkdir src && cd src
git clone https://github.com/griffithlab/regtools
cd regtools && mkdir build && cd build
cmake .. && make
cp regtools /usr/local/bin/
@gatoravi
gatoravi / vim_tabs.txt
Created April 21, 2016 15:06
Turning on and off tabs in Vim
set expandtab #convert tabs to spaces
set noexpandtab #don't convert tabs to spaces