Skip to content

Instantly share code, notes, and snippets.

View nathanhaigh's full-sized avatar

Nathan S. Watson-Haigh nathanhaigh

  • Alkahest Inc.
  • Adelaide, Australia
  • 19:56 (UTC +10:30)
  • X @watsonhaigh
View GitHub Profile
@nathanhaigh
nathanhaigh / deinterleave_fastq.sh
Last active May 6, 2024 06:38
deinterleave FASTQ files
#!/bin/bash
# Usage: deinterleave_fastq.sh < interleaved.fastq f.fastq r.fastq [compress]
#
# Deinterleaves a FASTQ file of paired reads into two FASTQ
# files specified on the command line. Optionally GZip compresses the output
# FASTQ files using pigz if the 3rd command line argument is the word "compress"
#
# Can deinterleave 100 million paired reads (200 million total
# reads; a 43Gbyte file), in memory (/dev/shm), in 4m15s (255s)
#
@nathanhaigh
nathanhaigh / add_user_accounts.sh
Created July 5, 2022 11:39
Generate user account
#!/usr/bin/env bash
#####
# Set default command line options
#####
USERNAME_PREFIX=user
USERNAME_SUFFIX_START=1
USERNAME_SUFFIX_END=100
USERNAME_SUFFIX_ZERO_PADDING_LENGTH=4
@nathanhaigh
nathanhaigh / interleave_fastq.sh
Last active March 28, 2022 09:11
Interleave reads from 2 FASTQ files and output to STDOUT.
#!/bin/bash
# Usage: interleave_fastq.sh f.fastq r.fastq > interleaved.fastq
#
# Interleaves the reads of two FASTQ files specified on the
# command line and outputs a single FASTQ file of STDOUT.
#
# Can interleave 100 million paired reads (200 million total
# reads; a 2 x 22Gbyte files), in memory (/dev/shm), in 6m54s (414s)
#
# Latest code: https://gist.github.com/4544979
@nathanhaigh
nathanhaigh / install.sh
Last active June 2, 2021 22:49 — forked from bmoore/install.sh
Gitorious installation script for Ubuntu 12.04 LTS
#!/bin/bash
# You should clone this gist to obtain the installation and patch file
# and then run it locally, after changing the below settings to something
# suitable for your system. Something like this:
# sudo apt-get install -y ssh
# cd
# scp -r nhaigh@bioserver:git/sysadmin/generic/gitorious_install ./
# Edit the settings below, then run the following as root:
# cd gitorious_install && sh ./install.sh
#
@nathanhaigh
nathanhaigh / depth2bedgraph.awk
Created June 7, 2017 13:13
Converts the output of samtools depth into bedgraph format
#!/usr/bin/awk
# Takes output of "samtools depth" and reformats into grouped bedgraph format:
# samtools depth -r ${loc} -Q 1 --reference $fasta $bam | mawk -f scripts/depth2bedgraph.awk > /tmp/my.bedgraph
# Example input:
#chr1 26 2
#chr1 27 2
#chr1 28 2
#chr1 29 5
#chr1 30 5
#chr1 31 5
@nathanhaigh
nathanhaigh / sra_process.sh
Created July 11, 2013 05:24
Example script for downloading (using aspera) and extracting paired-end data from the SRA and performing parallel compression using pigz.
#!/bin/bash
# Bash script to download a bunch of *.sra files from the NCBI SRA, using
# the aspera client, and extract FASTQ data using the SRA Toolkit.
max_bandwidth_mbps=50
# These SRA files are for the durum genome
files=(
'SRR567512.sra'
'SRR567559.sra'
@nathanhaigh
nathanhaigh / trackList.json
Last active July 4, 2018 05:06
Callbacks to generate links for Dbxref and Ontology_term entries in JBrowse GFF tracks
"fmtDetailValue_Dbxref" : "function(dbxref){if(typeof dbxref!='string'){return dbxref}var dbid=dbxref.split(':');var prefix='';switch(dbid[0].toLowerCase()){case 'interpro':prefix='http://www.ebi.ac.uk/interpro/entry/';break;case 'pfam':prefix='http://pfam.sanger.ac.uk/family/';break;case 'reactome':prefix='http://www.reactome.org/content/detail/';break;case 'unipathway':prefix='http://www.grenoble.prabi.fr/obiwarehouse/unipathway/upa?upid=';break;case 'kegg':prefix='http://www.genome.jp/kegg-bin/show_pathway?ec';break;case 'prositepatterns':prefix='http://prosite.expasy.org/';break;case 'prositeprofiles':prefix='http://prosite.expasy.org/cgi-bin/prosite/PSView.cgi?ac=';break;case 'smart':prefix='http://smart.embl-heidelberg.de/smart/do_annotation.pl?BLAST=DUMMY&DOMAIN=';break;case 'superfamily':prefix='http://supfam.org/SUPERFAMILY/cgi-bin/scop.cgi?sunid=';dbid[1]=dbid[1].replace('SSF','');break;case 'gene3d':prefix='http://www.cathdb.info/version/latest/superfamily/';dbid[1]=dbid[2];break;case 'pirsf':prefi
@nathanhaigh
nathanhaigh / gff3_split.pl
Last active June 8, 2017 01:33
Perl script to perform coordinate transformation on GFF3 files when reference sequences are split into multiple pieces.
#!/usr/bin/env perl
use strict;
use warnings;
my $bed_file = shift @ARGV;
my $suffix_fmt = '_part%01d';
open(my $bed_fh, '<', $bed_file) || die "Couldn't open BED file: $!\n";
my %cut_positions;
@nathanhaigh
nathanhaigh / update_openstack_python_apis.sh
Last active December 22, 2015 21:19
Install/Update OpenStack Python API's
#!/bin/bash
sudo apt-get update && sudo apt-get -y dist-upgrade
urls=(
'https://github.com/pypa/pip.git'
'git://github.com/openstack-dev/pbr.git'
'git://github.com/iguananaut/d2to1.git'
'https://github.com/kelp404/six.git'
'https://github.com/openstack/python-glanceclient.git'
'https://github.com/openstack/python-keystoneclient.git'
@nathanhaigh
nathanhaigh / gist:5589673
Last active December 17, 2015 09:48
Setup my dev Ubuntu 12.04 VM from a vanilla Ubuntu 12.04.1 Server install
#!/bin/bash
# First setup everything needed for connecting to it via an NX connection
wget https://gist.github.com/nathanhaigh/4007406/raw/40717e3031bec9efccc3dfcc38c3a50c222d29d9/NXServer.sh
chmod +x NXServer.sh
./NXServer.sh
apt-get -y install libreoffice-java-common htop sysstat git xclip dos2unix
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar xzf install-tl-unx.tar.gz && rm install-tl-unx.tar.gz