Class: Fasta::Chrom

Inherits:
Object
  • Object
show all
Includes:
GenomicLocus
Defined in:
lib/fasta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GenomicLocus

#default_stop, #loc, #long_chrom, #range, #short_chrom

Methods included from IntervalList::Interval

#above?, #below?, #center, #clone, #contains?, #diff, #dist, #intersect, #overlaps?, #union

Constructor Details

#initialize(n, fasta, sz, st, t) ⇒ Chrom

Returns a new instance of Chrom.



37
38
39
40
41
42
# File 'lib/fasta.rb', line 37

def initialize n, fasta, sz, st, t
  @seqname, @fasta, @size, @byte_start, @total = n, fasta, sz, st, t
  # truncate the name
  @seqname = short_chrom
  @start = 1
end

Instance Attribute Details

#centromereObject (readonly)

Returns the value of attribute centromere.



34
35
36
# File 'lib/fasta.rb', line 34

def centromere
  @centromere
end

#seqnameObject (readonly)

Returns the value of attribute seqname.



34
35
36
# File 'lib/fasta.rb', line 34

def seqname
  @seqname
end

#sizeObject (readonly) Also known as: stop

Returns the value of attribute size.



34
35
36
# File 'lib/fasta.rb', line 34

def size
  @size
end

#startObject (readonly) Also known as: pos

Returns the value of attribute start.



34
35
36
# File 'lib/fasta.rb', line 34

def start
  @start
end

#totalObject (readonly)

Returns the value of attribute total.



34
35
36
# File 'lib/fasta.rb', line 34

def total
  @total
end

Instance Method Details

#file_pos(pos) ⇒ Object



44
45
46
47
# File 'lib/fasta.rb', line 44

def file_pos pos
  return nil if !contains? pos
  @byte_start + pos/line_size*(line_size+1) + (pos % line_size) - 1 - ((pos % line_size == 0) ? 1 : 0)
end

#pObject



53
54
55
56
57
# File 'lib/fasta.rb', line 53

def p
  if @centromere
    @p ||= GenomicLocus::Region.new @seqname, 1, @centromere
  end
end

#qObject



59
60
61
62
63
# File 'lib/fasta.rb', line 59

def q
  if @centromere
    @q ||= GenomicLocus::Region.new @seqname, @centromere+1, stop
  end
end

#set_cen_pos(pos) ⇒ Object



49
50
51
# File 'lib/fasta.rb', line 49

def set_cen_pos pos
  @centromere = pos
end