]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed mate-pair name issue in assemble_seq_idba
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 May 2011 12:53:53 +0000 (12:53 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 May 2011 12:53:53 +0000 (12:53 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1433 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/assemble_seq_idba

index a8b6c25a9d5639ebaf3aa09a54e695d81e09ab68..cdb6d9989c472a9713bb22bd34cdf8ec8491d4d9 100755 (executable)
@@ -32,15 +32,15 @@ require 'maasha/biopieces'
 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=>'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}
-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=>'clean',      :short=>'x', :type=>'flag',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+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=>'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}
+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=>'clean',      :short=>'x', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
 
 options = Biopieces.options_parse(ARGV, casts)
 
@@ -48,9 +48,21 @@ Dir.mkdir(options[:directory]) unless Dir.exists?(options[:directory])
 
 file_fasta = File.join(options[:directory], "IDBA") + ".fna"
 
+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 records[:SEQ_NAME] =~ /1$/
+          record[:SEQ_NAME] = "read#{count}/1"
+        else
+          record[:SEQ_NAME] = "read#{count}/2"
+
+          count += 1
+        end
+      end
+
                        fasta_io.puts record
                end
        end
@@ -81,7 +93,11 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
                        $stderr.puts "Command failed: #{command}"
                end
 
-               file_contig = File.join(options[:directory], "IDBA") + "-contig.fa"
+    if options[:scaffold]
+                 file_contig = File.join(options[:directory], "IDBA") + "-contig-mate.fa"
+    else
+                 file_contig = File.join(options[:directory], "IDBA") + "-contig.fa"
+    end
 
                Fasta.open(file_contig, mode="r") do |fasta_io|
                        fasta_io.each do |entry|