Skip to content

Instantly share code, notes, and snippets.

View hiraksarkar's full-sized avatar

Hirak Sarkar hiraksarkar

View GitHub Profile
@hiraksarkar
hiraksarkar / auto_sub2.sh
Created December 21, 2018 17:38
check queue for empty place and submit
#!/bin/bash
MAX_LIMIT=12
#number of things queue
#CHEKC IF it less than try submeating jobs
while : ; do
NUM_QUEUED=`qstat -u moamin | awk '$10 == "Q" { count++ } END {print count }'`
NUM_RUNNING=`qstat -u moamin | awk '$10 == "R" { count++ } END {print count }'`
MAX_RUNNING=`qstat -u moamin | awk '$10 == "R" { print $4 }' | cut -d"_" -f3 | sort -n | tail -1`
MAX_SUBMITTED=`qstat -u moamin | awk '$10 == "Q" { print $4 }' | cut -d"_" -f3 | sort -n | tail -1`
@hiraksarkar
hiraksarkar / read_binary_gzipped.cpp
Created December 14, 2018 18:45
Read Binary data file without boost support (using zstr header)
#include <iostream>
#include <fstream>
#include <sstream>
#include <functional>
#include <sys/stat.h>
#include <memory>
#include <vector>
#include <numeric>
#include "zstr.hpp"
#From stackoverflow
def get_merged_intervals(intervals):
sorted_by_lower_bound = sorted(intervals, key=lambda tup: tup[0])
merged = []
for higher in sorted_by_lower_bound:
if not merged:
merged.append(higher)
else:
lower = merged[-1]
@hiraksarkar
hiraksarkar / extract_transcript_intron.sh
Last active December 14, 2018 21:53
3 line script to extract intron boundaries per transcript
## requirement bed tools
BIN='/home/hirak/bedtools2/bin'
## Gencode
## gencode.v29.chr_patch_hapl_scaff.annotation.gtf
GTF_FILE="gencode.v29.chr_patch_hapl_scaff.annotation.gtf"
# extract transcript boundaries
cat $GTF_FILE | awk 'BEGIN{OFS="\t";} $3=="transcript" {print $1,$4-1,$5,$12}' | tr -d "\"" | tr -d ";" | $BIN/sortBed > gencode_transcript_intervals.bed
# merge exon boundaris
@hiraksarkar
hiraksarkar / dust_python.py
Last active November 26, 2018 08:47
Native dust in python (N.B. This is not accelerated sdust)
from collections import deque
import itertools
# Make dictionary of triplets
i = 0
triplet_index = {}
inverse_triplet = {}
for x in list(itertools.product(['A','T','G','C'], repeat=3)):
triplet_index[''.join(x)] = i
inverse_triplet[i] = ''.join(x)
#!/bin/bash
####################################
USAGE: bash auto_sub.sh <QUEUE_LIM> <MAX_JOB_NUM>
###################################
USER="$(whoami)"
MAX_LIMIT=$1
MAX_JOB_NUM=$2
@hiraksarkar
hiraksarkar / spacemacs-cheshe.md
Last active October 1, 2018 16:20 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC f e d - open .spacemacs file
  • SPC f e R - reload .spacemacs file
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
@hiraksarkar
hiraksarkar / bamfilter_oneliners.md
Created May 30, 2018 14:40 — forked from davfre/bamfilter_oneliners.md
SAM and BAM filtering oneliners
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.