Skip to content

Instantly share code, notes, and snippets.

View SamStudio8's full-sized avatar

Sam Nicholls SamStudio8

View GitHub Profile
@SamStudio8
SamStudio8 / acct_parse.py
Last active November 28, 2023 16:12
SGE QACCT Parsing
"""
Provides functions for the purpose of parsing a Sun Grid Engine (SGE)
accounting file for job metadata.
"""
__author__ = "Sam Nicholls <msn@aber.ac.uk>"
__copyright__ = "Copyright (c) Sam Nicholls"
__version__ = "0.0.32"
__maintainer__ = "Sam Nicholls <msn@aber.ac.uk>"
@SamStudio8
SamStudio8 / subset_xam
Last active October 25, 2023 16:15
Safely subset a BAM or CRAM with samtools+picard
#!/usr/bin/env bash
# Name subset_xam
# Description Safely subset a BAM (or CRAM) with samtools+picard
# Author @samstudio8
# Date 2022-11-01
# Version 1.0.3
PICARD_JAR=${PICARD_JAR:-}
xam=$1
ref=$2
seq=$3
@SamStudio8
SamStudio8 / template.j2
Created September 17, 2023 19:52
Samposium v1 index
---
title: "Samposium v1"
url: "/v1/"
layout: "old_archive"
---
This listing enumerates the posts from the previous iteration of Samposium.
Posts range between long rambling posts about my PhD that I never expected anyone to read, and things that I did to distract myself from finishing my PhD that I hoped people would read.
Each link will take you to a static snapshot of the decommissioned Wordpress post.
@SamStudio8
SamStudio8 / .gitlab-ci.nojob.yaml
Last active June 21, 2022 13:18
job with variable profiles
# Nicer syntax but leads to ugly job names,
# and doesn't work when variables strings are long
# See https://gitlab.com/gitlab-org/gitlab/-/issues/362262
my-job:
extends: base-job
parallel:
matrix:
- OWLS: 1
CATS: 0
- OWLS: 0
@SamStudio8
SamStudio8 / django-unchecked-migration-pre-commit
Created January 21, 2022 12:14
Django unchecked migration pre-commit
#!/usr/bin/env python3
import sys
import subprocess
p = subprocess.Popen("git ls-files --others --exclude-standard", shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
migrations = []
for unchecked_rp in out.decode('UTF-8').split('\n'):
if "migrations" in unchecked_rp:
@SamStudio8
SamStudio8 / shredder.py
Last active September 2, 2021 12:41
A very bad read generator
import argparse
import sys
import random
import numpy as np
import pysam
parser = argparse.ArgumentParser(description="A very very very bad read generator.")
parser.add_argument("shred", type=int)
parser.add_argument("fasta")
@SamStudio8
SamStudio8 / collect.nf
Created July 28, 2021 17:00
collect_nf
#!/usr/bin/env nextflow
params.testdir = "/cephfs/covid/software/sam/nf-test/"
params.fofn_single = [params.testdir, 'samples.csv'].join('/')
single_manifest_ch = Channel
.fromPath(params.fofn_single) // open say, a CSV
.splitCsv(header:true) // split text stream into CSV records
.map { row-> file(row.path) } // coerce the record and return a file for each line
.collect() // emit all items as one
@SamStudio8
SamStudio8 / http-get-dos.conf
Created June 7, 2016 01:43
Simple fail2ban DOS jail
# Fail2Ban configuration file
#
# NOTE
# You should set up in the jail.conf file, the maxretry and findtime carefully in order to avoid false positives.
#
# Author: http://www.go2linux.org
# Modified by: samnicholls.net
# * Mon 6 Jun 2016 - Updated failregex to capture HOST group correctly
[Definition]
@SamStudio8
SamStudio8 / go.sh
Created June 16, 2020 15:37
building the kraken2-microbial database
# kraken2-microbial database
## Monday 3rd September 2018
## s.nicholls.1
KDB=$1
kraken2-build --download-taxonomy --threads 24 --db $KDB
kraken2-build --download-library archaea --db $KDB
kraken2-build --download-library bacteria --db $KDB
@SamStudio8
SamStudio8 / override_docker_workflow.sh
Created March 30, 2020 12:32
RAMPART + docker + gridion
#!/bin/bash
USER_ID=${LOCAL_USER_ID:-9001}
echo "starting with UID : $USER_ID"
echo "creating RAMPART user"
useradd --shell /bin/bash -u $USER_ID -o -c "" -m rampart
echo "raising RAMPART on $CLIENT $SERVER"