lib/bio/db/embl/common.rb in bio-1.2.1 vs lib/bio/db/embl/common.rb in bio-1.3.0
- old
+ new
@@ -3,11 +3,11 @@
#
# Copyright:: Copyright (C) 2001-2006
# Mitsuteru C. Nakao <n@bioruby.org>
# License:: The Ruby License
#
-# $Id: common.rb,v 1.12 2007/04/05 23:35:40 trevor Exp $
+# $Id: common.rb,v 1.12.2.5 2008/05/07 12:22:10 ngoto Exp $
#
# == Description
#
# EMBL style databases class
#
@@ -71,10 +71,11 @@
# http://www.expasy.org/sprot/userman.html
#
require 'bio/db'
require 'bio/reference'
+require 'bio/compat/references'
module Bio
class EMBLDB
module Common
@@ -268,36 +269,51 @@
# returns Bio::Reference object from Bio::EMBLDB::Common#ref.
# * Bio::EMBLDB::Common#ref -> Bio::References
def references
unless @data['references']
ary = self.ref.map {|ent|
- hash = Hash.new('')
+ 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'
- hash['authors'] = value.split(/, /)
+ a = value.split(/\, /)
+ a.each do |x|
+ x.sub!(/( [^ ]+)\z/, ",\\1")
+ end
+ hash['authors'] = a
when 'RT'
hash['title'] = value
when 'RL'
- if value =~ /(.*) (\d+) \((\d+)\), (\d+-\d+) \((\d+)\)$/
- hash['journal'] = $1
+ if /(.*) (\d+) *(\(([^\)]+)\))?(\, |\:)([a-zA-Z\d]+\-[a-zA-Z\d]+) *\((\d+)\)\.?\z/ =~ value.to_s
+ hash['journal'] = $1.rstrip
hash['volume'] = $2
- hash['issue'] = $3
- hash['pages'] = $4
- hash['year'] = $5
+ hash['issue'] = $4
+ hash['pages'] = $6
+ hash['year'] = $7
else
hash['journal'] = value
end
- when 'RX' # PUBMED, MEDLINE
- value.split('.').each {|item|
- tag, xref = item.split(/; /).map {|i| i.strip }
+ 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'] = References.new(ary)
+ @data['references'] = ary.extend(Bio::References::BackwardCompatibility)
end
@data['references']
end