Class: Cytogenetics::ChromosomeAberrations::Derivative

Inherits:
Aberration
  • Object
show all
Defined in:
lib/cytogenetics/chromosome_aberrations.rb

Overview

DERIVATIVE

Instance Attribute Summary

Attributes inherited from Aberration

#ab_objs, #abr, #breakpoints, #fragments

Instance Method Summary collapse

Methods inherited from Aberration

aberration_objs, aberration_type, all_regex, classify_aberration, #config_logging, #find_bands, #find_chr, #find_fragments, #initialize, instantiate_aberrations, regex, #remove_breakpoint, #to_s, type

Constructor Details

This class inherits a constructor from Cytogenetics::Aberration

Instance Method Details

#add_fragments(tbp_list) ⇒ Object

have to reorder the array and then turn Breakpoints into fragments



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cytogenetics/chromosome_aberrations.rb', line 118

def add_fragments(tbp_list)
  sorted = []
  tbp_list.each_with_index do |e, i|
    if i <= 1
      sorted << Breakpoint.new(e.chr, "#{e.arm}ter") if i.eql? 0
      sorted << e
    elsif i%2 == 0
      sorted << tbp_list[i+1]
      sorted << tbp_list[i]
    end
  end
  sorted << Breakpoint.new(sorted[-1].chr, "#{sorted[-1].arm}ter")
  sorted.each_slice(2).to_a.each do |pair|
    @fragments << Fragment.new(pair[0], pair[1])
  end
end

#get_breakpointsObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/cytogenetics/chromosome_aberrations.rb', line 78

def get_breakpoints
  @aberrations = []

  ab_objs = Aberration.aberration_objs

  chr_i = find_chr(@abr)
  derivative_abr = @abr[chr_i[:end_index]+1..@abr.length]

  # separate different abnormalities within the derivative chromosome and clean it up to make it parseable
  abnormalities = derivative_abr.scan(/([^\(\)]+\(([^\(\)]|\)\()*\))/).collect { |a| a[0] }

  trans_bps = []
  abnormalities.each do |abn|
    abrclass = Aberration.classify_aberration(abn)

    if abrclass.to_s.eql? 'unk' # not dealing with unknowns
      @log.warn("Cannot handle #{abn}, incorrect format.")
      next
    end

    # special handling because translocations are written as a sliding window
    # translocations should also only every have 2 breakpoints...
    if abrclass.to_s.eql? ChromosomeAberrations::Translocation.type
      trans = ChromosomeAberrations::Translocation.new(abn)
      trans_bps << trans.breakpoints
      @breakpoints << trans.breakpoints
    else
      ab_obj = ab_objs[abrclass].new(abn)
      if ab_obj.breakpoints.length > 0
        @aberrations << ab_obj
        @breakpoints << ab_obj.breakpoints
      end
    end
  end
  trans_bps.delete_if { |c| c.empty? }
  add_fragments(trans_bps.flatten!) if trans_bps.length > 0
end