Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
@brantfaircloth
brantfaircloth / gist:1061484
Created July 2, 2011 18:13
Easily get coverage from velvet assemblies
  • assemble data and output an AMOS file (-amos_file yes)

  • download and build http://sourceforge.net/projects/amos/

  • convert the afg file output by velvet to a bnk file

     ~/src/amos-3.0.0/src/Bank/bank-transact -m my.afg -b my.bnk -c
    
  • get short-version, depth-of-coverage output

     ~/src/amos-3.0.0/src/Validation/analyze-read-depth my.bnk -d
    
@brantfaircloth
brantfaircloth / stdout_progress.py
Created May 27, 2011 06:02
pretty easy progress indicator
# this works just fine w/ multiprocess...
# now with more flushing
import sys
import time
sys.stdout.write("This is running")
sys.stdout.flush()
for i in range(5):
sys.stdout.write(".")
@brantfaircloth
brantfaircloth / well-descriptors.py
Created May 13, 2011 00:05
generate well descriptors from a 96-well plate
rows = ['A','B','C','D','E','F','G','H']
columns = ['1','2','3','4','5','6','7','8','9','10','11','12']
[['{0}:{1}'.format(r,c) for c in columns] for r in rows]
@brantfaircloth
brantfaircloth / postgresbak.sh
Created May 6, 2011 07:13
Postgres automated backups
#!/bin/bash
#
# postgresbak - psql backup for xxx.yyy.zzz.qqq
#
# Created by Brant Faircloth on 2009-04-06.
# Copyright (c) 2009 Brant Faircloth. All rights reserved.
#
# Run by cron w/
# 0 0 * * * /path/to/script/postgresbak.sh
#
@brantfaircloth
brantfaircloth / gist:958546
Created May 6, 2011 07:10
Mysql automated backups
#!/bin/bash
#
# mysqlbak - mysql backup for xxx.yyy.zzz.qqq
#
# Created by Brant Faircloth on 2009-04-06.
# Copyright (c) 2009 Brant Faircloth. All rights reserved.
#
# Run by cron w/
# 0 0 * * * /path/to/script/mysqlbak.sh
#
@brantfaircloth
brantfaircloth / duplicity_backup_to_s3.sh
Created May 6, 2011 07:07
Duplicity backups to S3
#!/bin/bash
#
# duplicity_backup_to_s3.sh
#
# Created by Brant Faircloth on 2011-05-05.
# Copyright (c) 2011 Brant Faircloth. All rights reserved.
#
# Run by cron w/
# 0 2 * * * /path/to/duplicity_backup_to_s3.sh 2>&1 >> /var/log/duplicity/etc.log
#
@brantfaircloth
brantfaircloth / gist:950010
Created April 30, 2011 21:30
mpi and mrbayes on ec2
  • start an image:

      ec2-run-instances --key keypair ami-74f0061d \
          --instance-type=c1.xlarge \
          --block-device-mapping '/dev/sda2=ephemeral0' \
          --block-device-mapping '/dev/sda3=ephemeral1'
    
  • log in

ssh -i ec2-keypair [email protected]

@brantfaircloth
brantfaircloth / gist:944741
Created April 27, 2011 17:28
blat blast8 tabular format
text = Query id, Subject id, % identity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
csv = "Query id","Subject id","% identity","alignment length","mismatches","gap openings","q. start","q. end","s. start","s. end","e-value","bit score"
@brantfaircloth
brantfaircloth / gist:933843
Created April 21, 2011 06:22
Textmate save also commits to git
#!/usr/bin/env ruby
# Note: original hint from Florian Pilz @ http://stackoverflow.com/questions/4307192/is-it-possible-to-hook-a-git-commit-to-the-save-on-textmate. Slightly updated with git path (homebrew) and change to git_answer.
filename = ENV["TM_FILEPATH"].split("/").last
require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
message = TextMate::UI.request_string(:title => "Committing changes of #{filename}", :prompt => "Please enter the commit message for your changes.")
`/usr/local/bin/git add #{ENV["TM_FILEPATH"]} 2>&1`
commit = `/usr/local/bin/git commit -m "#{message}" 2>&1`
@brantfaircloth
brantfaircloth / get_protein.py
Created April 3, 2011 23:50
Get protein sequences from Genbank given a genomic accession number and a gene name
import sys
import time
from Bio import Entrez
Entrez.email = "[email protected]"
if not Entrez.email:
print "you must add your email address"
sys.exit(2)
# create an empty list we will fill with the gene names