Class: BioMummer::Alignment

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-mummer/mummer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(refname, qryname, refstart, refstop, qrystart, qrystop, strand, distances) ⇒ Alignment

Returns a new instance of Alignment.



8
9
10
11
12
13
14
15
16
17
# File 'lib/bio-mummer/mummer.rb', line 8

def initialize(refname, qryname, refstart, refstop, qrystart, qrystop, strand, distances)
  @refname = refname
  @qryname = qryname
  @refstart = refstart
  @refstop = refstop
  @qrystart = qrystart
  @qrystop = qrystop
  @strand = strand
  @distances = distances
end

Instance Attribute Details

#distancesObject

Returns the value of attribute distances.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def distances
  @distances
end

#qrynameObject

Returns the value of attribute qryname.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def qryname
  @qryname
end

#qrystartObject

Returns the value of attribute qrystart.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def qrystart
  @qrystart
end

#qrystopObject

Returns the value of attribute qrystop.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def qrystop
  @qrystop
end

#refnameObject

Returns the value of attribute refname.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def refname
  @refname
end

#refstartObject

Returns the value of attribute refstart.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def refstart
  @refstart
end

#refstopObject

Returns the value of attribute refstop.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def refstop
  @refstop
end

#strandObject

Returns the value of attribute strand.



6
7
8
# File 'lib/bio-mummer/mummer.rb', line 6

def strand
  @strand
end

Instance Method Details

#deltasObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bio-mummer/mummer.rb', line 19

def deltas
  ds = []
  a = @distances.each_with_object([0]) do |d, arr|
    state = arr.last
    if d > 0
      ds += Array.new(d - 1, state)
      ds.push(nil)
      arr << state - 1
    else
      ds += Array.new(d * -1 - 1, state)
      arr << state + 1
    end
  end
  ds << a.last
  return ds
end

#ref_to_query(ref_position) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/bio-mummer/mummer.rb', line 36

def ref_to_query(ref_position)
  position_in_alignment = ref_position - refstart + 1
  qrypos = nil
  if position_in_alignment >= deltas.length
    qrypos = @qrystart - 1 + position_in_alignment + deltas.last
  elsif deltas[position_in_alignment-1]
    qrypos = @qrystart - 1 + position_in_alignment + deltas[position_in_alignment-1]
  end
  !@strand && qrypos ? @qrystart + @qrystop - qrypos : qrypos
end