Module: Bio::KEGG::Common::References

Included in:
GENOME, ORTHOLOGY, PATHWAY
Defined in:
lib/bio/db/kegg/common.rb

Overview

The module provides references method.

Instance Method Summary (collapse)

Instance Method Details

- (Object) references

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



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/bio/db/kegg/common.rb', line 30

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 /REFERENCE/
          cmnt = tag_cut(field).chomp
          if /^\s*PMID\:(\d+)\s*/ =~ cmnt then
            hash['pubmed'] = $1
            cmnt = $'
          end
          if cmnt and !cmnt.empty? then
            hash['comments'] ||= []
            hash['comments'].push(cmnt)
          end
        when /AUTHORS/
          authors = truncate(tag_cut(field))
          authors = authors.split(/\, /)
          authors[-1] = authors[-1].split(/\s+and\s+/) if authors[-1]
          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))
          case journal
            # KEGG style
          when /(.*) (\d*(?:\([^\)]+\))?)\:(\d+\-\d+) \((\d+)\)$/
            hash['journal'] = $1
            hash['volume']  = $2
            hash['pages']   = $3
            hash['year']    = $4
            # old KEGG style
          when /(.*) (\d+):(\d+\-\d+) \((\d+)\) \[UI:(\d+)\]$/
            hash['journal'] = $1
            hash['volume']  = $2
            hash['pages']   = $3
            hash['year']    = $4
            hash['medline'] = $5
            # Only journal name and year are available
          when /(.*) \((\d+)\)$/
            hash['journal'] = $1
            hash['year']    = $2
          else
            hash['journal'] = journal
          end
        end
      end
      ary.push(Reference.new(hash))
    end
    @data['REFERENCE'] = ary #.extend(Bio::References::BackwardCompatibility)

  end
  @data['REFERENCE']
end