require 'biopieces'
require 'fasta'
-require 'pp'
-
-ok_methods = "ublast,usearch,uclust,usearch_uclust"
casts = []
casts << {:long=>'name', :short=>'n', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'cover', :short=>'C', :type=>'uint', :mandatory=>false, :default=>0, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'pairs_min', :short=>'p', :type=>'uint', :mandatory=>false, :default=>5, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'prefix_len', :short=>'P', :type=>'uint', :mandatory=>false, :default=>3, :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'no_stream', :short=>'x', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
bp = Biopieces.new
end
end
-output = [options[:directory], options[:name] ].join(File::SEPARATOR)
-
-commands = []
-commands << "nice -n 19"
-commands << "idba"
-commands << "--read #{file_fasta}"
-commands << "--output #{output}"
-commands << "--scaffold" if options[:scaffold]
-commands << "--mink #{options[:k_value_min]}"
-commands << "--maxk #{options[:k_value_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(" ")
-system(command)
-raise "Command failed: #{command}" unless $?.success?
+unless File.size(file_fasta) == 0
+ output = [options[:directory], options[:name] ].join(File::SEPARATOR)
+
+ commands = []
+ commands << "nice -n 19"
+ commands << "idba"
+ commands << "--read #{file_fasta}"
+ commands << "--output #{output}"
+ commands << "--scaffold" if options[:scaffold]
+ commands << "--mink #{options[:k_value_min]}"
+ commands << "--maxk #{options[:k_value_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(" ")
+ system(command)
+ raise "Command failed: #{command}" unless $?.success?
+
+ file_contig = [options[:directory], options[:name] ].join(File::SEPARATOR) + "-contig.fa"
+
+ Fasta.open(file_contig, mode="r") do |fasta_io|
+ fasta_io.each do |entry|
+ bp.puts entry.to_bp
+ end
+ end
+end
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<