Method: Bio::Locations#relative
- Defined in:
- lib/bio/location.rb
#relative(n, type = nil) ⇒ Object
Converts absolute position in the whole of the DNA sequence to relative position in the locus.
This method can for example be used to relate positions in a DNA-sequence with those in RNA. In this use, the optional ‘:aa’-flag returns the position of the associated amino-acid rather than the nucleotide.
loc = Bio::Locations.new('complement(12838..13533)')
puts loc.relative(13524) # => 10
puts loc.relative(13506, :aa) # => 3
Arguments:
-
(required) position: nucleotide position within whole of the sequence
-
:aa: flag that lets method return position in aminoacid coordinates
- Returns
-
position within the location
385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/bio/location.rb', line 385 def relative(n, type = nil) case type when :location ; when :aa if n = abs2rel(n) (n - 1) / 3 + 1 else nil end else abs2rel(n) end end |