casts << {:long=>'kmer_max', :short=>'K', :type=>'uint', :mandatory=>true, :default=>31, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'cov_cutoff', :short=>'c', :type=>'list', :mandatory=>true, :default=>cov_cutoffs, :allowed=>nil, :disallowed=>nil}
casts << {:long=>'exp_cov', :short=>'e', :type=>'float', :mandatory=>true, :default=>'auto', :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'clean', :short=>'x', :type=>'flag', :mandatory=>false, :default=>nil, :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)
raise ArgumentError, "kmer_min #{options[:kmer_min]} must be uneven." if options[:kmer_min].even?
raise ArgumentError, "kmer_max #{options[:kmer_max]} must be uneven." if options[:kmer_max].even?
file_fasta = File.join(options[:directory], "sequence_in.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
- velvet = Velvet.new(options[:directory], file_fasta, options[:verbose])
- velvet.run_velveth(options[:kmer_min], options[:kmer_max], options[:type])
- velvet.run_velvetg(options[:cov_cutoff], options[:exp_cov])
- file_contigs = velvet.pick_best_assembly
-
- Fasta.open(file_contigs, mode="r") do |fasta_io|
- fasta_io.each do |entry|
- bp.puts entry.to_bp
+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|
+ if record[:SEQ_NAME] and record[:SEQ]
+ seq = Seq.new_bp(record)
+ fasta_io.puts seq.to_fasta
+ end
end
- end
+ end
+
+ unless File.size(file_fasta) == 0
+ velvet = Velvet.new(options[:directory], file_fasta, options[:verbose])
+ velvet.run_velveth(options[:kmer_min], options[:kmer_max], options[:type])
+ velvet.run_velvetg(options[:cov_cutoff], options[:exp_cov])
+ file_contigs = velvet.pick_best_assembly
+
+ Fasta.open(file_contigs, 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