Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
@brantfaircloth
brantfaircloth / check_sum.py
Created February 23, 2012 18:44
Check a list of files against a list of openssl checksums (sha1 and md5)
"""
File: check_sum.py
Author: Brant Faircloth
Created by Brant Faircloth on 23 February 2012 10:02 PST (-0800)
Copyright (c) 2012 Brant C. Faircloth. All rights reserved.
Description: Check a list of files against hashes.
License: http://www.opensource.org/licenses/BSD-3-Clause
@brantfaircloth
brantfaircloth / compute-machines.rst
Created February 14, 2012 00:14
cheap compute options

Cheaper, smaller

Add in SSD or two for fast IO ops. 4 internal HDD slots.

Part p/n cost units total cost comment
CPU BX80614E5645 $557.00 2 $1,114.00 12 cores @ 2.4 GHZ
@brantfaircloth
brantfaircloth / cool_argparse_stuff.py
Created December 7, 2011 16:47
Some cool argparse stuff
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def is_dir(dirname):
"""Checks if a path is an actual directory"""
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
@brantfaircloth
brantfaircloth / refgene_to_bed.py
Created December 7, 2011 06:47
Convert UCSC refgene to BED
"""
File: refgene_to_bed.py
Author: Brant Faircloth
Created by Brant Faircloth on 06 December 2011 22:12 PST (-0800)
Copyright (c) 2011 Brant C. Faircloth. All rights reserved.
Description: convert UCSC refgene.txt files to BED format
"""
@brantfaircloth
brantfaircloth / gist:1282390
Created October 12, 2011 20:12
Enable Lion TRIM support on 3rd part SSDs
cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage ~/Desktop/IOAHCIBlockStorage.original
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
@brantfaircloth
brantfaircloth / gist:1270954
Created October 7, 2011 18:03
Wrapping option list in docutils/sphinx
class Writer(writers.Writer):
setting_spec = (
('Specify the maximum width (in characters) for options in option '
'lists. Longer options will span an entire row of the table used '
'to render the option list. Default is 14 characters. '
'Use 0 for "no limit".',
['--option-limit'],
{'default': 4, 'metavar': '<level>',
'validator': frontend.validate_nonnegative_int})
)
@brantfaircloth
brantfaircloth / mult_prod_single_consume.py
Created October 1, 2011 07:06
Python multiprocessing: multiple producers, single consumer
import time
import random
from multiprocessing import Process, Queue, JoinableQueue, cpu_count
""" Adjust time.sleep() values to see action of consumer """
def work(id, jobs, result):
while True:
task = jobs.get()
if task is None:
@brantfaircloth
brantfaircloth / paths_to_full_paths.py
Created September 30, 2011 00:27
Convert paths to full paths (argparse)
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def get_args():
parser = argparse.ArgumentParser(description='Something smart here')
parser.add_argument('my_conf', help='The configuration file for the db', action = FullPaths)
return parser.parse_args()
@brantfaircloth
brantfaircloth / hyphy_headless.md
Created August 30, 2011 18:08
Building hyphy (headless) on darwin
  • get hyphy source (http://www.datam0nk3y.org/)

  • get sqlite source (http://www.sqlite.org/download.html) - you want the "amalgamation"

  • unzip hyphy source somewhere

  • unzip sqlite source somewhere

  • remove the shell.c file from the sqlite source

  • edit buildFromSVN.sh to point to your svn files:

      cp /path/to/sqlite-amalgamation-*/*.{c,h} $installDirectory/Source/SQLite/
    
  • run bash buildFromSVN.sh

@brantfaircloth
brantfaircloth / singleton.sh
Created August 3, 2011 18:44
Getting singleton reads from a 454 assembly:
# get singleton reads names from assembly stats:
grep Singleton 454ReadStatus.txt > singles.txt
# if you assembled using fasta+qual files, use faSomeRecords from kent source:
faSomeRecords ../reads/schisto.454reads.combined.fsa singles.txt singles.fa
# if you assembled using SFF files: