Class: Mutation

Inherits:
Object
  • Object
show all
Includes:
GenomicLocus, Oncotate
Defined in:
lib/mutation.rb,
lib/oncotator.rb,
lib/mutation_set.rb,
lib/mutation_set.rb

Defined Under Namespace

Modules: Filtering, Oncotate Classes: Collection, Record

Constant Summary collapse

VALID_ALLELE =

This is a generic description of a mutation.

/^[ATGCNatgcn]+$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Oncotate

#discard_onco, #in_cosmic, #inspect, #onco, #to_ot

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?, #size, #union

Constructor Details

#initialize(seqname, pos, ref, alt, ref_count = nil, alt_count = nil) ⇒ Mutation

Returns a new instance of Mutation.



10
11
12
# File 'lib/mutation.rb', line 10

def initialize seqname, pos, ref, alt, ref_count=nil, alt_count=nil
  @seqname, @pos, @ref, @alt, @ref_count, @alt_count = seqname, pos, ref, alt, ref_count, alt_count
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt.



8
9
10
# File 'lib/mutation.rb', line 8

def alt
  @alt
end

#alt_countObject (readonly)

Returns the value of attribute alt_count.



8
9
10
# File 'lib/mutation.rb', line 8

def alt_count
  @alt_count
end

#posObject (readonly) Also known as: start

Returns the value of attribute pos.



8
9
10
# File 'lib/mutation.rb', line 8

def pos
  @pos
end

#refObject (readonly)

Returns the value of attribute ref.



8
9
10
# File 'lib/mutation.rb', line 8

def ref
  @ref
end

#ref_countObject (readonly)

Returns the value of attribute ref_count.



8
9
10
# File 'lib/mutation.rb', line 8

def ref_count
  @ref_count
end

#seqnameObject (readonly)

Returns the value of attribute seqname.



8
9
10
# File 'lib/mutation.rb', line 8

def seqname
  @seqname
end

Instance Method Details

#alt_at(loc) ⇒ Object



37
38
39
40
# File 'lib/mutation.rb', line 37

def alt_at loc
  return nil unless contains? loc
  alt[pos - loc.pos]
end

#is_valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mutation.rb', line 22

def is_valid?
  ref =~ VALID_ALLELE && alt =~ VALID_ALLELE
end

#ref_at(loc) ⇒ Object



26
27
28
29
# File 'lib/mutation.rb', line 26

def ref_at loc
  return nil unless contains? loc
  ref[pos - loc.pos]
end

#stopObject



14
15
16
# File 'lib/mutation.rb', line 14

def stop
  start + ref.size - 1
end

#to_sObject



18
19
20
# File 'lib/mutation.rb', line 18

def to_s
  range.to_s + ":#{ref}-#{alt}"
end

#var_freqObject



31
32
33
34
35
# File 'lib/mutation.rb', line 31

def var_freq
  if ref_count && alt_count
    ref_count / alt_count
  end
end