[BioRuby-cvs] bioruby/lib/bio/shell/plugin seq.rb,1.17,1.18

Katayama Toshiaki k at dev.open-bio.org
Tue Sep 19 06:20:40 UTC 2006


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

Modified Files:
	seq.rb 
Log Message:
* sixtrans, skip, step methods are added


Index: seq.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/plugin/seq.rb,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** seq.rb	9 Feb 2006 20:48:53 -0000	1.17
--- seq.rb	19 Sep 2006 06:20:38 -0000	1.18
***************
*** 42,45 ****
--- 42,54 ----
  
  
+   def sixtrans(str)
+     seq = seq(str)
+     [ 1, 2, 3, -1, -2, -3 ].each do |frame|
+       title = "Translation #{frame.to_s.rjust(2)}"
+       puts seq.translate(frame).to_fasta(title, 60)
+     end
+   end
+ 
+ 
    # Displays some basic properties of the sequence.
    def seqstat(str)
***************
*** 152,155 ****
--- 161,182 ----
  class String
  
+   def step(window_size)
+     i = 0
+     0.step(self.length - window_size, window_size) do |i|
+       yield self[i, window_size]
+     end
+     yield self[i + window_size .. -1] if i + window_size < self.length
+   end
+ 
+   def skip(window_size, step_size = 1)
+     i = 0
+     0.step(self.length - window_size, step_size) do |i|
+       yield [self[i, window_size], i + 1, i + window_size]
+     end
+     from = i + step_size
+     to  = [self.length, i + step_size + window_size].min
+     yield [self[from, window_size], from + 1, to] if from + 1 <= to
+   end
+ 
    def to_naseq
      Bio::Sequence::NA.new(self)




More information about the bioruby-cvs mailing list