]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/assemble_seq_idba
added new match.rb and tests
[biopieces.git] / bp_bin / assemble_seq_idba
index 1f392e91184b94de637b43e7e4a4b32648db5085..bd8b4a819b8986ccfe6f9c968f9f65bbb264043b 100755 (executable)
@@ -34,6 +34,7 @@ require 'maasha/fasta'
 casts = []
 casts << {:long=>'directory',  :short=>'d', :type=>'dir',  :mandatory=>true,  :default=>nil, :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'scaffold',   :short=>'s', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+casts << {:long=>'metagenome', :short=>'m', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'kmer_min',   :short=>'k', :type=>'uint', :mandatory=>false, :default=>25,  :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'kmer_max',   :short=>'K', :type=>'uint', :mandatory=>false, :default=>50,  :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'count_min',  :short=>'c', :type=>'uint', :mandatory=>false, :default=>2,   :allowed=>nil, :disallowed=>nil}
@@ -53,17 +54,21 @@ count = 0
 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 options[:scaffold] # we need to fix the sequence name for mate-pair IDBA
-        if record[:SEQ_NAME] =~ /1$/
-          record[:SEQ_NAME] = "read#{count}/1"
-        else
-          record[:SEQ_NAME] = "read#{count}/2"
+      if record[:SEQ_NAME] and record[:SEQ]
+        seq = Seq.new_bp(record)
 
-          count += 1
+        if options[:scaffold] # we need to fix the sequence name for mate-pair IDBA
+          if seq.seq_name =~ /1$/
+            seq.seq_name = "read#{count}/1"
+          else
+            seq.seq_name = "read#{count}/2"
+
+            count += 1
+          end
         end
-      end
 
-                       fasta_io.puts record
+        fasta_io.puts seq.to_fasta
+      end
                end
        end
 
@@ -72,7 +77,13 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
                commands = []
                commands << "nice -n 19"
-               commands << "idba"
+
+    if options[:metagenome]
+                 commands << "metaidba"
+    else
+                 commands << "idba"
+    end
+
                commands << "--read #{file_fasta}"
                commands << "--output #{prefix}"
                commands << "--scaffold" if options[:scaffold]