X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fblast_seq_pair;h=854ee424c3201110c9fb48f1dfcbe085737a884b;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=18b2b5bd404a6fab75f3cf638463a6e08e32f84d;hpb=f0df6c5ea9176bab6321c2e073a9b8db59b4ca27;p=biopieces.git diff --git a/bp_bin/blast_seq_pair b/bp_bin/blast_seq_pair index 18b2b5b..854ee42 100755 --- a/bp_bin/blast_seq_pair +++ b/bp_bin/blast_seq_pair @@ -61,6 +61,7 @@ class Blast commands << "-j #{@infile2}" commands << "-o #{@outfile}" commands << "-p #{@program}" + commands << "-W #{options[:word_size]}" if options[:word_size] commands << "-D 1" # tabular output commands << "-e #{options[:e_val]}" commands << (options[:megablast] ? "-m T" : "-m F") @@ -79,7 +80,7 @@ class Blast def each record = {} - File.open(@outfile, mode="r") do |ios| + File.open(@outfile, 'r') do |ios| ios.each_line do |line| if line !~ /^#/ fields = line.chomp.split("\t") @@ -121,14 +122,14 @@ class Blast def program_choose(type1, type2) program = "" - if type1 == 'protein' - if type2 == 'protein' + if type1 == :protein + if type2 == :protein program = 'blastp' else program = 'tblastn' end else - if type2 == 'protein' + if type2 == :protein program = 'blastx' else program = 'blastn' @@ -147,6 +148,7 @@ casts << {:long=>'e_val', :short=>'e', :type=>'float', :mandatory=>false, : casts << {:long=>'filter', :short=>'f', :type=>'string', :mandatory=>false, :default=>'no', :allowed=>'yes,no', :disallowed=>nil} casts << {:long=>'megablast', :short=>'m', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'no_gaps', :short=>'G', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} +casts << {:long=>'word_size', :short=>'w', :type=>'uint', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} options = Biopieces.options_parse(ARGV, casts) @@ -155,8 +157,8 @@ infile1 = File.join(tmpdir, "in1.fna") infile2 = File.join(tmpdir, "in2.fna") outfile = File.join(tmpdir, "blast.out") -got1 = false -got2 = false +got1 = nil +got2 = nil type1 = "" type2 = "" @@ -164,37 +166,40 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| output.puts record - if record.has_key? :SEQ_NAME and record.has_key? :SEQ - unless got1 - Fasta.open(infile1, mode="w") do |fasta_io| - fasta_io.puts record + if record[:SEQ_NAME] and record[:SEQ] + seq = Seq.new_bp(record) + + if got1.nil? + Fasta.open(infile1, "w") do |fasta_io| + fasta_io.puts seq.to_fasta end got1 = true - type1 = Seq.new(nil, record[:SEQ][0 ... 100]).type_guess - next - end - - unless got2 - Fasta.open(infile2, mode="w") do |fasta_io| - fasta_io.puts record + type1 = Seq.new(seq: record[:SEQ][0 ... 100]).type_guess + elsif got2.nil? + Fasta.open(infile2, "w") do |fasta_io| + fasta_io.puts seq.to_fasta end got2 = true - type2 = Seq.new(nil, record[:SEQ][0 ... 100]).type_guess + type2 = Seq.new(seq: record[:SEQ][0 ... 100]).type_guess end - end - end - if got1 and got2 - blast = Blast.new(infile1, infile2, outfile) - blast.program_set(type1, type2, options[:program]) - blast.run(options) + if got1 and got2 + blast = Blast.new(infile1, infile2, outfile) + blast.program_set(type1, type2, options[:program]) + blast.run(options) - blast.each do |record| - output.puts record + blast.each do |new_record| + output.puts new_record + end + + got1 = nil + got2 = nil + end end end + end