Module: Exodb::GenomeLocationField
- Extended by:
- ActiveSupport::Concern
- Included in:
- Gene, Generef, Variant, Variantref
- Defined in:
- lib/exodb/datamodel/locationfield.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#begin ⇒ Integer
get the start position of gene rely on the genome.
-
#chromosome ⇒ Integer
get the chromosome.
-
#end ⇒ Integer
get the start position of gene rely on the genome.
- #location_str ⇒ Object
-
#parse_location(loc_str) ⇒ Object
Assign gene location in format of chromosome_number:start..stop.
-
#start ⇒ Integer
get the start position of gene rely on the genome.
-
#stop ⇒ Integer
get the end position of gene rely on the genome.
Instance Method Details
#begin ⇒ Integer
get the start position of gene rely on the genome
81 82 83 |
# File 'lib/exodb/datamodel/locationfield.rb', line 81 def begin self[:strand] == '+' ? self[:location]['start'] : self[:location]['stop'] end |
#chromosome ⇒ Integer
get the chromosome
95 96 97 |
# File 'lib/exodb/datamodel/locationfield.rb', line 95 def chromosome self[:location]['chromosome'] end |
#end ⇒ Integer
get the start position of gene rely on the genome
88 89 90 |
# File 'lib/exodb/datamodel/locationfield.rb', line 88 def end self[:strand] == '+' ? self[:location]['stop'] : self[:location]['start'] end |
#location_str ⇒ Object
111 112 113 |
# File 'lib/exodb/datamodel/locationfield.rb', line 111 def location_str return "#{self.chromosome}:#{[self.start, self.stop].uniq.join('..')}" end |
#parse_location(loc_str) ⇒ Object
Assign gene location in format of chromosome_number:start..stop
102 103 104 105 106 107 108 109 |
# File 'lib/exodb/datamodel/locationfield.rb', line 102 def parse_location(loc_str) dat = loc_str.split(/(:|\.\.|-)/) if dat[4] self[:location] = {'chromosome' => dat[0], 'start' => dat[2].to_i, 'stop' => dat[4].to_i} else self[:location] = {'chromosome' => dat[0], 'start' => dat[2].to_i, 'stop' => dat[2].to_i} end end |
#start ⇒ Integer
get the start position of gene rely on the genome
67 68 69 |
# File 'lib/exodb/datamodel/locationfield.rb', line 67 def start self[:location]['start'] end |
#stop ⇒ Integer
get the end position of gene rely on the genome
74 75 76 |
# File 'lib/exodb/datamodel/locationfield.rb', line 74 def stop self[:location]['stop'] end |