Skip to content

Instantly share code, notes, and snippets.

View nathanhaigh's full-sized avatar

Nathan S. Watson-Haigh nathanhaigh

  • Alkahest Inc.
  • Adelaide, Australia
  • 05:07 (UTC +10:30)
  • X @watsonhaigh
View GitHub Profile
@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 / 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 / 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 / mlFASTA2slFASTA.sh
Created November 14, 2014 04:09
Convert a FASTA file containing multi-line (wrapped) sequences to occupy a single line
#!/bin/bash
# Convert a multi-line FASTA file into a single line FASTA file
# These are easier/faster to process using native UNIX tools like paste - - < in.fasta
dos2unix | awk 'BEGIN { RS = "\n>"; FS = "\n"; OFS = "" };
{
if (NR == 1) {
print $1
} else
if (NR > 1) {
print ">"$1
@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 / 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 / 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 / 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
@nathanhaigh
nathanhaigh / screenrc
Last active December 15, 2015 04:19
My screenrc file
# Get/install this screenrc file using something like this (the URL is specific to a particular revision, update as needed):
# wget https://gist.github.com/nathanhaigh/5200267/raw/17c8e4a95df8540dfb5a8374c8f78c1f2568e43f/screenrc -O ~/.screenrc
startup_message off
caption string "%?%F%{= Bk}%? %C%A %D %d-%m-%Y %{= kB} %t%= %?%F%{= Bk}%:%{= wk}%? %n "
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{R} %d/%m %{W}%c %{g}]'
altscreen on