Method: Bio::EMBLDB::Common#references

Defined in:
lib/bio/db/embl/common.rb

#referencesObject

returns Bio::Reference object from Bio::EMBLDB::Common#ref.

  • Bio::EMBLDB::Common#ref -> Bio::References



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/bio/db/embl/common.rb', line 271

def references
  unless @data['references']
    ary = self.ref.map {|ent|
      hash = Hash.new
      ent.each {|key, value|
        case key
        when 'RN'
          if /\[(\d+)\]/ =~ value.to_s
            hash['embl_gb_record_number'] = $1.to_i
          end
        when 'RC'
          unless value.to_s.strip.empty?
            hash['comments'] ||= []
            hash['comments'].push value
          end
        when 'RP'
          hash['sequence_position'] = value
        when 'RA'
          a = value.split(/\, /)
          a.each do |x|
            x.sub!(/( [^ ]+)\z/, ",\\1")
          end
          hash['authors'] = a
        when 'RT'
          hash['title'] = value
        when 'RL'
          if /(.*) (\d+) *(\(([^\)]+)\))?(\, |\:)([a-zA-Z\d]+\-[a-zA-Z\d]+) *\((\d+)\)\.?\z/ =~ value.to_s
            hash['journal'] = $1.rstrip
            hash['volume']  = $2
            hash['issue']   = $4
            hash['pages']   = $6
            hash['year']    = $7
          else
            hash['journal'] = value
          end
        when 'RX'  # PUBMED, DOI, (AGRICOLA)
          value.split(/\. /).each {|item|
            tag, xref = item.split(/\; /).map {|i| i.strip.sub(/\.\z/, '') }
            hash[ tag.downcase ]  = xref
          }
        end
      }
      Reference.new(hash)
    }
    @data['references'] = ary.extend(Bio::References::BackwardCompatibility)
  end
  @data['references']
end