lib/uniprot_parser/protein.rb
#Append a cross referenced database line (DR)
#@param line [String] the DR line to append
Append a cross referenced database line (DR)
Append a cross referenced database line ( DR )
def append_dr(line)
      @dr_block = '' if @dr_block.nil?
      @dr_block += line
      @dr_hash = Hash.new if(@dr_hash.nil?)
      tmp = line.split(';')
      @dr_hash[tmp[0][2..-1].strip] = Array.new if(@dr_hash[tmp[0][2..-1].strip].nil?)
      @dr_hash[tmp[0][2..-1].strip] << tmp[1..-1].join(';').strip
      unless respond_to? "dr_#{tmp[0][2..-1].gsub("\s",'').downcase}"
        self.class.send(:define_method,"dr_#{tmp[0][2..-1].gsub("\s",'').downcase}") do ||
          return @dr_hash[tmp[0][2..-1].strip]
        end
      end
    end
def append_dr ( line ) @dr_block = '' if @dr_block . nil? @dr_block += line @dr_hash = Hash . new if ( @dr_hash . nil? ) tmp = line . split ( ';' ) @dr_hash [ tmp [ 0 ] [ 2 .. - 1 ] . strip ] = Array . new if ( @dr_hash [ tmp [ 0 ] [ 2 .. - 1 ] . strip ] . nil? ) @dr_hash [ tmp [ 0 ] [ 2 .. - 1 ] . strip ] << tmp [ 1 .. - 1 ] . join ( ';' ) . strip unless respond_to? "dr_#{tmp[0][2..-1].gsub("\s",'').downcase}" self . class . send ( :define_method , "dr_#{tmp[0][2..-1].gsub("\s",'').downcase}" ) do | | return @dr_hash [ tmp [ 0 ] [ 2 .. - 1 ] . strip ] end end end
Append a cross referenced database line (DR)
Append a cross referenced database line ( DR )
# we add the cross reference information in the dedicated hash # as key we use the ID of the database, as content the reference and other informations provided # we automatically create a method to get the database associated content #define_method is private so ...
line
the DR line to append
the DR line to append