module Exodb::VarLocationField
Public Instance Methods
chromosome()
click to toggle source
get the chromosome
@return [Integer] chromosome
# File lib/exodb/datamodel/varlocfield.rb, line 36 def chromosome self[:location]['chr'] end
convlocation=(loc)
click to toggle source
Assign location
@param [String, Hash] location string in chromosome:start..stop or chromosome:start-stop format
# File lib/exodb/datamodel/varlocfield.rb, line 91 def convlocation=(loc) if loc.is_a?(String) begin self[:convlocation].push(parse_locstr(loc).delete_if {|k, v| ['start', 'stop'].include?(k)}) rescue end end end
location=(loc)
click to toggle source
Assign location
@param [String, Hash] location string in chromosome:start..stop or chromosome:start-stop format
# File lib/exodb/datamodel/varlocfield.rb, line 75 def location=(loc) if loc.is_a?(String) begin self[:location] = parse_locstr(loc).delete_if {|k, v| ['start', 'stop'].include?(k)} rescue end end end
location_str(assembly = nil)
click to toggle source
Return location from specific genome assembly
@param [String] assembly version
@return [String] location string in chromosome:position
# File lib/exodb/datamodel/varlocfield.rb, line 59 def location_str(assembly = nil) result = nil if assembly == nil || Exodb::ASSEMBLY[assembly] == self[:location]['assembly'] result = "#{self[:location]['chr']}:#{self[:location]['position']}:#{self[:location]['assembly']}" else self[:convlocation].each {|e| result = "#{[e['chr'], e['position'], e['assembly']].join(':')}" if e['assembly'] == Exodb::ASSEMBLY[assembly]} end return result end
parse_locstr(loc_str)
click to toggle source
Assign gene location in format of chromosome_number:pos;build
@param [String] gene location in format of chromosome_number:start..stop
# File lib/exodb/datamodel/varlocfield.rb, line 43 def parse_locstr(loc_str) dat = loc_str.split(/:/) return {'chr' => dat[0], 'position' => dat[1].to_i, 'assembly' => dat[2] ? Exodb::ASSEMBLY.has_key?(dat[2]) ? Exodb::ASSEMBLY[dat[2]] : dat[2] : Exodb::DEFAULTASSEMBLY } end