[BioRuby-cvs] bioruby/lib/bio/io fastacmd.rb,1.2,1.3

Naohisa Goto ngoto at pub.open-bio.org
Tue Aug 9 06:28:28 EDT 2005


Update of /home/repository/bioruby/bioruby/lib/bio/io
In directory pub.open-bio.org:/tmp/cvs-serv1657

Modified Files:
	fastacmd.rb 
Log Message:
* Changed not to execute shell when execute command
* Using block with Open3.popen3
* removed rescue


Index: fastacmd.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fastacmd.rb	9 Aug 2005 08:55:40 -0000	1.2
--- fastacmd.rb	9 Aug 2005 09:40:27 -0000	1.3
***************
*** 51,74 ****
        end
  
!       cmd = "#{@fastacmd} -d #{@database} -s #{entry_id}"
!       begin
!         inn, out, err = Open3.popen3(cmd)
          results = Bio::FlatFile.new(Bio::FastaFormat, out).to_a
!         err_msg = err.read
!         return results
!       rescue
!         raise "[Error] command execution failed : #{cmd}\n#{err_msg}"
!       ensure
!         inn.close; out.close; err.close
        end
      end
  
      def each_entry
!       cmd = "#{@fastacmd} -d #{@database} -D T"
!       IO.popen(cmd) do |io|
!         f = Bio::FlatFile.new(Bio::FastaFormat, io)
          f.each_entry do |e|
            yield e
          end
        end
      end
--- 51,74 ----
        end
  
!       cmd = [ @fastacmd, '-d', @database, '-s', entry_id ]
!       Open3.popen3(cmd) do |inn, out, err|
!         inn.close
!         t = Thread.start { err.read }
          results = Bio::FlatFile.new(Bio::FastaFormat, out).to_a
!         t.join
!         results
        end
      end
  
      def each_entry
!       cmd = [ @fastacmd, '-d', @database, '-D', 'T' ]
!       Open3.popen3(*cmd) do |inn, out, err|
!         inn.close
!         t = Thread.start { err.read }
!         f = Bio::FlatFile.new(Bio::FastaFormat, out)
          f.each_entry do |e|
            yield e
          end
+         t.join
        end
      end



More information about the bioruby-cvs mailing list