class Cytogenetics::ChromosomeAberrations::Derivative
DERIVATIVE
Public Instance Methods
add_fragments(tbp_list)
click to toggle source
have to reorder the array and then turn Breakpoints into fragments
# 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_breakpoints()
click to toggle source
# 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