Method: Bio::KEGG::GENOME#references

Defined in:
lib/bio/db/kegg/genome.rb

#referencesObject

REFERENCE – Returns contents of the REFERENCE records as an Array of Bio::Reference objects.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bio/db/kegg/genome.rb', line 96

def references
  unless @data['REFERENCE']
    ary = []
    toptag2array(get('REFERENCE')).each do |ref|
      hash = Hash.new('')
      subtag2array(ref).each do |field|
        case tag_get(field)
        when /AUTHORS/
          authors = truncate(tag_cut(field))
          authors = authors.split(', ')
          authors[-1] = authors[-1].split(/\s+and\s+/)
          authors = authors.flatten.map { |a| a.sub(',', ', ') }
          hash['authors'] = authors
        when /TITLE/
          hash['title'] = truncate(tag_cut(field))
        when /JOURNAL/
          journal = truncate(tag_cut(field))
          if journal =~ /(.*) (\d+):(\d+)-(\d+) \((\d+)\) \[UI:(\d+)\]$/
            hash['journal'] = $1
            hash['volume']  = $2
            hash['pages'] = $3
            hash['year']  = $5
            hash['medline'] = $6
          else
            hash['journal'] = journal
          end
        end
      end
      ary.push(Reference.new(hash))
    end
    @data['REFERENCE'] = References.new(ary)
  end
  @data['REFERENCE']
end