Skip to content

Instantly share code, notes, and snippets.

View timrandg's full-sized avatar

Tim Rand timrandg

View GitHub Profile
1. export GOPATH='~/Desktop/go/project' #set the GOPATH to the pwd
2. mkdir -p $GOPATH/{bin,pkg,src} #create the required subdirectory sturcture: {bin,pkg,src}
3. tree $GOPATH
/Users/Tim/Desktop/go/project
├── bin
├── pkg
└── src
4. mkdir $GOPATH/src/my_new_package #create a package folder with the same name as the package itself
5. touch $GOPATH/src/my_new_package/my_new_package.go
@timrandg
timrandg / go.sublime-build
Created July 9, 2013 06:05
build and run GO from sublime text 2
{
"cmd": ["go run '${file}'"],
"selector": "source.go",
"path": "/usr/local/go/bin",
"shell": true
}
@timrandg
timrandg / ruby wrap agrep
Created May 23, 2013 12:07
ruby wrap agrep
ruby -e '["a","b","c"].each {|q| puts `echo this is a test in A b sentenCe. | agrep -i --show-position --color "#{q}" `}'
@timrandg
timrandg / Ruby pattern matching wild cards
Created March 22, 2013 11:27
Implementation wildcard operator for pattern-matching-like case statements in RUBY
#Here is a quick implementation of pattern matching for cases in ruby
module WildcardFunctionality
class Wildcard
def ==(other)
true
end
end
def _
Wildcard.new
@timrandg
timrandg / paste function
Created March 6, 2013 09:57
reminder to self about the useful paste funciton for looking at histogram peptide files side by side
% paste mapped_PRRC2A.txt mapped_PRRC2B.txt mapped_PRRC2C.txt | column -s $'\t' -t > all_mapped_order_CBA.txt% head !$head all_mapped_order_CBA.txt
1 M 0 1 M 0 1 M 0
2 S 0 2 S 0 2 S 0
3 D 0 3 D 0 3 E 0
4 R 0 4 R 0 4 K 0
5 S 0 5 L 1 | 5 S 0
6 G 0 6 G 1 | 6 G 0
7 P 0 7 Q 1 | 7 Q 0
8 T 0 8 I 1 | 8 S 0
9 A 0 9 T 1 | 9 T 0
@timrandg
timrandg / peptide_mapper4.rb
Created March 5, 2013 05:16
peptide_mapper5.rb
#command-line usage:
#% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file
# 1 M 0
# 2 S 0
# 3 P 8 [][][][][][][][]
# 4 A 8 [][][][][][][][]
# 5 G 8 [][][][][][][][]
# 6 S 8 [][][][][][][][]
# 7 C 8 [][][][][][][][]
# 8 D 8 [][][][][][][][]
@timrandg
timrandg / peptide_mapper4.rb
Created March 2, 2013 16:07
More refactoring
#command-line usage:
#% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file
# 1 M 0
# 2 S 0
# 3 P 8 [][][][][][][][]
# 4 A 8 [][][][][][][][]
# 5 G 8 [][][][][][][][]
# 6 S 8 [][][][][][][][]
# 7 C 8 [][][][][][][][]
# 8 D 8 [][][][][][][][]
@timrandg
timrandg / peptide_mapper4.rb
Created March 1, 2013 16:35
Refactoring peptide aligner
#command-line usage:
#% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file
# 1 M 0
# 2 S 0
# 3 P 8 [][][][][][][][]
# 4 A 8 [][][][][][][][]
# 5 G 8 [][][][][][][][]
# 6 S 8 [][][][][][][][]
# 7 C 8 [][][][][][][][]
# 8 D 8 [][][][][][][][]
@timrandg
timrandg / gist:5054689
Created February 28, 2013 06:29
peptide mapper
#command-line usage:
#% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file
# 1 M 0
# 2 S 0
# 3 P 8 [][][][][][][][]
# 4 A 8 [][][][][][][][]
# 5 G 8 [][][][][][][][]
# 6 S 8 [][][][][][][][]
# 7 C 8 [][][][][][][][]
# 8 D 8 [][][][][][][][]
@timrandg
timrandg / Unix batch download
Created February 15, 2013 06:42
Batch download genbank files from IRES website
1. Created a script for stripping out the urls for genbank files.
#IRES_PLASMID_SCRAPER.rb
pwd = "/Users/timrand/Dropbox/NAT1/"
file = pwd + "IRES_plasmids.txt"
website_url = "http://iresite.org/IRESite_web.php?page=gb_download&file="
out_file = pwd + "ires_plasmid_urls.txt"
f = File.read(file)