[BioRuby-cvs] bioruby/lib/bio/db/embl format_embl.rb, 1.1.2.3, 1.1.2.4

Naohisa Goto ngoto at dev.open-bio.org
Wed May 7 12:24:28 UTC 2008


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

Modified Files:
      Tag: BRANCH-biohackathon2008
	format_embl.rb 
Log Message:
Bug fix: in RA line, every author's name should not be splitted into two lines.


Index: format_embl.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/Attic/format_embl.rb,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** format_embl.rb	23 Apr 2008 18:52:18 -0000	1.1.2.3
--- format_embl.rb	7 May 2008 12:24:26 -0000	1.1.2.4
***************
*** 21,28 ****
--- 21,52 ----
      private
  
+     # wrapping with EMBL style
      def embl_wrap(prefix, str)
        wrap(str.to_s, 80, prefix)
      end
  
+     # Given words (an Array of String) are wrapping with EMBL style.
+     # Each word is never splitted inside the word.
+     def embl_wrap_words(prefix, array)
+       width = 80
+       result = []
+       str = nil
+       array.each do |x|
+         if str then
+           if str.length + 1 + x.length > width then
+             str = nil
+           else
+             str.concat ' '
+             str.concat x
+           end
+         end
+         unless str then
+           str = prefix + x
+           result.push str
+         end
+       end
+       result.join("\n")
+     end
+ 
      # format reference
      # ref:: Bio::Reference object
***************
*** 53,58 ****
          lines << embl_wrap("RX   ",   "PUBMED; #{ref.pubmed}.")
        end
!       unless ref.authors.empty?
!         lines << embl_wrap('RA   ', ref.authors.join(', ') + ';')
        end
        lines << embl_wrap('RT   ',
--- 77,90 ----
          lines << embl_wrap("RX   ",   "PUBMED; #{ref.pubmed}.")
        end
!       unless ref.authors.empty? then
!         auth = ref.authors.collect do |x|
!           y = x.to_s.strip.split(/\, *([^\,]+)\z/)
!           y[1].gsub!(/\. +/, '.') if y[1]
!           y.join(' ')
!         end
!         lastauth = auth.pop
!         auth.each { |x| x.concat ',' }
!         auth.push(lastauth.to_s + ';')
!         lines << embl_wrap_words('RA   ', auth)
        end
        lines << embl_wrap('RT   ',




More information about the bioruby-cvs mailing list