Skip to content

Instantly share code, notes, and snippets.

View michaelbarton's full-sized avatar

Michael Barton michaelbarton

View GitHub Profile
# Reasons to use rails approach for bioinformatics
## Generic Ruby
* Modules like enumerable are great for sorting data
## Activerecord
* Simple to add indexes to enforce uniqueness of data
task :environment do
require 'database'
require 'logger'
@log = Logger.new('log/analysis.log')
end
namespace :db do
desc 'Create database'
task :create => :environment do
require 'database'
gene = Gene.find(2)
gene.alignment_sequences.each do |a|
puts "#{a.species.letter}#{gene.name} #{a.protein}"
end
Can I over-ride task :environment in test_helper.rb to test rake tasks?
I have a series of rake tasks in a Rakefile which I'd like to test as part of my specs etc. Each task is defined in the form:
task :do_somthing => :environment do
# Do something with the database here
end
Where the :environment task sets up an ActiveRecord/DataMapper database connection and classes. I'm not using this as part of Rails but I have a series of tests which I like to run as part of BDD.
BEGIN { FS = OFS = ","
print "gene", "cost", "cost-type"}
/yeast-carbon|weight/ && /0\.1/ && /nitrogen/{
gsub(/"/,"")
gsub(/yeast-carbon-/,"")
printf "%s,%3.4f,%s\n", $2, $3, $13
}
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in webrat_steps.rb
#
def path_to(page_name)
"http://0.0.0.0:3000" + case page_name
require 'www/mechanize'
# Patches WWW::Mechanize for Cucumber + Webrat
module WWW
class Mechanize
def self.log_disabled
@@log ||= Logger.new(STDOUT)
end
#! /usr/local/bin/ruby
require 'rubygems'
require 'fastercsv'
layout = Hash.new
FasterCSV.open(ARGV.first, :headers => true).each do |row|
row.headers.each do |header|
layout[header] ||= Hash.new
\documentclass[12pt,PhD]{muthesis}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{url} % typeset URL's reasonably
\usepackage{listings}
\usepackage{phdthesis}
\usepackage{rotating}
\usepackage{subfig}
\usepackage{psfrag}