[BioRuby-cvs] bioruby/lib/bio reference.rb,1.24.2.5,1.24.2.6

Naohisa Goto ngoto at dev.open-bio.org
Wed Apr 23 18:52:20 UTC 2008


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

Modified Files:
      Tag: BRANCH-biohackathon2008
	reference.rb 
Log Message:
* lib/bio/reference.rb
  * New methods: Bio::Reference#comments, Bio::Reference#doi
  * Code of Bio::Reference#embl is moved to lib/bio/db/embl/format_embl.rb
    to improve tolerance for various data (e.g. references with no
    record numbers or with duplicated record numbers).
* lib/bio/db/embl/common.rb
  * Changes to support for Bio::Reference#comments.
* lib/bio/db/embl/format_embl.rb
  * Bio::Sequence::Format::NucFormatter::Embl#reference_format_embl
    (private method) is added based on Bio::Reference#embl.
  * Changes to improve tolerance for various data.


Index: reference.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v
retrieving revision 1.24.2.5
retrieving revision 1.24.2.6
diff -C2 -d -r1.24.2.5 -r1.24.2.6
*** reference.rb	4 Mar 2008 11:31:45 -0000	1.24.2.5
--- reference.rb	23 Apr 2008 18:52:18 -0000	1.24.2.6
***************
*** 42,47 ****
    class Reference
  
-     include Bio::Sequence::Format::INSDFeatureHelper
- 
      # Author names in an Array, [ "Hoge, J.P.", "Fuga, F.B." ].
      attr_reader :authors
--- 42,45 ----
***************
*** 70,73 ****
--- 68,74 ----
      # medline identifier (typically Fixnum)
      attr_reader :medline
+ 
+     # DOI identifier (typically String, e.g. "10.1126/science.1110418")
+     attr_reader :doi
      
      # Abstract text in String.
***************
*** 89,92 ****
--- 90,96 ----
      attr_reader :sequence_position
  
+     # Comments for the reference (typically Array of String, or nil)
+     attr_reader :comments
+ 
      # Create a new Bio::Reference object from a Hash of values. 
      # Data is extracted from the values for keys:
***************
*** 126,150 ****
      # *Returns*:: Bio::Reference object
      def initialize(hash)
!       hash.default = ''
!       @authors  = hash['authors'] # [ "Hoge, J.P.", "Fuga, F.B." ]
!       @title    = hash['title']   # "Title of the study."
!       @journal  = hash['journal'] # "Theor. J. Hoge"
!       @volume   = hash['volume']  # 12
!       @issue    = hash['issue']   # 3
!       @pages    = hash['pages']   # 123-145
!       @year     = hash['year']    # 2001
!       @pubmed   = hash['pubmed']  # 12345678
!       @medline  = hash['medline'] # 98765432
!       @abstract = hash['abstract']
        @url      = hash['url']
!       @mesh     = hash['mesh']
        @embl_gb_record_number = hash['embl_gb_record_number'] || nil
        @sequence_position = hash['sequence_position'] || nil
!       @comments = hash['comments'] || []
!       @xrefs    = hash['xrefs'] || []
!       @affiliations = hash['affiliations']
!       @authors = [] if @authors.empty?
!       @mesh    = [] if @mesh.empty?
!       @affiliations = [] if @affiliations.empty?
      end
  
--- 130,150 ----
      # *Returns*:: Bio::Reference object
      def initialize(hash)
!       @authors  = hash['authors'] || [] # [ "Hoge, J.P.", "Fuga, F.B." ]
!       @title    = hash['title']   || '' # "Title of the study."
!       @journal  = hash['journal'] || '' # "Theor. J. Hoge"
!       @volume   = hash['volume']  || '' # 12
!       @issue    = hash['issue']   || '' # 3
!       @pages    = hash['pages']   || '' # 123-145
!       @year     = hash['year']    || '' # 2001
!       @pubmed   = hash['pubmed']  || '' # 12345678
!       @medline  = hash['medline'] || '' # 98765432
!       @doi      = hash['doi']
!       @abstract = hash['abstract'] || '' 
        @url      = hash['url']
!       @mesh     = hash['mesh'] || []
        @embl_gb_record_number = hash['embl_gb_record_number'] || nil
        @sequence_position = hash['sequence_position'] || nil
!       @comments  = hash['comments']
!       @affiliations = hash['affiliations'] || []
      end
  
***************
*** 273,298 ****
      #     RL   Plant Mol. Biol. 17(2):209-219(1991).
      def embl
!       lines = Array.new
!       if ! @embl_gb_record_number.nil?
!         lines << "RN   [#{@embl_gb_record_number}]"
!       end
!       if @comments != []
!         @comments.each do |c|
!           lines << "RC   #{c}"
!         end
!       end
!       if ! @sequence_position.nil?
!         lines << "RP   #{@sequence_position}"
!       end
!       if ! @xrefs.nil?
!         @xrefs.each do |x|
!           lines << "RX   #{x}"
!         end
!       end
!       lines << wrap(@authors.join(', '), 80, 'RA   ') + ';' unless @authors.nil?
!       lines << (@title == '' ? 'RT   ;' : wrap('"' + @title + '"', 80, 'RT   ') + ';')
!       lines << wrap(@journal, 80, 'RL   ') unless @journal == ''
!       lines << "XX"
!       return lines.join("\n")
      end
  
--- 273,280 ----
      #     RL   Plant Mol. Biol. 17(2):209-219(1991).
      def embl
!       r = self
!       Bio::Sequence::Format::NucFormatter::Embl.new('').instance_eval {
!         reference_format_embl(r)
!       }
      end
  




More information about the bioruby-cvs mailing list