Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
#!/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 / 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
@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 / 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 / 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 / index_counter.py
Created October 14, 2014 14:37
Easy Illumina Index Counter
#!/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 / extract_most_variable_snp.py
Created February 13, 2015 22:49
Extract most variable SNP from a "stack" of sequence (from stacks)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
(c) 2015 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 / bcl2fastq-on-zcluster.md
Last active August 29, 2015 14:16
bcl2fastq demxuing on zcluster
  • create shell script to run configuration of job. Save the following as configure.sh:

    #!/bin/bash
    export LD_LIBRARY_PATH=/usr/local/boost/1.44.0/gcc447/lib:${LD_LIBRARY_PATH}
    
    cd /escratch4/tcg_tech2/tcg_tech2_Mar_03/test-ACN5P
    
    # create a basecalls directory to hold our output
    

/usr/local/bcl2fastq/1.8.4/bin/configureBclToFastq.pl \

@brantfaircloth
brantfaircloth / other_times_it_is_exabayes_reinsert.sh
Last active August 29, 2015 14:16
Reinsert missing line in ExaBayes parameter files started from checkpoint
#!/usr/bin/env zsh
# assumes we're using coreutils on osx. if GNU/linux, then
# replace gwc with wc and gsed with sed
for i in ExaBayes_parameters.*.{0-3}$;
do
echo "working on ${i}"
lineno=`gwc -l < $i`;line=`tail -n -1 $i`;gsed -e "${lineno}i ${line}" $i:r.continued1."${i##*.}" > $i:r.continued1.mod."${i##*.}";
done
@brantfaircloth
brantfaircloth / .zshrc
Last active August 29, 2015 14:22
Decent antigen/zshrc setup
source /usr/local/antigen/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle command-not-found
# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting