Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
@brantfaircloth
brantfaircloth / fibo.py
Created January 18, 2016 20:17
fibo function
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
@brantfaircloth
brantfaircloth / rint.py
Created July 7, 2015 15:11
get random numbers from CLI
#!/usr/bin/env python
import sys
from numpy import random
print random.random_integers(1,1000000000,int(sys.argv[1]))
@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
@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 / 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 / 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 / stacks-config.md
Last active August 4, 2017 18:30
Install and configure stacks 1.21 on Ubuntu 14.04 LTS

Stacks on Ubuntu 14.04 LTS

  • install dependencies:

      apt-get install build-essential zlib1g-dev vim
      apt-get install libsparsehash-dev mysql-server php5 apache2 php-mdb2 php-mdb2-driver-mysql libdbd-mysql-perl samtools libbam-dev
    
  • for ease of compilation, symlink sparsehash to /usr/local/include:

sudo ln -s /usr/include/google /usr/local/include/sparsehash

@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 / fastq_split.py
Last active March 11, 2020 14:54
split (gzipped) fastq files to temp files quickly in python
#!/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 / 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):