Class: Cytogenetics::Chromosome
- Inherits:
-
Object
- Object
- Cytogenetics::Chromosome
- Includes:
- BandReader
- Defined in:
- lib/cytogenetics/chromosome.rb
Class Attribute Summary collapse
-
.normal_bands ⇒ Object
Returns the value of attribute normal_bands.
Instance Attribute Summary collapse
-
#aberrations ⇒ Object
readonly
Returns the value of attribute aberrations.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #aberration(obj) ⇒ Object
- #breakpoints ⇒ Object
- #config_logging ⇒ Object
- #fragments ⇒ Object
-
#initialize(*args) ⇒ Chromosome
constructor
A new instance of Chromosome.
- #to_s ⇒ Object
Methods included from BandReader
Constructor Details
#initialize(*args) ⇒ Chromosome
Returns a new instance of Chromosome.
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_bands ⇒ Object
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
#aberrations ⇒ Object (readonly)
Returns the value of attribute aberrations.
15 16 17 |
# File 'lib/cytogenetics/chromosome.rb', line 15 def aberrations @aberrations end |
#name ⇒ Object (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
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 |
#breakpoints ⇒ Object
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_logging ⇒ Object
64 65 66 67 |
# File 'lib/cytogenetics/chromosome.rb', line 64 def config_logging @log = Cytogenetics.logger #@log.progname = self.class.name end |
#fragments ⇒ Object
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_s ⇒ Object
28 29 30 |
# File 'lib/cytogenetics/chromosome.rb', line 28 def to_s "#{@name}" end |