Class: Bio::DB::Fasta::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/fastadb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, length, offset = 0, line_bases = 0, line_length = 0) ⇒ Entry

Returns a new instance of Entry.



50
51
52
53
54
55
56
# File 'lib/bio/db/fastadb.rb', line 50

def initialize(id, length, offset = 0 , line_bases= 0 , line_length = 0 )
  @id=id
  @length=length.to_i
  @offset = offset.to_i
  @line_bases  = line_bases.to_i
  @line_length = line_length.to_i
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



48
49
50
# File 'lib/bio/db/fastadb.rb', line 48

def id
  @id
end

#lengthObject (readonly) Also known as: size

Returns the value of attribute length.



48
49
50
# File 'lib/bio/db/fastadb.rb', line 48

def length
  @length
end

#line_basesObject (readonly)

Returns the value of attribute line_bases.



48
49
50
# File 'lib/bio/db/fastadb.rb', line 48

def line_bases
  @line_bases
end

#line_lengthObject (readonly)

Returns the value of attribute line_length.



48
49
50
# File 'lib/bio/db/fastadb.rb', line 48

def line_length
  @line_length
end

#offsetObject (readonly)

Returns the value of attribute offset.



48
49
50
# File 'lib/bio/db/fastadb.rb', line 48

def offset
  @offset
end

Instance Method Details

#get_base_coordinate(coordinate) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bio/db/fastadb.rb', line 58

def get_base_coordinate(coordinate)
  lines_for_offset = coordinate / line_bases
  line_offset = coordinate % line_bases
  #puts "get_base_coordinate"
  #puts "Coordinate: #{coordinate}"
  #puts "lines_for_offset: #{lines_for_offset}"
  #puts "line pffset: #{line_offset}"
  #puts self.inspect
  pointer = offset + (line_length * lines_for_offset) + line_offset - 1
  pointer
end

#get_full_regionObject Also known as: to_region



70
71
72
73
74
75
76
77
# File 'lib/bio/db/fastadb.rb', line 70

def get_full_region
  reg = Region.new
  reg.entry = id
  reg.start = 1
  reg.end = @length
  reg.orientation = :forward
  reg
end