Navigation Menu

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 / find_adapters.sh
Created April 20, 2024 10:33
Find likely adapter sequences in a set of paired end FASTQs
#!/bin/bash
# Given a directory of fastq files, use bbmerge to find adapters sequences for every sample,
# align and find the consensus.
# Final consensus is in r1_adapter.consensus.fa and r2_adapter.consensus.fa - trim by hand
# if the automatic trimming up the the first 'n' isn't sensible
# Requires: bbmerge.sh (bbmap), muscle, emboss (cons)
@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 / R-kill-vscode-remote.sh
Last active February 7, 2024 04:03
tmux persistent R session for vscode-R
#!/bin/bash
R_TMUX_SESSION_NAME="${R_TMUX_SESSION_NAME:-vscode-r}"
TMUX_CMD=$(command -v tmux)
if ! [ -x "$(command -v tmux)" ]; then
echo "Error: tmux is not installed."
exit 1
fi
@pansapiens
pansapiens / README.md
Created November 9, 2023 03:53
Gzip compression heatmap

Gzip compression heatmap

Generates a heatmap plot showing the compression ratio of different block through a file.

Show interesting patterns in FASTQ files, and may be useful for diagnosing pathological or unusual data. I find using the zscore transformation for the plot is more informative.

Run like:

./compression_heatmap.py -b 1048576 -c rainbow -t zscore SRR11794587_2.fastq.gz
@pansapiens
pansapiens / standalone_html.py
Last active October 6, 2023 23:16
Convert HTML to a self contained file with inline Base64 encoded PNG images
#!/usr/bin/env python
# A simple script to suck up HTML, convert any images to inline Base64
# encoded format and write out the converted file.
#
# Usage: python standalone_html.py <input_file.html> <output_file.html>
#
# TODO: Consider MHTML format: https://en.wikipedia.org/wiki/MHTML
import os
from bs4 import BeautifulSoup
@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.
@pansapiens
pansapiens / deinterleave_mgi_lanes.sh
Created July 25, 2023 07:10
Deinterleave MGI FASTQ lanes
#!/bin/bash
# This script deinterleaves a FASTQ file generated by an MGI sequencer with two flowcell lanes
# where headers are in the format: @v300009551L1C002R003000000/1 with L1 or L2 indicating the lane
# This can be useful for some analyses since each lane can behave like a technical replicate (eg DADA2 error correction?)
set -e
set -o pipefail
input_fastq_gz="$1" # input FASTQ file
samplename="$(basename $input_fastq_gz .fastq.gz)"
@pansapiens
pansapiens / Dockerfile
Last active March 28, 2023 12:23
bcl-convert in Docker / Singularity
FROM centos:7
#
# You'll need to download bcl-convert-3.6.3-1.el7.x86_64.rpm from
# https://support.illumina.com/downloads/bcl-convert-downloads.html
# Yay clickwrap licenses !
#
# Building:
#
# docker build -t bcl-convert:latest -t bcl-convert:3.6.3 .
# sudo singularity build bcl-convert.sif docker-daemon://bcl-convert:latest
@pansapiens
pansapiens / ssh_config_split.py
Created March 27, 2023 09:45
Split ~/.ssh/config file into separate per-host files
#!/usr/bin/env python
import os
import shutil
import re
import sys
import difflib
import argparse
def parse_ssh_config(config_path):
@pansapiens
pansapiens / 0README.md
Last active November 22, 2022 00:58
RStudio Server in Singularity (via rocker), M3 HPC flavour