]> git.donarmstrong.com Git - biopieces.git/commitdiff
added assemble_seq_idba
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 3 May 2011 14:16:00 +0000 (14:16 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 3 May 2011 14:16:00 +0000 (14:16 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1360 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/assemble_seq_idba [new file with mode: 0755]

diff --git a/bp_bin/assemble_seq_idba b/bp_bin/assemble_seq_idba
new file mode 100755 (executable)
index 0000000..861e038
--- /dev/null
@@ -0,0 +1,86 @@
+#!/usr/bin/env ruby
+
+# Copyright (C) 2007-2011 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This program is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Assemble sequences in the stream using IDBA.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+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=>'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=>'k_value_min', :short=>'k', :type=>'uint',   :mandatory=>false, :default=>25,  :allowed=>nil, :disallowed=>nil}
+casts << {:long=>'k_value_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=>'no_stream',   :short=>'x', :type=>'flag',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+
+bp = Biopieces.new
+
+options = bp.parse(ARGV, casts)
+
+Dir.mkdir(options[:directory]) unless Dir.exists?(options[:directory])
+
+file_fasta = [options[:directory], options[:name] ].join(File::SEPARATOR) + ".fna"
+
+Fasta.open(file_fasta, mode="w") do |fasta_io|
+  bp.each_record do |record|
+    fasta_io.puts record
+  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?
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__