Module: Exodb::VarLocationField
- Extended by:
- ActiveSupport::Concern
- Included in:
- Variant, Variantref
- Defined in:
- lib/exodb/datamodel/varlocfield.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#chromosome ⇒ Integer
get the chromosome.
-
#convlocation=(loc) ⇒ Object
Assign location.
-
#location=(loc) ⇒ Object
Assign location.
-
#location_str(assembly = nil) ⇒ String
Return location from specific genome assembly.
-
#parse_locstr(loc_str) ⇒ Object
Assign gene location in format of chromosome_number:pos;build.
Instance Method Details
#chromosome ⇒ Integer
get the chromosome
36 37 38 |
# File 'lib/exodb/datamodel/varlocfield.rb', line 36 def chromosome self[:location]['chr'] end |
#convlocation=(loc) ⇒ Object
Assign location
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# 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) ⇒ Object
Assign location
75 76 77 78 79 80 81 82 83 84 85 86 |
# 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) ⇒ String
Return location from specific genome assembly
59 60 61 62 63 64 65 66 67 68 69 70 |
# 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) ⇒ Object
Assign gene location in format of chromosome_number:pos;build
43 44 45 46 47 48 49 50 51 52 |
# 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 |