From 79351f6b5e9a7b9167230a726f361a4bb2ad1c19 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Mon, 11 Mar 2013 14:49:14 +0000 Subject: [PATCH] changed blast_seq_pair to do multiple pairs git-svn-id: http://biopieces.googlecode.com/svn/trunk@2125 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/blast_seq_pair | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/bp_bin/blast_seq_pair b/bp_bin/blast_seq_pair index d612a6c..ca1d543 100755 --- a/bp_bin/blast_seq_pair +++ b/bp_bin/blast_seq_pair @@ -79,7 +79,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") @@ -155,8 +155,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 = "" @@ -167,36 +167,37 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| if record[:SEQ_NAME] and record[:SEQ] seq = Seq.new_bp(record) - unless got1 - Fasta.open(infile1, mode="w") do |fasta_io| + 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| + 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 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 -- 2.39.2