Skip to content

Instantly share code, notes, and snippets.

View brantfaircloth's full-sized avatar

Brant Faircloth brantfaircloth

View GitHub Profile
@brantfaircloth
brantfaircloth / gist:6830880
Created October 4, 2013 18:55
Illumina adapters
[adapters]
i7:AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC*ATCTCGTATGCCGTCTTCTGCTTG
i5:AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGTAGATCTCGGTGGTCGCCGTATCATT
@brantfaircloth
brantfaircloth / gist:6830352
Created October 4, 2013 18:24
oh my zsh prompt
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
}
PROMPT='
%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}$(box_name)%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info)$(virtualenv_info)%(?,,%{${fg_bold[blue]}%}%{$reset_color%} )
@brantfaircloth
brantfaircloth / 1-regions.txt
Created August 24, 2013 22:15
Get your protein (examples)
gi|91983971|ref|NC_007957.1| Vitis vinifera chloroplast, complete genome
gi|52220789|ref|NC_006290.1| Panax ginseng chloroplast, complete genome
gi|300388125|ref|NC_013991.2| Phoenix dactylifera chloroplast, complete genome
gi|94502469|ref|NC_007977.1| Helianthus annuus chloroplast, complete genome
gi|139390328|ref|NC_009265.1| Aethionema cordifolium chloroplast, complete genome
gi|189162250|ref|NC_010776.1| Fagopyrum esculentum subsp. ancestrale chloroplast, complete genome
gi|68164782|ref|NC_007144.1| Cucumis sativus chloroplast, complete genome
gi|149390334|ref|NC_009601.1| Dioscorea elephantipes chloroplast, complete genome
gi|17570783|ref|NC_003119.6| Medicago truncatula chloroplast, complete genome
gi|116617087|ref|NC_008535.1| Coffea arabica chloroplast, complete genome
@brantfaircloth
brantfaircloth / remove-git-file.sh
Created August 24, 2013 21:14
Remove file permanently from git
# blackhole the content
git filter-branch --tree-filter 'rm -rf my/folder' HEAD
# force the update
git push origin master --force
@brantfaircloth
brantfaircloth / virtual_digests.py
Created August 24, 2013 21:12
Virtual restriction digests and BioPython
from Bio import SeqIO
seq = SeqIO.read(open('chr1.fas','rU'),'fasta')
len(seq)
30427671
from Bio import Restriction
Restriction.HindIII.search(seq.seq)
sites = Restriction.HindIII.search(seq.seq)
@brantfaircloth
brantfaircloth / restriction_batches.py
Created August 24, 2013 21:10
Restriction batches and BioPython
# subset record #
test=seq[0:10000]
# take a look at the common restriction enzymes
Restriction.CommOnly
# do a restriction batch analysis on our test sequence with ALL common
# enzymes
Ana = Restriction.Analysis(Restriction.CommOnly, test.seq, linear=True)
@brantfaircloth
brantfaircloth / bulk_sequence_rename.py
Created August 24, 2013 21:08
Bulk sequence renaming with BioPython
from Bio import SeqIO
# create a dict to hold our new GI:names mapping, which looks like so, in
# this case (from sheep)
#
# gi|289623201|gb|CM000885.1| 299839927 chr1
# gi|289623190|gb|CM000894.1| 94216033 chr10
# gi|289623189|gb|CM000895.1| 67137890 chr11
# gi|289623188|gb|CM000896.1| 86457535 chr12
data = {}
@brantfaircloth
brantfaircloth / convert-date-and-time.sql
Last active December 21, 2015 15:59
converting mysql date and time strings to date and time values
mysql> select usdi, capture_date, time,
-> str_to_date(concat(capture_date, ' ', time), '%m/%d/%y %k%i')
-> as str_to_datetime
-> from all_bands_temp order by RAND() limit 10;
+-----------+--------------+------+---------------------+
| usdi | capture_date | time | str_to_datetime |
+-----------+--------------+------+---------------------+
| 139106995 | 6/12/91 | 0707 | 1991-06-12 07:07:00 |
| 149143944 | 6/2/95 | 1212 | 1995-06-02 12:12:00 |
| 139107786 | 5/12/90 | 1730 | 1990-05-12 17:30:00 |
@brantfaircloth
brantfaircloth / restart-vmware-fusion.sh
Created August 24, 2013 20:34
Restart VMWare fusion from the cli
/Library/Application\ Support/VMware\ Fusion/vmrun stop \
"/Volumes/Data2/VM/Fedora 64-bit.vmwarevm/Fedora 64-bit.vmx" soft
@brantfaircloth
brantfaircloth / list-comprehension.py
Last active December 21, 2015 15:59
casting a numpy array of strings to int (examples)
import numpy
s = '40 40 40 40 40'
sl = s.rstrip().split(' ')
si = [int(elem) for elem in sl]
sa = numpy.array(si)