Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
#
# Usage: sspace_evidence2agp.pl formattedcontigs.fasta < final.evidence > out.agp 2> out.stderr
# e.g. sspace_evidence2agp.pl intermediate_results/standard_output.formattedcontigs.fasta < standard_output.final.evidence > standard_output.agp 2> standard_output.agp.stderr
#
# What this script does:
# 1) Uses the *.final.evidence file created by SSPACE to generate an AGP v2.0 file.
# 2) Uses information in the *.formattedcontigs.fasta file to recover the original contig
# names.
# 3) Non-positive length gaps are output as component_type=U and gap length 100, as per the
@hliang
hliang / gist:10403858
Last active August 29, 2015 13:58
makes tab bar distinguishable

In Ubuntu 12.10, tabbed interfaces such as in gnome-terminal under unity it is difficult to visually distinguish the selected tab from the unselected ones.

Modify ~/.config/gtk-3.0/gtk.css to solve this problem.

TerminalWindow .notebook tab {
    background-color: #D1D0CE;
}
TerminalWindow .notebook tab:active {
 background-color: #FFF5EE;
@hliang
hliang / gist:1fa9901f7fe636ac0e31
Created August 4, 2014 21:07
number of reads vs. coverage
excap_cov.df = read.table("input.txt", header=F, sep="\t")
colnames(excap_cov.df) = c("sample_name", "total_reads", "pct_mapped", "pct_dup",
"mean_cov", "pct_on_target", "pct_10X", "pct_20X", "pct_50X",
"mean_insert_size", "std_dev_insert_size")
# convert character of percentage into numeric
excap_cov.df$pct_dup = as.numeric(sub("%","", excap_cov.df$pct_dup))/100
excap_cov.df$pct_mapped = as.numeric(sub("%","", excap_cov.df$pct_mapped))/100
# hold a job
qalter -h u 123456
# unhold
qalter -h U 123456
# list of holds
'u' denotes a user hold.
's' denotes a system hold.
'o' denotes a operator hold.
@hliang
hliang / gist:56862e0277a7ce1ea7d6
Created August 22, 2014 22:05
Condition evaluation of command output
# condition evaluation of command output
# e.g.
# keep checking whether a file contains PATTERN string
while [[ $(grep -c 'PATTERN' test.txt) == 1 ]]; do echo test.txt contains PATTERN ; date; sleep 2; done
@hliang
hliang / gist:4665a72d7755926dd7a2
Created August 22, 2014 22:08
Submit a new job after old job is done
# start a new job once after an old job finish
while qstat -j 112233 > /dev/null; do echo -n "Previous job is still running... "; date; sleep 600; done; echo "Previous job completed. Now starting new job."; qsub newjob.sh
@hliang
hliang / mtrush.R
Created March 17, 2017 06:05
code snippet from The Art of R Programming: A Tour of Statistical Software Design
# a code snippet from the book:
# The Art of R Programming: A Tour of Statistical Software Design
# load library
library("pixmap")
# show mtrush
mtrush1 = read.pnm("path/to/mtrush1.pgm")
mtrush1
plot(mtrush1)
#!/bin/bash
#SBATCH -p bcbio
#SBATCH -a 1-60
set -e
source /WORK/app/toolshs/cnmodule.sh
module load bedtools/2.26.0
which bedtools
bedtools --version
## create output dir
# Assumes you've already run coverageBed -hist, and grep'd '^all'. E.g. something like:
# find *.bam | parallel 'bedtools -abam {} -b capture.bed -hist | grep ^all > {}.all.txt'
setwd("./qc/")
# Get a list of the bedtools output files you'd like to read in
bedcov_dir = "./bedcov_cds_canol/"
print(files <- list.files(path=bedcov_dir, recursive=TRUE, pattern="samp.*all.txt$", full.names=TRUE))
# This regular expression leaves me with "samp01", "samp02", and "samp03" in the legend.
#! /usr/bin/env python
'''
==================
ucsc_snapshots
==================
retrieve pictures from the UCSC Genome Browser based on coordinates
specified from BED3+ file and a session ID (hgsid).