Skip to content

Instantly share code, notes, and snippets.

View MikeDacre's full-sized avatar

Mike Dacre MikeDacre

View GitHub Profile
@MikeDacre
MikeDacre / change_indent_length.py
Created December 11, 2012 19:01
Change number of spaces used for indentation in a file, only change spaces at start of file. Made for python, will work with any file.
#!/bin/env python3
#===============================================================================
#
# FILE: change_indent_length.py
#
# USAGE: cange_indent_length.py [-h] file_name old_tab_length new_tab_length
#
# DESCRIPTION: Change indent length, only change those at start of line
#
# AUTHOR: Michael D Dacre, mike.dacre@gmail.com
@MikeDacre
MikeDacre / flashcache
Created February 20, 2013 20:55
systemd script for flashcache - non-root disk Install to /usr/lib/systemd/system/flashcache.service. Activate with `systemctl enable flashcache` You need to update the shell script to reflect your own caches.
#!/bin/bash
HOMEMOUNT=$(mount | grep home | sed 's/ .*//' | sed 's#.*/##' )
if [[ ! "$(eval lsmod | grep "^flashcache")" ]]; then
modprobe flashcache
fi
if [[ ! "$HOMEMOUNT" == "flashcache" ]]; then
umount /home
@MikeDacre
MikeDacre / selective-backup.py
Last active December 14, 2015 07:48
A simple backup program to create a selective backup by duplicating a directory tree with hard links. This allows users to choose only the files they wish backed up. It requires a third party backup solution (e.g. rsync or CrashPlan), to do the actual backup. The script allows users to choose the backup location, and also uses `find` to search t…
#!/bin/env python3
dsript="""\
#===============================================================================
#
# FILE: selective-backup.py
#
# USAGE: ./selective-backup.py [-o] [-l] [-r] file1 [file2]...[folder1...
#
# DESCRIPTION: Duplicate a directory to a given location using only hard links
# REQUIREMENTS: python3
@MikeDacre
MikeDacre / std-arg.py
Last active December 21, 2015 17:59
Cumbersome python3 functions to give user the choice between either using STDIN, STDOUT, STDERR, or using -i, -o, and -l. The idea is that we want to use the protection of a `with"` statement if using the '-i' and '-o' flags for input and output files, while still allowing the use of STDIN and STDERR. It makes use of sys and argparse. It is cumb…
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4
"""
#====================================================================================
#
# FILE: std-arg.py
# AUTHOR: Michael D Dacre, mike.dacre@gmail.com
# LICENSE: Open Source
# CREATED: 2013-08-26 10:56
@MikeDacre
MikeDacre / vcf_simplify.py
Last active January 4, 2016 04:28
Simplify a 1000genomes vcf file to a smaller file with all genotypes encoded as 0/1/2, where 0: homozygote 1; 1: heterozygote; 2:homozygote 2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# Copyright © Mike Dacre <mike.dacre@gmail.com>
#
# Distributed under terms of the MIT license
"""
===============================================================================
@MikeDacre
MikeDacre / bed2vcf.py
Last active January 8, 2016 21:29
Convert simplified bed file(s) plus a reference genome into a vcf file. Formats in source.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Distributed under terms of the MIT license
"""
================================================================================
FILE: bed2vcf (python 3)
AUTHOR: Michael D Dacre, mike.dacre@gmail.com
ORGANIZATION: Stanford University
LICENSE: MIT License, Property of Stanford, Use as you wish
@MikeDacre
MikeDacre / cnvnator_mouse.patch
Last active August 29, 2015 14:04
Patch for http://sv.gersteinlab.org/cnvnator/ including the black6 genome
Only in ./: cnvnator
diff -u ../../../CNVnator_v0.3/src/cnvnator.cpp ./cnvnator.cpp
--- ../../../CNVnator_v0.3/src/cnvnator.cpp 2014-02-01 20:29:35.000000000 -0800
+++ ./cnvnator.cpp 2014-07-21 13:06:23.022155584 -0700
@@ -39,7 +39,7 @@
usage += argv[0];
usage += " -pe file1.bam ... -qual val(20) -over val(0.8) [-f file]\n";
usage += "\n";
- usage += "Valid genomes (-genome option) are: NCBI36, hg18, GRCh37, hg19\n";
+ usage += "Valid genomes (-genome option) are: NCBI36, hg18, GRCh37, hg19, black6\n";
@MikeDacre
MikeDacre / get_chromosome_length.py
Last active August 29, 2015 14:04
Take a list of FastA files (or just one file) and count the length of the chromosome
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# Copyright © Mike Dacre <mike.dacre@gmail.com>
#
# Distributed under terms of the MIT license
"""
#====================================================================================
#
@MikeDacre
MikeDacre / logme.py
Created August 22, 2014 23:36
Little logging script to make writing timed messages easier
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4
"""
#====================================================================================
#
# FILE: logme (python 3)
# AUTHOR: Michael D Dacre, mike.dacre@gmail.com
# ORGANIZATION: Stanford University
# LICENSE: Open Source - Public - Do as you wish (no license) - Mike Dacre
@MikeDacre
MikeDacre / syslog.log
Last active August 29, 2015 14:07
Kernel error log from 2014-10-13, fraser-server, USB3 related bugs
This file has been truncated, but you can view the full file.
Oct 13 09:25:50 fraser-server kernel: [774197.362929] usb 2-3: USB disconnect, device number 2
Oct 13 09:25:50 fraser-server kernel: [774197.362931] usb 2-3.1: USB disconnect, device number 3
Oct 13 09:25:50 fraser-server kernel: [774197.362933] usb 2-3.1.1: USB disconnect, device number 7
Oct 13 09:25:50 fraser-server kernel: [774197.364620] sd 12:0:0:0: [sdj] Synchronizing SCSI cache
Oct 13 09:25:50 fraser-server kernel: [774197.373022] usb 1-3.1-port2: cannot reset (err = -71)
Oct 13 09:25:50 fraser-server kernel: [774197.373519] usb 1-3.1-port2: cannot reset (err = -71)
Oct 13 09:25:50 fraser-server kernel: [774197.374019] usb 1-3.1-port2: cannot reset (err = -71)
Oct 13 09:25:50 fraser-server kernel: [774197.374518] usb 1-3.1-port2: cannot reset (err = -71)
Oct 13 09:25:50 fraser-server kernel: [774197.375019] usb 1-3.1-port2: cannot reset (err = -71)
Oct 13 09:25:50 fraser-server kernel: [774197.375020] usb 1-3.1-port2: Cannot enable. Maybe the USB cable is bad?