Skip to content

Instantly share code, notes, and snippets.

View pansapiens's full-sized avatar

Andrew Perry pansapiens

  • Melbourne, Australia
View GitHub Profile
@pansapiens
pansapiens / csv_join_rm_mm.py
Last active September 7, 2018 06:59
Join CSVs for DART BLAST hits
#!/usr/bin/env python
from __future__ import print_function
import sys
from collections import OrderedDict
# Usage:
# python csv_join_rm_mm.py my_dart_ref.csv my_blast_hits.csv >joined_hits.csv 2>warnings.txt
REF_DART_ID_PREFIX = "SNP_"
@pansapiens
pansapiens / Singularity.spec
Last active January 15, 2019 19:27 — forked from vsoch/Singularity.spec
A DeepVariant image for Singularity, reliant on a localimage pull of layers first
Bootstrap: localimage
From: deepvariant-0.6.1.simg
# Install Google Cloud SDK for the gcloud tool, then:
# We grab the official Docker image, push it to a locally running container repo, then get
# Singularity to pull it back.
# gcloud docker -- pull gcr.io/deepvariant-docker/deepvariant:0.6.1
# docker tag gcr.io/deepvariant-docker/deepvariant:0.6.1 localhost:5000/deepvariant:0.6.1
# docker run -d -p 5000:5000 --restart=always --name registry registry:2
# docker push localhost:5000/deepvariant:0.6.1
@pansapiens
pansapiens / .bashrc
Last active March 13, 2024 04:15
Some SLURM aliases
alias default_account='sacctmgr --parsable2 show user -s andrewpe | tail -1 | cut -f 2 -d '\''|'\'''
alias fairshare='sshare -a --accounts $(default_account)'
alias jhistory='sacct -u ${USER} --starttime $(date -d "-1 month" +%Y-%m-%d) --format=User,JobID,Jobname,partition,state,exitcode,time,start,end,elapsed,MaxRss,MaxVMSize,nnodes,ncpus,nodelist'
alias jshow='scontrol show job'
alias jinfo='sacct --starttime $(date -d "-1 month" +%Y-%m-%d) --format=User,JobID,Jobname%64,partition,qos,ReqCPUS,ReqMem,state,exitcode,time,start,end,elapsed,MaxRss,MaxVMSize,nnodes,ncpus,nodelist -j'
alias node_types='sinfo -o '\''%c %m %n %R'\'' --sort '\''P'\'''
alias qhogs='sreport cluster UserUtilizationByAccount -t hours'
alias si='sinfo -o "%20P %5D %14F %8z %10c %10m %10d %11l %16f %N"'
alias sq='squeue -o "%8i %.60j %4t %10u %20q %20a %10g %20P %10Q %5D %2C %5m %11l %11L %R"'
alias squ='squeue -u $USER --format="%.18i %.9P %.60j %.8u %.8a %.2t %.10M %.6D %R"'
@pansapiens
pansapiens / grab_from_cloudstor_pw_protect.py
Last active March 2, 2021 22:52
Download a password protected file from CloudStor / ownCloud / NextCloud on the commandline
#!/usr/bin/env python3
# https://colab.research.google.com/drive/1CGOygPAmjTxWnmsywv178dh3u36ZRBgv
# You'll need to install the `robobrowser` Python package.
# Do it in a virtualenv like:
#
# python3 -m venv ~/.virtualenvs/cloudstor
# source ~/.virtualenvs/cloudstor/activate
# pip3 install robobrowser
#!/bin/bash
# A simple script for mounting NTFS disks on macOS
if [ $# -eq 0 ]; then
diskutil list
echo
echo "No arguments provided."
echo "Usage: mount-ntfs.sh [diskXsY]"
echo "eg: mount-ntfs.sh disk2s2"
echo
@pansapiens
pansapiens / views.py
Created February 20, 2018 01:26
Django REST Framework CSV parser, RFC 4180
from typing import Dict, List
import csv
from rest_framework import status
from rest_framework.response import Response
from rest_framework.parsers import JSONParser, BaseParser
from rest_framework.views import APIView
class CSVTextParser(BaseParser):
"""
A CSV parser for DRF APIViews.

Keybase proof

I hereby claim:

  • I am pansapiens on github.
  • I am pansapiens (https://keybase.io/pansapiens) on keybase.
  • I have a public key ASADQ2rj-JVJbBwI3120kk1etbdVu-bi38W1gm8JKZ3R0go

To claim this, I am signing this object:

@pansapiens
pansapiens / ENA REST API.ipynb
Created January 22, 2018 04:01
Interacting with the ENA REST API
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Build like: $ sudo singularity build --writable consexpression.simg Singularity
# Run like: $ singularity run --bind CONFIG_tool.txt:/consexpression/dao/CONFIG_tool.txt consexpression.simg
Bootstrap: docker
From: ubuntu:17.10
# Bootstrap: debootstrap
# OSVersion: xenial
# MirrorURL: http://au.archive.ubuntu.com/ubuntu/
@pansapiens
pansapiens / openapi_yaml.py
Created January 4, 2018 02:35
drf_openapi: Render YAML OpenAPI / Swagger instead of JSON
import yaml
from rest_framework import status
from rest_framework_swagger.renderers import OpenAPIRenderer as _OpenAPIRenderer
from rest_framework.renderers import JSONRenderer
from openapi_codec import OpenAPICodec as _OpenAPICodec
from coreapi import Document
from drf_openapi.codec import _generate_openapi_object
from coreapi.compat import force_bytes
from collections import OrderedDict