Class: Cytogenetics::Chromosome

Inherits:
Object
  • Object
show all
Includes:
BandReader
Defined in:
lib/cytogenetics/chromosome.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BandReader

#bands, #read_file

Constructor Details

#initialize(*args) ⇒ Chromosome

Returns a new instance of Chromosome.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
# File 'lib/cytogenetics/chromosome.rb', line 17

def initialize(*args)
  config_logging()
  chr = args[0]
  chr = chr.to_s  if chr.is_a?Fixnum

  raise ArgumentError, "#{chr} is not a valid chromosome identifier." unless (chr.is_a? String and chr.match(/^\d+|X|Y$/))
  @name = chr
  @aberrations = []
  #@normal_bands = bands(@name, File.open("HsBands.txt", 'r')) if (args.length > 1 and args[1].eql? true) ## TODO quit hardcoding
end

Class Attribute Details

.normal_bandsObject

Returns the value of attribute normal_bands.



12
13
14
# File 'lib/cytogenetics/chromosome.rb', line 12

def normal_bands
  @normal_bands
end

Instance Attribute Details

#aberrationsObject (readonly)

Returns the value of attribute aberrations.



15
16
17
# File 'lib/cytogenetics/chromosome.rb', line 15

def aberrations
  @aberrations
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/cytogenetics/chromosome.rb', line 15

def name
  @name
end

Instance Method Details

#aberration(obj) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cytogenetics/chromosome.rb', line 32

def aberration(obj)
  raise ArgumentError, "Not an Aberration object" unless obj.is_a? Aberration

  #obj.breakpoints.each do |bp|
  #  log.warn("Band #{bp.to_s} doesn't exist. Removing.") if @normal_bands.index(bp.to_s).nil?
  #end

  ## TODO Deal with bands, HOWEVER because the chromosome has aberration objects breakpoints can include
  ## bands for which no chromosome object is created

  #obj.breakpoints.reject {|bp|
  #  @normal_bands.index(bp.to_s).nil?
  #}

  @aberrations << obj
end

#breakpointsObject



49
50
51
52
53
# File 'lib/cytogenetics/chromosome.rb', line 49

def breakpoints
  bps = []
  @aberrations.each { |a| bps << a.breakpoints }
  return bps
end

#config_loggingObject



64
65
66
67
# File 'lib/cytogenetics/chromosome.rb', line 64

def config_logging
  @log = Cytogenetics.logger
  #@log.progname = self.class.name
end

#fragmentsObject



55
56
57
58
59
60
61
# File 'lib/cytogenetics/chromosome.rb', line 55

def fragments
  frags = []
  @aberrations.each do |a|
    frags << a.fragments
  end
  frags
end

#to_sObject



28
29
30
# File 'lib/cytogenetics/chromosome.rb', line 28

def to_s
  "#{@name}"
end