[BioRuby-cvs] bioruby/lib bio.rb,1.89,1.89.2.1

Jan Aerts aerts at dev.open-bio.org
Wed Feb 20 09:56:24 UTC 2008


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

Modified Files:
      Tag: BRANCH-biohackathon2008
	bio.rb 
Log Message:
* Rewrote some of the code for converting EMBL files into Bio::Sequence.
* Added functionality to export Bio::Sequence to EMBL format.

Changes:
* renamed Sequence::Format#wrap and #fold to String#wrap and #fold (stored in bio.rb)
* lib/bio/db/common.rb:
    - rewrote def ref and def references
    - added to_biosequence
    - def references now returns an Array instead of a Bio::References object (tests changed accordingly)
* lib/bio/db/embl/embl.rb
    - def ft now returns Array instead of Bio::Features object (tests changed accordingly)
* lib/bio/db/embl/format.erb
* lib/bio/sequence/common.rb
    - added def format_embl


Index: bio.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v
retrieving revision 1.89
retrieving revision 1.89.2.1
diff -C2 -d -r1.89 -r1.89.2.1
*** bio.rb	9 Jan 2008 17:18:17 -0000	1.89
--- bio.rb	20 Feb 2008 09:56:22 -0000	1.89.2.1
***************
*** 278,279 ****
--- 278,310 ----
  end
  
+ class String
+   def fold(width = 80)
+     self.gsub(Regexp.new("(.{1,#{width}})"), "\\1\n")
+   end
+   
+   def wrap(width = 80, prefix = '')
+     actual_width = width - prefix.length
+     result = []
+     left = self.dup
+     while left and left.length > actual_width
+       line = nil
+       actual_width.downto(1) do |i|
+         if left[i..i] == ' ' or /[,;]/ =~ left[(i-1)..(i-1)]  then
+           line = left[0..(i-1)].sub(/ +\z/, '')
+           left = left[i..-1].sub(/\A +/, '')
+           break
+         end
+       end
+       if line.nil? then
+         line = left[0..(actual_width-1)]
+         left = left[actual_width..-1]
+       end
+       result << line
+     end
+     result << left if left
+     result_string = result.join("\n#{prefix}")
+     result_string = prefix + result_string unless result_string.empty?
+ #    result_string << "\n" unless result_string.empty?
+     return result_string
+   end
+ end
\ No newline at end of file




More information about the bioruby-cvs mailing list