Skip to content

Instantly share code, notes, and snippets.

View tomkinsc's full-sized avatar

Chris Tomkins-Tinch tomkinsc

View GitHub Profile
@tomkinsc
tomkinsc / graphical_mpileup_qual.py
Last active August 22, 2022 20:11
This replaces basecall quality scores with graphical equivalents. Based on pyemojify and fastqe, but self-contained without dependencies external to the standard library.
#!/usr/bin/env python
import re, sys, os
from stat import S_ISFIFO
import argparse
# quick and dirty script to show emoji or bars for samtools mpileup quality scrores
# extra verbose so this does not require any external libraries
# based on fastqe and emojify:
# https://raw.githubusercontent.com/fastqe/fastqe/master/fastqe/fastqe_map.py
@tomkinsc
tomkinsc / gist:f5d52274226139887380480543063f6a
Created July 23, 2022 08:07 — forked from hongar/gist:2a7c416c6d049fb5891a5577a424e56d
uBlock Origin: Block "Sign in to (website) with Google" popup
||id.google.com^
||accounts.google.com/gsi/$3p
@tomkinsc
tomkinsc / flowcell-id_to_seqmodel.py
Created July 13, 2022 21:54
quick regex-based script for returning the model of Illumina sequencer for a given flowcell ID
#!/usr/bin/env python
import sys, re
flowcell_to_machine_model_and_chemistry = {
r'[A-Z,0-9]{5}AAXX':{
"machine": "Illumina Genome Analyzer IIx",
"chemistry": "All",
"lane_count": 8,
"note": ""
#!/usr/bin/env python
import sys, os
import argparse
from Bio import SeqIO
from Bio.Seq import MutableSeq, Seq
from Bio.SeqIO import FastaIO
from itertools import cycle, chain
@tomkinsc
tomkinsc / outlet_state.sh
Last active August 1, 2024 13:21
This gets the state of Meross outlets, model MSS110. It may only work if the outlets have been added via HomeKit but not accessed via the Meross cloud.
#!/bin/bash
# This gets the state of Meross outlets, model MSS110. It may only work if the outlets have been added via HomeKit but not accessed via the Meross cloud.
# requires jq
# see Meross API:
# https://github.com/dieantu/ha-config/blob/96cd122bcb6e0559e147c57d04448828cbc190d5/custom_components/meross_lan/merossclient/api.http
PLUG_IP=$1
PLUG_STATE=$2
currenttime="$(date '+%s')"
@tomkinsc
tomkinsc / count_words_after_heading_google_docs_script.js
Last active March 19, 2022 04:13
Add as a script to a particular Google Doc. Note that this may count differently than the native Docs word count, which counts differently still from what MS Word does...
//var delimitRegex = /\W+/;
//var delimitRegex = /[^\w\n]+/;
var delimitRegex = /[^\w\-\–\—\(\)\.:,;]+/;
function countPerSection() {
var body = DocumentApp.getActiveDocument().getBody();
var para = body.getParagraphs();
var levels = para.map(function(p) {
return [DocumentApp.ParagraphHeading.TITLE,
DocumentApp.ParagraphHeading.SUBTITLE,
@tomkinsc
tomkinsc / export_excel_from_graphpad.py
Created March 4, 2022 19:13
quick and dirty script to export graphpad prism data tables to excel format
#!/usr/bin/env python
import os
import glob
import pandas as pd
import pzfx_parser as gpp # pip install pzfx_parser; conda install openpyxl
gp_ext = ".pzfx"
for f in glob.glob(f"./*{gp_ext}"):
@tomkinsc
tomkinsc / make_tree.sh
Last active February 3, 2022 22:06
Make a quick ML tree for SARS-CoV-2. Requires the SARS-CoV-2 reference genome in a fasta, and iqtree and mafft on the PATH
#!/bin/bash
set -e -o pipefail
DEPENDENCIES=(iqtree mafft trimal curl python)
if ! $(hash $DEPENDENCIES &> /dev/null); then
echo "ERROR! aborting..."
echo "The following need to be installed and on the PATH:"
for dependency in ${DEPENDENCIES[@]}; do
#!/bin/bash
curl http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucest&rettype=fasta&id=NC_045512.2 > NC_045512.2.fasta
@tomkinsc
tomkinsc / matplotlib_colorcycler_colorblind_friendly.py
Last active January 5, 2022 16:22
matplotlib colorblindness-friendly color cycler using Okabe & Ito's palette (later mentioned by Bang Wong):
# matplotlib color cycler using Okabe & Ito's palette
# https://jfly.uni-koeln.de/color/
# later mentioned by Bang Wong:
# https://www.nature.com/articles/nmeth.1618
# re-order colors as desired for the application
c = cycler(color=[
(0,0,0), # black
(230/255, 159/255, 0/255), # orange
(86/255, 180/255, 233/255), # sky blue
(0/255, 158/255, 115/255), # blueish green