Skip to content

Instantly share code, notes, and snippets.

@delagoya
Created January 23, 2010 02:07
Show Gist options
  • Save delagoya/284378 to your computer and use it in GitHub Desktop.
Save delagoya/284378 to your computer and use it in GitHub Desktop.
class Blat < CloudCrowd::Action
# Run BLAT on the input against a database with some options.
def process
#download the query DB to local disk
query_db = download(options[:db],File.basename(options[:db]))
#run blat search
`blat #{query_db} #{input_path} #{file_name}.result #{option[:args]}`
# gzip the file
`gzip #{file_name}.result`
#save the file to S3 and return the S3 URL as the result a
save("#{file_name}.result.gz")
end
end
#!/bin/bash
SRC="
deb http://us.archive.ubuntu.com/ubuntu karmic main multiverse restricted universe
deb-src http://us.archive.ubuntu.com/ubuntu karmic main multiverse restricted universe
"
echo $SRC > /etc/apt/sources.list.d/karmic.list
apt-get update
apt-get -y safe-upgrade
apt-get -y install unzip build-essential git-core ia32-libs
apt-get -y -t universe install ruby rubygems ruby-dev libopenssl-ruby libsqlite3-ruby
gem install cloud-crowd thin --no-ri --no-rdoc
# add gems bin to path
echo "export PATH=$PATH:/var/lib/gems/1.8/bin" > /etc/profile.d/rubygems.sh
export PATH=$PATH:/var/lib/gems/1.8/bin
# set up blat
cd /mnt
wget 'http://genome-test.cse.ucsc.edu/~kent/exe/linux/blatSuite.zip';
unzip -d /usr/local/bin blatSuite.zip;
#ccblat
cd /mnt
wget -O ccblat.zip 'http://my.private.bucket.s3.amazonaws.com/ccblat.zip?AWSAccessKeyId=XXXXXXXXXXXXXXXX&Expires=123456789&Signature=XXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXX'
unzip -o ccblat.zip
cd ccblat
crowd node >& ccblat.log &
require "rubygems"
require "bio"
f = Bio::FlatFile.open_file(ARGV[0])
fnum = 0
while !f.eof?
fnum += 1
o = File.open("#{ARGV[1]}/seq.#{fnum}.fa","w")
100000.times do |i|
o.write(f.next_entry.to_s)
end
end
require 'rubygems'
require "rest_client"
require "json"
RestClient.post('http://my.server.com/jobs',
{:job => {'action' => 'blat',
'inputs' => ["http://my.bucket.s3.amazonaws.com/reads.fa"],
'options' => {
'db' => "http://my.bucket.s3.amazonaws.com/querydb.2bit",
'args'=> '-minScore=0 -minIdentity=0 -stepSize=5 -repMatch=2253'
},
}.to_json})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment