Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
@brantfaircloth
brantfaircloth / shuffler.py
Created September 17, 2014 00:34
shuffle population labels in a csv file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import shuffle
# create a list of all labels - NOTE that i've used 2 here because we have
# 2 individuals in pop A and 2 in pop B
label_list = ["population-A"] * 2 + ["population-B"] * 2
# do something 100 times
for i in xrange(100):
@brantfaircloth
brantfaircloth / bad.py
Created September 12, 2014 15:55
A numpy/multiprocessing surprise
import numpy as np
from multiprocessing import Pool
def test(top):
return np.random.random_integers(0,100,5)
def main():
# set this to a large CPU number
pool = Pool(4)
results = pool.map(test, [1,1,1,1,1,1])
@brantfaircloth
brantfaircloth / check_nexus.py
Created July 23, 2014 02:28
check a nexus file's site patterns
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
(c) 2014 Brant Faircloth || http://faircloth-lab.org/
All rights reserved.
This code is distributed under a 3-clause BSD license. Please see
LICENSE.txt for more information.
@brantfaircloth
brantfaircloth / merge_next_seq.py
Created June 13, 2014 23:31
Merge next-seq gzip files
# this is the SampleId columnd of your SampleSheet.csv
[samples]
sample1-nameA-blah-blah
sample2-nameB-blah-blah
sample3-nameC-blah-blah
@brantfaircloth
brantfaircloth / rnalater.md
Last active April 13, 2021 14:33
Homebrew RNALater

Disclaimer

Before using this for samples that are precious, you should thoroughly test the solution that you make. The best way to do that would be a side-by-side with commercial RNALater.

Source

The following recipe is from the patent. It always pays to read these.

In a beaker, combine 40 ml 0.5 M EDTA, 25 ml 1M Sodium Citrate, 700 gm Ammonium Sulfate
@brantfaircloth
brantfaircloth / exclude.sh
Created April 30, 2014 16:33
copy but exclude files in a list
find . -type f | grep -v -f exclude.txt | xargs cp -t /path/to/new/dir
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
(c) 2014 Brant Faircloth || http://faircloth-lab.org/
All rights reserved.
This code is distributed under a 3-clause BSD license. Please see
LICENSE.txt for more information.
@brantfaircloth
brantfaircloth / travis-with-conda.yml
Created December 30, 2013 02:26
Use conda + travis-ci.org to setup complex dependency chain for running tests.
# borrowed from here: https://gist.github.com/dan-blanchard/7045057
# lint it here: http://lint.travis-ci.org/
language: python
python:
- 2.7
notifications:
email: false
# whitelist
branches:
@brantfaircloth
brantfaircloth / reorder.R
Last active December 28, 2015 17:39
Reorder labels in R (order, labels, R, reorder)
data$method = factor(data$method, levels=c("abyss k=25", "velvet k=25", "trinity k=25"))
@brantfaircloth
brantfaircloth / ghost.sh
Last active May 20, 2020 09:20
CentOS init script for the ghost blogging platform
#!/bin/sh
#
# ghost - this script starts the ghost blogging package
#
# chkconfig: - 95 20
# description: ghost is a blogging platform built using javascript \
# and running on nodejs
#
# Source function library.