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

Instance Method Details

#beginInteger

get the start position of gene rely on the genome

Returns:

  • (Integer)

    start position of gene



81
82
83
# File 'lib/exodb/datamodel/locationfield.rb', line 81

def begin
	self[:strand] == '+' ? self[:location]['start'] : self[:location]['stop']
end

#chromosomeInteger

get the chromosome

Returns:

  • (Integer)

    chromosome



95
96
97
# File 'lib/exodb/datamodel/locationfield.rb', line 95

def chromosome
	self[:location]['chromosome']
end

#endInteger

get the start position of gene rely on the genome

Returns:

  • (Integer)

    start position of gene



88
89
90
# File 'lib/exodb/datamodel/locationfield.rb', line 88

def end
	self[:strand] == '+' ? self[:location]['stop'] : self[:location]['start']
end

#location_strObject



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

Parameters:

  • gene (String)

    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

#startInteger

get the start position of gene rely on the genome

Returns:

  • (Integer)

    start position of gene



67
68
69
# File 'lib/exodb/datamodel/locationfield.rb', line 67

def start
	self[:location]['start']
end

#stopInteger

get the end position of gene rely on the genome

Returns:

  • (Integer)

    end position of gene



74
75
76
# File 'lib/exodb/datamodel/locationfield.rb', line 74

def stop
	self[:location]['stop']
end