Skip to content

Instantly share code, notes, and snippets.

View PoisonAlien's full-sized avatar
🌻

Anand Mayakonda PoisonAlien

🌻
  • Heidelberg
  • 08:24 (UTC +02:00)
View GitHub Profile
@PoisonAlien
PoisonAlien / readBam.C
Last active November 9, 2023 21:21
reading bam files in C using htslib
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <htslib/sam.h>
int main(int argc, char *argv[]){
samFile *fp_in = hts_open(argv[1],"r"); //open bam file
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header
bam1_t *aln = bam_init1(); //initialize an alignment
@PoisonAlien
PoisonAlien / rna_seq_variant_pipeline.sh
Created August 7, 2015 09:35
RNA seq Variant calling pipeline according to gatk best practices
#!/bin/bash
#
# AUTHOR: Anand M.
# RNA-Seq variant calling pieline accoring to GATK Best practices.
# https://www.broadinstitute.org/gatk/guide/article?id=3891
#
# Call with following arguments
# bash rna_seq_variant_pipeline.sh <Input_Reads1.fq.gz> <Input_Reads2.fq.gz> <output_basename>
#
# Assumes STAR aligner is under path
@PoisonAlien
PoisonAlien / VarScan2_format_converter.py
Last active May 3, 2021 12:26
Takes output file generated by VarScan2 somatic programme and converts the formats. See here for updated versions https://github.com/PoisonAlien/varscan_accessories
__author__ = "Anand M"
'''
Takes output file generated by VarScan2 somatic programme and converts the formats.
'''
import argparse, math, re
parser = argparse.ArgumentParser(
description="Converts VarScan2 somatic vcf to native format and vice-versa.\nInput is automatically detected")
@PoisonAlien
PoisonAlien / star_aligner.py
Last active April 15, 2019 14:20
This is a wrapper for STAR aligner with most commonly used arguments. Assumes STAR is under path and accessible.
__author__ = 'Anand M'
import argparse, datetime, os
############# parse arguments ########
parser = argparse.ArgumentParser(
description="wrapper script for STAR aligner. Assumes STAR is installed under path and accessible.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@PoisonAlien
PoisonAlien / oncotate.r
Last active February 18, 2019 16:13
Takes variants as input and annotates them using borads oncotator api (http://www.broadinstitute.org/oncotator/). Output is a dataframe of annotated variants in maf format.
# Usage
#
# oncotate(maflite, header = FALSE, basename = NULL)
# Arguments
#
# maflite
# input tsv file with chr, start, end, ref_allele, alt_allele columns. (rest of the columns, if present will be attached to the output maf)
#
# header
# logical. Whether input has a header line. Default is FALSE.
@PoisonAlien
PoisonAlien / dnaCopyScan.r
Last active September 7, 2017 20:43
dnaCopyScan - Takes output from varscan copynumber command (*.copynumber) and performs CBS segmentation.
#Usage: From command line
#Rscript dnaCopyScan.r <foo.copynumber>
#Author: Anand Mayakonda (Cancer Science Institute of Singapore; NUS)
dnaCopy=function(copynumber_file){
suppressPackageStartupMessages(library(DNAcopy))
suppressPackageStartupMessages(library(data.table))
tn = data.table::fread(copynumber_file, sep="\t", stringsAsFactors=FALSE, header=TRUE, check.names=FALSE)
colnames(tn)[1] = 'contig'
tn$contig = gsub(pattern = 'chr', replacement = '', x = tn$contig, fixed = T)
@PoisonAlien
PoisonAlien / fetch_sra
Last active August 13, 2018 07:40
Download SRA runs with wget. Usage: fetch_sra SRR1067272
#!/usr/bin/env bash
#Usage example: fetch_sra SRR1067272
#Details - Downloads SRA runs with wget.
#Accepts one or more SRR run ids as input and downloads them into working directory
#Partially downloaded files will be resumed.
#Author: Anand Mayakonda <anandmt3@gmail.com>
echo "$(tput setaf 3)"
if [ $# -lt 1 ];then

Keybase proof

I hereby claim:

  • I am poisonalien on github.
  • I am anandmt (https://keybase.io/anandmt) on keybase.
  • I have a public key ASCo_qLuKorQBwDJ44Rb9fTv-EmjPSFm-A6i3MF-aXvQawo

To claim this, I am signing this object:

@PoisonAlien
PoisonAlien / methrix.R
Last active April 28, 2019 21:33
Matrix style ATGC plot
png(filename = "xx.png", width = 1200, height = 700, res = 70, bg = "white")
par(bg = 'black', mar = c(0, 0, 0, 0))
plot(1:50,1:50, pch = NA, axes = FALSE)
for(i in 1:50){
x = sample(x = c("A", "T", "G", "C"), size = 50, replace = TRUE)
points(x = rep(i, 50), y = 1:50, pch = x, cex = 0.8, col = "green")
}
par(family = "serif")
legend(x = "center", legend = "M E T H R I X", text.col = "green", bg = "black", cex = 3, adj = 0.1)
@PoisonAlien
PoisonAlien / parse_rc.rs
Last active June 11, 2019 13:57
Parse output from bam-readcount
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::env;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2{