[BioRuby-cvs] bioruby/lib/bio reference.rb,1.24,1.24.2.1

Jan Aerts aerts at dev.open-bio.org
Mon Feb 18 15:44:41 UTC 2008


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

Modified Files:
      Tag: BRANCH-biohackathon2008
	reference.rb 
Log Message:
Added export method to EMBL format.


Index: reference.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -C2 -d -r1.24 -r1.24.2.1
*** reference.rb	5 Apr 2007 23:35:39 -0000	1.24
--- reference.rb	18 Feb 2008 15:44:39 -0000	1.24.2.1
***************
*** 2,8 ****
  # = bio/reference.rb - Journal reference classes
  #
! # Copyright::   Copyright (C) 2001, 2006
  #               Toshiaki Katayama <k at bioruby.org>,
! #               Ryan Raaum <ryan at raaum.org>
  # License::     The Ruby License
  #
--- 2,9 ----
  # = bio/reference.rb - Journal reference classes
  #
! # Copyright::   Copyright (C) 2001, 2006, 2008
  #               Toshiaki Katayama <k at bioruby.org>,
! #               Ryan Raaum <ryan at raaum.org>,
! #               Jan Aerts <jandot at bioruby.org>
  # License::     The Ruby License
  #
***************
*** 79,82 ****
--- 80,89 ----
      # Affiliations in an Array.
      attr_reader :affiliations
+     
+     # Sequence number in EMBL/GenBank records
+     attr_reader :embl_gb_record_number
+     
+     # Position in a sequence that this reference refers to
+     attr_reader :sequence_position
  
      # Create a new Bio::Reference object from a Hash of values. 
***************
*** 130,133 ****
--- 137,144 ----
        @url      = hash['url']
        @mesh     = hash['mesh']
+       @embl_gb_record_number = hash['embl_gb_record_number'] || nil
+       @sequence_position = hash['sequence_position'] || []
+       @comments = hash['comments'] || []
+       @xrefs    = hash['xrefs'] || []
        @affiliations = hash['affiliations']
        @authors = [] if @authors.empty?
***************
*** 171,174 ****
--- 182,187 ----
      def format(style = nil, option = nil)
        case style
+       when 'embl'
+         return embl
        when 'endnote'
          return endnote
***************
*** 246,249 ****
--- 259,298 ----
      end
  
+     # Returns reference formatted in the EMBL style.
+     #
+     #   # ref is a Bio::Reference object
+     #   puts ref.embl
+     #
+     #     RP   1-1859
+     #     RX   PUBMED; 1907511.
+     #     RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+     #     RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+     #     RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+     #     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 != ''
+         lines << "RP   #{@sequence_position}"
+       end
+       if ! @xrefs.nil?
+         @xrefs.each do |x|
+           lines << "RX   #{x}"
+         end
+       end
+       lines << @authors.join(', ').wrap(80, 'RA   ') + ';' unless @authors.nil?
+       lines << (@title == '' ? 'RT   ;' : ('"' + @title + '"').wrap(80, 'RT   ') + ';')
+       lines << @journal.wrap(80, 'RL   ') unless @journal == ''
+       lines << "XX"
+       return lines.join("\n")
+     end
+ 
      # Returns reference formatted in the bibitem style
      #
***************
*** 542,546 ****
    #
    class References
! 
      # Array of Bio::Reference objects
      attr_accessor :references
--- 591,596 ----
    #
    class References
!     include Enumerable
!     
      # Array of Bio::Reference objects
      attr_accessor :references




More information about the bioruby-cvs mailing list