module Bio::KEGG::Common::References
The module provides references method.
Public Instance Methods
references()
click to toggle source
REFERENCE – Returns contents of the REFERENCE records as an Array of Bio::Reference
objects.
# File lib/bio/db/kegg/common.rb 30 def references 31 unless @data['REFERENCE'] 32 ary = [] 33 toptag2array(get('REFERENCE')).each do |ref| 34 hash = Hash.new 35 subtag2array(ref).each do |field| 36 case tag_get(field) 37 when /REFERENCE/ 38 cmnt = tag_cut(field).chomp 39 if /^\s*PMID\:(\d+)\s*/ =~ cmnt then 40 hash['pubmed'] = $1 41 cmnt = $' 42 end 43 if cmnt and !cmnt.empty? then 44 hash['comments'] ||= [] 45 hash['comments'].push(cmnt) 46 end 47 when /AUTHORS/ 48 authors = truncate(tag_cut(field)) 49 authors = authors.split(/\, /) 50 authors[-1] = authors[-1].split(/\s+and\s+/) if authors[-1] 51 authors = authors.flatten.map { |a| a.sub(',', ', ') } 52 hash['authors'] = authors 53 when /TITLE/ 54 hash['title'] = truncate(tag_cut(field)) 55 when /JOURNAL/ 56 journal = truncate(tag_cut(field)) 57 case journal 58 # KEGG style 59 when /(.*) (\d*(?:\([^\)]+\))?)\:(\d+\-\d+) \((\d+)\)$/ 60 hash['journal'] = $1 61 hash['volume'] = $2 62 hash['pages'] = $3 63 hash['year'] = $4 64 # old KEGG style 65 when /(.*) (\d+):(\d+\-\d+) \((\d+)\) \[UI:(\d+)\]$/ 66 hash['journal'] = $1 67 hash['volume'] = $2 68 hash['pages'] = $3 69 hash['year'] = $4 70 hash['medline'] = $5 71 # Only journal name and year are available 72 when /(.*) \((\d+)\)$/ 73 hash['journal'] = $1 74 hash['year'] = $2 75 else 76 hash['journal'] = journal 77 end 78 end 79 end 80 ary.push(Reference.new(hash)) 81 end 82 @data['REFERENCE'] = ary #.extend(Bio::References::BackwardCompatibility) 83 84 end 85 @data['REFERENCE'] 86 end