Skip to content

Instantly share code, notes, and snippets.

View andreas-wilm's full-sized avatar

Andreas Wilm andreas-wilm

View GitHub Profile
@andreas-wilm
andreas-wilm / index.sl
Created November 21, 2019 13:53
bwa index on slurm with singularity
#!/bin/bash
#SBATCH --job-name=bwaindex
#SBATCH --output=bwaindex.out
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --time=01:00:00
#SBATCH --mem-per-cpu=20000
SIF=/shared/containers/dnazoo-uwa-20191106.sif
@andreas-wilm
andreas-wilm / url_to_deploy.py
Last active August 30, 2019 02:28
Convert Github JSON URL to directly usable "Deploy on Azure" link
import urllib.parse
TEMPLATEURL = "https://portal.azure.com/#create/Microsoft.Template/uri/"
def toraw(ghurl):
# convert github url to its raw equivalent, if needed
ghbase = "https://github.com"
ghrawbase = "https://raw.githubusercontent.com"
if ghbase in ghurl and "/blob/" in ghurl:
return ghurl.replace(ghbase, ghrawbase).replace("/blob/", "/")
@andreas-wilm
andreas-wilm / patentlanguage.sql
Created August 7, 2019 09:47
Microsoft Academic Graph: Patents vs Language
// modify the following two values as needed
DECLARE @dataVersion string = "mag-YYYY-MM-DD";
DECLARE @blobAccount string = "XXX";
DECLARE @uriPrefix string = "wasb://" + @dataVersion + "@" + @blobAccount + "/";
DECLARE @outFile string = "/Output/patent_languages.tsv";
@Papers = Papers(@uriPrefix);
@PaperLanguages = PaperLanguages(@uriPrefix);
@andreas-wilm
andreas-wilm / defprio.py
Created April 16, 2019 09:03
on-add hook to add default priority to taskwarrior tasks if not specified
#!/usr/bin/env python
import sys
import json
DEF_PRIO = 'M'
added_task = json.loads(sys.stdin.readline())
if 'priority' not in added_task:
sys.stderr.write("Adding default priority: {}\n".format(DEF_PRIO))
added_task['priority'] = DEF_PRIO
@andreas-wilm
andreas-wilm / CountMagDocTypes.sql
Last active April 11, 2019 17:37
Summarizing Document Types in Microsoft Academic Graph
DECLARE @dataVersion string = "mag-2019-03-22";
DECLARE @blobAccount string = "<PLACEHOLDER>";
DECLARE @uriPrefix string = "wasb://" + @dataVersion + "@" + @blobAccount + "/";
DECLARE @typeCounts string = "/Output/TypeCounts.tsv";
@Papers = Papers(@uriPrefix);
@Types = SELECT
DocType, COUNT(1) AS cnt
FROM
@andreas-wilm
andreas-wilm / nftrace.py
Created January 25, 2019 01:53
Incomplete five minute hack to massage NF trace.txt
#!/bin/env python
import csv
import sys
import numpy
trace = sys.argv[1]
@andreas-wilm
andreas-wilm / aws-linux2-install-singularity3.sh
Created October 26, 2018 16:04
Install Singularity3 on Amazon Linux2
# https://www.sylabs.io/guides/3.0/user-guide/quick_start.html#quick-installation-steps
# https://unix.stackexchange.com/questions/1338/what-is-the-fedora-equivalent-of-the-debian-build-essential-package
sudo yum install make automake gcc gcc-c++ kernel-devel
sudo yum install openssl-devel libuuid-devel
# install go
export VERSION=1.11 OS=linux ARCH=amd64
cd /tmp
wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz
@andreas-wilm
andreas-wilm / nvmraid.sh
Last active June 5, 2023 22:11
Combine all NVMs on AWS instance (e.g. i3) as raid0 and mount as data
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/raid-config.html
nvmes=$(sudo lsblk | awk '/^nvme/ {printf "/dev/%s ", $1}')
sudo mdadm --create --verbose /dev/md0 --level=0 --name=my_raid --raid-devices=$(echo $nvmes | wc -w) $nvmes
sleep 10# crutch
sudo mkfs.ext4 -L my_raid /dev/md0
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
sudo dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
sudo mkdir /data
sudo mount LABEL=my_raid /data
sudo chown ec2-user:ec2-user /data/
@andreas-wilm
andreas-wilm / aws-default-profile-from-csv
Created October 24, 2018 02:20
Populate default AWS profile from CSV
#!/bin/bash
csv=$1
test -z "$csv" && exit 1
test -e "$csv" || exit 1
grep -q '^AccessKeyId' $csv || exit 1
test $(cat "$csv" | wc -l) -eq 2 || exit 1
akid=$(tail -n1 $csv | cut -d',' -f 2)
sak=$(tail -n1 $csv | cut -d',' -f 2)
@andreas-wilm
andreas-wilm / htsbgz.nim
Created August 24, 2018 08:08
hts-nim bgzip read example
import hts
var b: BGZ
open(b, "example.txt.gz", mode="rb")
set_threads(b, 2)
var kstr: kstring_t
kstr.l = 0
kstr.m = 0
kstr.s = nil