Skip to content

Instantly share code, notes, and snippets.

@peterjc
peterjc / V4.samples.onebp.svg
Created Feb 19, 2020
THAPBI PICT sample report Excel screenshot - mock freshwater:marine community with 18S rRNA V4
View V4.samples.onebp.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peterjc
peterjc / mirror_setup.sh
Created Aug 17, 2018
Script to simplify setting up git repository for cron-based mirroring of a GitHub fork
View mirror_setup.sh
#!/bin/bash
set -euo pipefail
# See https://blastedbio.blogspot.co.uk/2016/05/sync-github-mirror-with-cron.html and
# https://gist.github.com/peterjc/eccac1942a9709993040425d33680352 for mirroring script
#
# Usage:
#
# 1. Fork upstream repo under HuttonICS, disable wiki, projects, issues etc. Protect master branch.
# 2. Run:
@peterjc
peterjc / mirror_git
Last active Jul 14, 2019
Script to push git changes to a mirror repository using a deploy key
View mirror_git
#!/bin/bash
# Enable strict bash mode - halts on any error
set -euo pipefail
# Takes exactly three command line arguments:
git_dir=$1
ssh_key=$2
log_file=$3
@peterjc
peterjc / keybase.md
Created Apr 17, 2018
Linking my GitHub profile to my KeyBase identity
View keybase.md

Keybase proof

I hereby claim:

  • I am peterjc on github.
  • I am pjacock (https://keybase.io/pjacock) on keybase.
  • I have a public key ASDyMh8PfhtgajUDmucW2sUhci9kIZ5U2TywiDd5GKUlyAo

To claim this, I am signing this object:

@peterjc
peterjc / make_roomba_lirc.py
Created Nov 11, 2013
Python script to generate
View make_roomba_lirc.py
#!/usr/bin/env python
#Copyright 2013, Peter Cock. All rights reserved.
#Released under the MIT License.
"""Python scipt to generate Roomba IR codes for LIRC.
Tested under Python 2.7 and Python 3.3, example usage:
$ python make_roomba_lirc.py > roomba.conf
See also:
@peterjc
peterjc / update_tool_dependencies.py
Created Aug 18, 2016
Hack for updating Galaxy tool_dependencies.xml files with depot.galaxyproject.org URLs
View update_tool_dependencies.py
# Copyright 2016 Peter Cock, James Hutton Institute.
# All Rights Reserved.
# Released as open source under the MIT license.
"""Update URLs in Galaxy tool_dependencies.xml files
Assumes have a copy of the urls.tsv file from
https://github.com/galaxyproject/cargo-port/blob/master/urls.tsv
This file defines the https://depot.galaxyproject.org/software/
URL naming used for caching Galaxy dependencies.
@peterjc
peterjc / reportlab_ps_test.py
Last active Jan 2, 2016
Standalone test case originally Biopython for resting ReportLab under Python 2 and 3. Currently seeing a segmentation fault under Python 2.7, and a TypeError under Python 3.3 when testing on Mac OS X - see http://two.pairlist.net/pipermail/reportlab-users/2014-January/010972.html
View reportlab_ps_test.py
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.pdfbase.pdfmetrics import stringWidth
from reportlab.graphics.shapes import Drawing, String, Line, Rect, Wedge, ArcPath
from reportlab.graphics import renderPDF, renderPS
from reportlab.graphics.widgetbase import Widget
@peterjc
peterjc / decode_roomba_ir.py
Last active Dec 26, 2015
Python scipt to decode Roomba IR codes via the Linux mode2 tool. See http://astrobeano.blogspot.co.uk/2013/10/roomba-620-infrared-signals.html
View decode_roomba_ir.py
#!/usr/bin/env python
#Copyright 2013, Peter Cock. All rights reserved.
#Released under the MIT License.
"""Python scipt to decode Roomba IR codes via the Linux mode2 tool.
Tested under Python 2.7 and Python 3.3, example usage:
$ mode2 -d /dev/lirc0 | python decode_roomba_ir.py
10101100 - 172 - 0xAC
10101100 - 172 - 0xAC
@peterjc
peterjc / ace_to_contig_stats.py
Created Feb 19, 2013
Quick Python script to extract contig summary information (lengths and number of reads, as a tabular file) from an ACE assembly file, using the Biopython ACE parser for convenience.
View ace_to_contig_stats.py
#!/usr/bin/env python
#Example usage:
#
# $ python ace_to_contig_stats.py < example.ace > example_stats.tsv
#
import sys
from Bio.Sequencing import Ace
sys.stdout.write("#Contig\tPadded length\tUnpadded length\tReads\n")
for contig in Ace.parse(sys.stdin):
@peterjc
peterjc / make_shed_yml.py
Created Oct 13, 2015
Hack for syncing local .shed.yml files with a Galaxy Tool Shed
View make_shed_yml.py
#
# A hack, loosly based on Eric Rasche's disgusting.py
# https://gist.github.com/erasche/4ac3448b036f09979e14
#
# Intended as a one-off use script to help with syncing local
# .shed.yml files with a Galaxy Tool Shed. See also:
# https://gist.github.com/peterjc/5ebbf446d799f3aaa639
import yaml
import os