]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed asseble_seq_idba
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 24 May 2011 11:39:39 +0000 (11:39 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 24 May 2011 11:39:39 +0000 (11:39 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1421 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/assemble_seq_idba

index ef35973f6ea627f1fa280b01d182d5437e2cbd60..a8b6c25a9d5639ebaf3aa09a54e695d81e09ab68 100755 (executable)
@@ -42,53 +42,53 @@ casts << {:long=>'pairs_min',  :short=>'p', :type=>'uint',   :mandatory=>false,
 casts << {:long=>'prefix_len', :short=>'P', :type=>'uint',   :mandatory=>false, :default=>3,   :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'clean',      :short=>'x', :type=>'flag',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
 
-bp = Biopieces.new
-
-options = bp.parse(ARGV, casts)
+options = Biopieces.options_parse(ARGV, casts)
 
 Dir.mkdir(options[:directory]) unless Dir.exists?(options[:directory])
 
 file_fasta = File.join(options[:directory], "IDBA") + ".fna"
 
-Fasta.open(file_fasta, mode="w") do |fasta_io|
-  bp.each_record do |record|
-    fasta_io.puts record
-  end
-end
-
-unless File.size(file_fasta) == 0
-  output = File.join(options[:directory], "IDBA")
-
-  commands = []
-  commands << "nice -n 19"
-  commands << "idba"
-  commands << "--read #{file_fasta}"
-  commands << "--output #{output}"
-  commands << "--scaffold" if options[:scaffold]
-  commands << "--mink #{options[:kmer_min]}"
-  commands << "--maxk #{options[:kmer_max]}"
-  commands << "--minCount #{options[:count_min]}"
-  commands << "--cover #{options[:cover]}"
-  commands << "--minPairs #{options[:pairs_min]}"
-  commands << "--prefixLength #{options[:prefix_len]}"
-  commands << "> /dev/null 2>&1" unless options[:verbose]
-
-  command = commands.join(" ")
-
-  begin
-    system(command)
-    raise "Command failed: #{command}" unless $?.success?
-  rescue
-    $stderr.puts "Command failed: #{command}"
-  end
-
-  file_contig = File.join(options[:directory], "IDBA") + "-contig.fa"
-
-  Fasta.open(file_contig, mode="r") do |fasta_io|
-    fasta_io.each do |entry|
-      bp.puts entry.to_bp
-    end
-  end
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+       Fasta.open(file_fasta, mode="w") do |fasta_io|
+               input.each_record do |record|
+                       fasta_io.puts record
+               end
+       end
+
+       unless File.size(file_fasta) == 0
+               prefix = File.join(options[:directory], "IDBA")
+
+               commands = []
+               commands << "nice -n 19"
+               commands << "idba"
+               commands << "--read #{file_fasta}"
+               commands << "--output #{prefix}"
+               commands << "--scaffold" if options[:scaffold]
+               commands << "--mink #{options[:kmer_min]}"
+               commands << "--maxk #{options[:kmer_max]}"
+               commands << "--minCount #{options[:count_min]}"
+               commands << "--cover #{options[:cover]}"
+               commands << "--minPairs #{options[:pairs_min]}"
+               commands << "--prefixLength #{options[:prefix_len]}"
+               commands << "> /dev/null 2>&1" unless options[:verbose]
+
+               command = commands.join(" ")
+
+               begin
+                       system(command)
+                       raise "Command failed: #{command}" unless $?.success?
+               rescue
+                       $stderr.puts "Command failed: #{command}"
+               end
+
+               file_contig = File.join(options[:directory], "IDBA") + "-contig.fa"
+
+               Fasta.open(file_contig, mode="r") do |fasta_io|
+                       fasta_io.each do |entry|
+                               output.puts entry.to_bp
+                       end
+               end
+       end
 end
 
 FileUtils.remove_entry_secure file_fasta