Skip to content

Instantly share code, notes, and snippets.

View michaelbarton's full-sized avatar

Michael Barton michaelbarton

View GitHub Profile
require 'open-uri'
require 'rubygems'
require 'hpricot'
ARGV.each do |gi|
# Fetch the URL and pass the contents to Hpricot
url = "http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=protein&id=#{gi}&rettype=fasta&retmode=xml"
doc = Hpricot.XML(open(url).read)
library(reshape)
library(lattice)
#
# Categorical example
#
data1 <- read.csv(file="plots/categorical.csv")
# Reshape the data into long format
# Prompt with just directory basename
PS1="\W $ "
# Colourise ls output an sort by size
alias ls='ls -l -G -t'
desc 'Loads all the alignment codon data'
task :load_alignment_codons => :clear_alignment_codons do
starfish = %x|which starfish|.strip
loader = PROJECT_ROOT + '/model/starfish/load_alignment_codons.rb'
p = lambda{ system( "qsub -cwd -j y -V #{starfish} #{loader}") }
p.call
sleep(120)
16.times { p.call }
end
Task: Blast
Run BLAST
Using the protein sequence for YDL177C
On uniprot
Return all hits with e < 0.00001
BLAST protein YDL177C
BLAST dna YDL177C
# Given the location of an SQL query file, this method will
# execute the query on the database, and print each line to
# the supplied target file.
# This method relies on the MySQL adapter for the fetch_fields
# method, but should not suffer in performance from pulling
# large amounts of data into memory.
public
def export_csv_from_sql(sql_file,target_file)
# Example activerecord interator based on using an indexed 'id' column.
# See http://schuerig.de/michael/blog/index.php/2007/02/03/ar-enumerable/
# and http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord
class << ActiveRecord::Base
def each(chunk_size=1000)
(0..self.last.id / chunk_size).each do |offset|
self.find(:all,
:limit => chunk_size,
:conditions => ["id > ?", offset * chunk_size]).each do |i|
require 'fileutils'
require 'find'
class Latex < Thor
desc "build","builds thesis document"
method_options :src => 'src',
:dest => 'out',
:tmp => 'tmp'
def build(file)
- Example where
- cost of alanine is being considered
- in glucose limitation
- at biomass flux of 0.5
- Set all exchange fluxes to have a lower bound of -10000.
- Effectively unlimited nutrients with respect to biomass flux
- Set biomass flux reaction rate to have upper and lower bounds of 0.05