Skip to content

Instantly share code, notes, and snippets.

View lh3's full-sized avatar

Heng Li lh3

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
my %opts = ();
getopts('fd:', \%opts);
die("Usage: pexe.pl [options] <exe1> [exe2 [...]]
# OUTSIDE VM: launch an instance
gcloud compute instances create lh3test --machine-type n1-standard-1 --image-project ubuntu-os-cloud --image-family ubuntu-1604-lts
#
# INSIDE VM!!!
#
# install dependencies
sudo apt-get update
sudo apt-get install libboost-all-dev cmake libstdc++6 clang-3.8 cmake git-all python3 zlib1g-dev
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
my %opts = (t=>'ct', m=>50);
getopts('t:m:3', \%opts);
my $type;
@lh3
lh3 / paf2sam.js
Created August 23, 2016 17:23
Preliminary and incomplete PAF->SAM converter (for wgsim_eval.pl)
var getopt = function(args, ostr) {
var oli; // option letter list index
if (typeof(getopt.place) == 'undefined')
getopt.ind = 0, getopt.arg = null, getopt.place = -1;
if (getopt.place == -1) { // update scanning pointer
if (getopt.ind >= args.length || args[getopt.ind].charAt(getopt.place = 0) != '-') {
getopt.place = -1;
return null;
}
if (getopt.place + 1 < args[getopt.ind].length && args[getopt.ind].charAt(++getopt.place) == '-') { // found "--"
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
my %opts = (g=>37, l=>2, L=>100);
getopts('g:l:L:o:Huc', \%opts);
# check path
@lh3
lh3 / fq_download.md
Last active December 30, 2017 22:22
Downloading gzip'd fastq
Source Dst. file type Protocol Time (s) Command Line
NCBI .sra ftp 296 wget
NCBI .fastq.gz sra toolkit ~23000 fastq-dump -Z --gzip --split-spot
local file sra=>fastq.gz sra toolkit ~15000 fastq-dump --gzip --split-spot --split-3
EBI .fastq.gz aspera 513+492 aspera -QT -l 300m
EBI .fastq.gz ftp 1876+1946 wget

Notes:

@lh3
lh3 / 00_fsi.md
Last active March 6, 2016 04:32
Recoding-free fast BAM slicing for BAMs generated by samtools-0.1.8+

This gist demonstrates fast BAM slicing without re-compressing the alignment data. It only works for BAMs generated by samtools-0.1.8+ and htslib, as it requires the BAM to be block aligned.

To use this gist, you need to first acquire and compile htslib. After that:

cd htslib; gcc -g -O2 -Wall -o fsi -I. /path/to/fsi.c libhts.a -lz
./fsi aln.bam > aln.fsi
perl fsi-get.pl aln.bam aln.fsi chr11:1000000-1200000 > slice.bam
@lh3
lh3 / 00README.md
Last active February 9, 2016 18:38

This gist implements a proof-of-concept web server to provide remote access to multiple BAMs. You can launch the server with:

go run hts-server.go -e /path/to/samtools bam-dir1 bam-dir2

and test it with:

curl -s http://127.0.0.1:8000/

The server regards bam-dir1 and bam-dir2 as study accessions. For a BAM file bam-dir1/myfile1.bam, the file accession is myfile1. It is required that every file has a unique file name across all input directories (i.e. even in two directories, two files must be named differently).

#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
my %opts = (t=>8, k=>17, m=>0.6, s=>200, p=>'wtasm');
getopts('t:p:k:m:s:', \%opts);
die (qq/Usage: smartdenovo.pl [options] <reads.fa>
Options: