Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Re-organise rakefile into namespaces

  • Loading branch information...
commit 95282848c36e524e7195f024f75dbc741fbd3f29 1 parent f559030
@michaelbarton authored
Showing with 10,541 additions and 10,525 deletions.
  1. +46 −30 Rakefile
  2. +10,495 −10,495 data/alignment/nucmer.coords
View
76 Rakefile
@@ -1,42 +1,58 @@
-desc "Generate genome alignments"
-task :alignments => [:env,:tmp_dir] do
- Dir.chdir(TMP) do
- pids = Dir['*.fna'].map do |r|
- ref = r.gsub('.fna','')
- pid = fork{
- `nucmer --prefix=#{ref} --maxmatch #{ref}.fna ../data/genome/assembly/assembly.fna 2> /dev/null && show-coords -THr #{ref}.delta > #{ref}.coords`
- }
- pid
- end
- # Wait for all jobs to finish
- pids.each {|p| Process.waitpid p}
- end
- `cat #{TMP}/*.coords > data/alignment/nucmer.coords`
+task :env do
+ @tmp = "tmp"
+ @genome = "genome.fna"
end
-task :env do
- require 'bio'
- TMP = "tmp"
+task :tmp => :env do
+ @tmp = File.expand_path File.join(File.dirname(__FILE__),'tmp')
+ FileUtils.rm_rf @tmp if File.exists? @tmp
+ FileUtils.mkdir @tmp
end
-task :scaffold do
- Dir.chdir('data/genome/assembly') do
- `scaffolder sequence genome.scaffold.yml draft.fna > assembly.fna`
+namespace :data do
+
+ desc "Align genomes to the scaffold"
+ task :synteny => [:env,:tmp,'fasta:all'] do
+ Dir.chdir(@tmp) do
+ pids = Dir['*_*.fna'].map do |r|
+ ref = r.gsub('.fna','')
+ pid = fork{
+ `nucmer --prefix=#{ref} --maxmatch #{ref}.fna #{@genome} 2> /dev/null`
+ `show-coords -THr #{ref}.delta > #{ref}.coords`
+ }
+ pid
+ end
+ # Wait for all jobs to finish
+ pids.each {|p| Process.waitpid p}
+ end
+ `sort #{@tmp}/*.coords -o data/alignment/nucmer.coords`
end
+
end
-task :tmp_dir => [:env,:scaffold] do
- FileUtils.rm_rf TMP if File.exists? TMP
- FileUtils.mkdir TMP
+namespace :fasta do
- files = Dir['data/reference/genomes/**/*.gb']
- files.each do |f|
- dna = Bio::FlatFile.auto(f).first.to_biosequence
+ task :all => [:reference,:scaffold]
- target = f.split('/')[-3,3] * '_'
- target.gsub!(".gb",".fna")
- File.open(File.join(TMP,target),"w") do |out|
- out.print dna.output(:fasta,:header => target.gsub(".fna",""))
+ task :reference => [:env,:tmp] do
+ require 'bio'
+
+ files = Dir['data/reference/genomes/**/*.gb']
+ files.each do |f|
+ dna = Bio::FlatFile.auto(f).first.to_biosequence
+
+ target = f.split('/')[-3,3] * '_'
+ target.gsub!(".gb",".fna")
+ File.open(File.join(@tmp,target),"w") do |out|
+ out.print dna.output(:fasta,:header => target.gsub(".fna",""))
+ end
+ end
+ end
+
+ task :scaffold => [:env,:tmp] do
+ Dir.chdir('data/genome/assembly') do
+ `scaffolder sequence genome.scaffold.yml draft.fna > #{@tmp}/#{@genome}`
end
end
+
end
View
20,990 data/alignment/nucmer.coords
10,495 additions, 10,495 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.