[BioRuby-cvs] bioruby/lib/bio/shell/plugin seq.rb,1.8,1.9

Katayama Toshiaki k at pub.open-bio.org
Tue Nov 15 23:03:25 EST 2005


Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin
In directory pub.open-bio.org:/tmp/cvs-serv1478/plugin

Modified Files:
	seq.rb 
Log Message:
* Bio::Sequence object go through seq() methods faster
* changed to use parse() method in plugin/flatfile.rb
* sequence is folded in seqstat method


Index: seq.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/seq.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** seq.rb	15 Nov 2005 12:56:39 -0000	1.8
--- seq.rb	16 Nov 2005 04:03:23 -0000	1.9
***************
*** 40,51 ****
    #   * ID     -- "embl:BUM"  (entry is retrieved by the OBDA)
    def seq(arg)
!     if arg.respond_to?(:gets) or File.exists?(arg)
        entry = flatauto(arg)
      elsif arg[/:/]
        db, entry_id = arg.split(/:/)
        str = obda_get_entry(db, entry_id)
!       if cls = Bio::FlatFile.autodetect(str)
!         entry = cls.new(str)
!       end
      else
        tmp = arg
--- 40,51 ----
    #   * ID     -- "embl:BUM"  (entry is retrieved by the OBDA)
    def seq(arg)
!     if arg.kind_of?(Bio::Sequence)
!       s = arg
!     elsif arg.respond_to?(:gets) or File.exists?(arg)
        entry = flatauto(arg)
      elsif arg[/:/]
        db, entry_id = arg.split(/:/)
        str = obda_get_entry(db, entry_id)
!       entry = parse(str)
      else
        tmp = arg
***************
*** 70,80 ****
    # Convert sequence to colored HTML string
    def htmlseq(str)
!     if str.instance_of?(String)
!       s = seq(str)
!     elsif str.kind_of?(Bio::Sequence)
!       s = str
      end
  
!     if s.is_a?(Bio::Sequence::AA)
        scheme = Bio::ColorScheme::Taylor
      else
--- 70,80 ----
    # Convert sequence to colored HTML string
    def htmlseq(str)
!     if str.kind_of?(Bio::Sequence)
!       seq = str
!     else
!       seq = seq(str)
      end
  
!     if seq.is_a?(Bio::Sequence::AA)
        scheme = Bio::ColorScheme::Taylor
      else
***************
*** 83,87 ****
  
      html = %Q[<div style="font-family:monospace;">\n]
!     s.fold(50).each_byte do |c|
        case c.chr
        when "\n"
--- 83,87 ----
  
      html = %Q[<div style="font-family:monospace;">\n]
!     seq.fold(50).each_byte do |c|
        case c.chr
        when "\n"
***************
*** 102,124 ****
      rep = ""
      if seq.respond_to?(:complement)
!       rep << "Sequence           : #{seq}\n"
!       rep << "Reverse complement : #{seq.complement}\n"
!       rep << "Translation  1     : #{seq.translate}\n"
!       rep << "Translation  2     : #{seq.translate(2)}\n"
!       rep << "Translation  3     : #{seq.translate(3)}\n"
!       rep << "Translation -1     : #{seq.translate(-1)}\n"
!       rep << "Translation -2     : #{seq.translate(-2)}\n"
!       rep << "Translation -3     : #{seq.translate(-3)}\n"
        rep << "GC percent         : #{seq.gc_percent} %\n"
        rep << "Composition        : #{seq.composition.inspect}\n"
        begin
          rep << "Molecular weight   : #{seq.molecular_weight}\n"
          rep << "Complemnet weight  : #{seq.complement.molecular_weight}\n"
          rep << "Protein weight     : #{seq.translate.molecular_weight}\n"
        rescue
!         rep << "Molecular weight   : #{$!}\n"
        end
      else
!       rep << "Sequence           : #{seq}\n"
        rep << "Composition        : #{seq.composition.inspect}\n"
        begin
--- 102,132 ----
      rep = ""
      if seq.respond_to?(:complement)
!       rep << "Sequence           : #{seq.fold(71,21).strip}\n"
!       rep << "Reverse complement : #{seq.complement.fold(71,21).strip}\n"
!       rep << "Translation  1     : #{seq.translate.fold(71,21).strip}\n"
!       rep << "Translation  2     : #{seq.translate(2).fold(71,21).strip}\n"
!       rep << "Translation  3     : #{seq.translate(3).fold(71,21).strip}\n"
!       rep << "Translation -1     : #{seq.translate(-1).fold(71,21).strip}\n"
!       rep << "Translation -2     : #{seq.translate(-2).fold(71,21).strip}\n"
!       rep << "Translation -3     : #{seq.translate(-3).fold(71,21).strip}\n"
        rep << "GC percent         : #{seq.gc_percent} %\n"
        rep << "Composition        : #{seq.composition.inspect}\n"
        begin
          rep << "Molecular weight   : #{seq.molecular_weight}\n"
+       rescue
+         rep << "Molecular weight   : #{$!}\n"
+       end
+       begin
          rep << "Complemnet weight  : #{seq.complement.molecular_weight}\n"
+       rescue
+         rep << "Complement weight  : #{$!}\n"
+       end
+       begin
          rep << "Protein weight     : #{seq.translate.molecular_weight}\n"
        rescue
!         rep << "Protein weight     : #{$!}\n"
        end
      else
!       rep << "Sequence           : #{seq.fold(71,21).strip}\n"
        rep << "Composition        : #{seq.composition.inspect}\n"
        begin



More information about the bioruby-cvs mailing list