michaelbarton / cost_in_evolution

This URL has Read+Write access

cost_in_evolution / analysis / 001_sitewise_substitution_rate / analysis.rake
100644 53 lines (43 sloc) 1.305 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'zlib'
 
namespace '001' do
 
  @number = 1
 
  desc 'Clears yeast sequence data'
  task :clear_sequence_data do
    Gene.delete_all
  end
 
  desc 'Load yeast DNA sequence data'
  task :load_sequence_data => :clear_sequence_data do
    file_gz = PROJECT_ROOT + '/data/yeast_protein_genes.fasta.gz'
    Zlib::GzipReader.open(file_gz) do |file|
      Bio::FlatFile.auto(file).each {|entry| Gene.create_from_flatfile entry }
    end
  end
 
  desc 'Clears sequence alignment data'
  task :clear_alignment_data do
    Alignment.delete_all
  end
 
  desc 'Loads the sequence alignment data'
  task :load_alignment_data => ['clear_alignment_data'] do
    file_gz = PROJECT_ROOT + '/data/yeast_alignments.txt.gz'
    Zlib::GzipReader.open(file_gz) do |file|
      entry = nil
      file.each_line do |line|
        if line =~ /\d+\s\d+/
          Alignment.create_from_alignment(entry.strip) if entry
          entry = ''
        end
        entry += line
      end
    end
  end
 
  desc 'Clears all data, and repeats milestone 001 analysis'
  task :analysis_rebuild => [
    'load_sequence_data',
    'load_alignment_data'
  ]
 
  desc 'Rebuilds website files'
  task :www_rebuild do
    file = File.dirname(__FILE__) + '/description.markdown.erb'
    Stage.create_from_markdown_erb(@number,file)
  end
 
end