Skip to content

Instantly share code, notes, and snippets.

@inodb
inodb / deletion_fastq_simulation_ensembl_api.md
Last active June 3, 2016 17:49
Generate deletions of arbitrary length in hg19 using ensembl rest api

Generate reads with deletions of arbitrary length using ensembl rest api

for del_size in 10 30 50 70 90 150 300 600
do
  chr=17
  start_pos=4126000
  read_length=100
  ens_url="http://grch37.rest.ensembl.org/sequence/region/human/"
  qual=$(python -c "print 'A'*${read_length}")
  (
@inodb
inodb / grep_color_barcodes.sh
Created May 25, 2016 23:47
Use grep --color=always to color a file by another file of patterns. Pretty useful for sequencing analysis
color_grep_file() {
COLOR_CMD="cat $1"
echo $COLOR_CMD
local i=31;
while read line; do
echo $line
COLOR_CMD="$COLOR_CMD | GREP_COLOR='01;$i' grep --color=always -E '$line|$'"
i=$(( $i + 1 ))
done < $2
COLOR_CMD="$COLOR_CMD | less -RS"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@inodb
inodb / string-format.js
Created February 25, 2016 23:13 — forked from poxip/string-format.js
Python-like string format in JavaScript
/**
* Python-like string format function
* @param {String} str - Template string.
* @param {Object} data - Data to insert strings from.
* @returns {String}
*/
var format = function(str, data) {
var re = /{([^{}]+)}/g;
return str.replace(/{([^{}]+)}/g, function(match, val) {
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Plot</title>
<style>
/* BEGIN /Users/debruiji/anaconda/lib/python2.7/site-packages/bokeh/server/static/css/bokeh.min.css */
.bk-bs-container{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}@media(min-width:768px){.bk-bs-container{width:750px}}@media(min-width:992px){.bk-bs-container{width:970px}}@media(min-width:1200px){.bk-bs-container{width:1170px}}.bk-bs-container-fluid{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}.bk-bs-row{margin-left:-15px;margin-right:-15px}.bk-bs-col-xs-1,.bk-bs-col-sm-1,.bk-bs-col-md-1,.bk-bs-col-lg-1,.bk-bs-col-xs-2,.bk-bs-col-sm-2,.bk-bs-col-md-2,.bk-bs-col-lg-2,.bk-bs-col-xs-3,.bk-bs-col-sm-3,.bk-bs-col-md-3,.bk-bs-col-lg-3,.bk-bs-col-xs-4,.bk-bs-col-sm-4,.bk-bs-col-md-4,.bk-bs-col-lg-4,.bk-bs-col-xs-5,.bk-bs-col-sm-5,.bk-bs-col-md-5,.bk-bs-col-lg-5,.bk-bs-col-xs-6,.bk-bs-col-sm-6,.bk-bs-col-md-6,.bk-bs-col-lg-6,.bk
@inodb
inodb / gbgrep
Created November 5, 2015 23:14 — forked from nas/gbgrep
git blame with grep
#!/usr/bin/env ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
puts "\n-----------------------------------------------------------"
puts "GREP RESULT"
puts '-----------------------------------------------------------'
puts grep
files = grep.scan /.*\:\d+/
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export PORTAL_HOME=$DIR
#!/bin/bash
# Deduplicates all .txt files in sudirs
# creates file with .dedup postfix
# keeps one header line if file does not contains comments
# keeps two header lines if file contains comments
find . -name '*.txt' | parallel -k "f=$(mktemp -t mskimpact) &&" sort {} '|' uniq -d '>' '$f' '&&' test -s '$f' '&&' '('grep -q '^#' {} '&&' '('head -2 {} '>' {}.dedup '&&' tail -n +3 {} '|' sort '|' uniq '>>' {}.dedup')' '||' '('head -1 {} '>' {}.dedup '&&' tail -n +2 {} '|' sort '|' uniq '>>' {}.dedup'))'
# to replace all files run:
#find . -name '*.dedup' | parallel -k 'f='{} '&&' mv {} '${f/.dedup/}'
@inodb
inodb / ensemble_rest.md
Created August 27, 2015 22:57
Get region from ensembl rest and translate one-liner

Ensembl REST API

Get region from ensembl REST and translate in one line

curl 'http://grch37.rest.ensembl.org/sequence/region/human/17:41267755:41267763:-1' -H 'Content-type:text/x-fasta' \
    | python <(echo -e "import sys\nfrom Bio import SeqIO\nprint [r.seq.translate() for r in SeqIO.to_dict(SeqIO.parse(sys.stdin, 'fasta')).values()][0]")
@inodb
inodb / init_raylim_pipeline
Last active August 29, 2015 14:16
init_raylim_pipeline
#!/bin/bash
echo "Cloning raylim/scripts"
git clone https://github.com/raylim/scripts
git clone https://github.com/raylim/modules
cat > Makefile <<EOF
# Autogenerated Makefile with init_raylim_pipeline
include modules/Makefile
EOF