Skip to content

Instantly share code, notes, and snippets.

@michaelbarton
Created January 24, 2010 16:41
Show Gist options
  • Save michaelbarton/285296 to your computer and use it in GitHub Desktop.
Save michaelbarton/285296 to your computer and use it in GitHub Desktop.
require 'open-uri'
FILE = 'SBW25.fna'
URL = "ftp://ftp.ncbi.nih.gov/genbank/genomes/Bacteria/Pseudomonas_fluorescens_SBW25/AM181176.fna"
READS = [200_000]
N_SIMULATIONS = 5
METASIM = 'metasim'
desc "Fetches SBW25 genome sequence"
task :fetch do
unless File.exists?(FILE)
File.open(FILE,'w') do |f|
open(URL) do |url|
url.each_line { |line| f.write(line) }
end
end
end
end
desc "Simulates genome sequencing"
task :sequence => :fetch do
READS.each do |reads|
dir = mkdir(reads)
0.upto(N_SIMULATIONS - 1) do
`#{METASIM} cmd --reads #{reads} --454 --output-dir #{dir} #{FILE}`
end
end
end
private
def mkdir(reads)
dir = "#{reads/1_000}k"
Dir.mkdir(dir) unless File.exists?(dir)
dir
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment