cytogenetics 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cytogenetics.rb +19 -1
- data/lib/cytogenetics/aberration.rb +6 -6
- data/lib/cytogenetics/breakpoint.rb +1 -1
- data/lib/cytogenetics/chromosome.rb +4 -1
- data/lib/cytogenetics/chromosome_aberrations.rb +2 -2
- data/lib/cytogenetics/fragment.rb +1 -1
- data/lib/cytogenetics/karyotype.rb +4 -3
- data/lib/cytogenetics/utils/band_reader.rb +1 -0
- data/lib/cytogenetics/utils/karyotype_reader.rb +0 -1
- data/lib/cytogenetics/version.rb +2 -2
- metadata +1 -2
- data/lib/cytogenetics/karyotype_error.rb +0 -4
data/lib/cytogenetics.rb
CHANGED
@@ -4,7 +4,7 @@ require 'cytogenetics/chromosome'
|
|
4
4
|
require 'cytogenetics/chromosome_aberrations'
|
5
5
|
require 'cytogenetics/fragment'
|
6
6
|
require 'cytogenetics/karyotype'
|
7
|
-
require 'cytogenetics/karyotype_error'
|
7
|
+
#require 'cytogenetics/karyotype_error'
|
8
8
|
|
9
9
|
|
10
10
|
require 'cytogenetics/utils/karyotype_reader'
|
@@ -27,10 +27,28 @@ module Cytogenetics
|
|
27
27
|
end
|
28
28
|
@clog
|
29
29
|
end
|
30
|
+
|
31
|
+
#def haploid=(hp)
|
32
|
+
# @sp_ploidy=hp
|
33
|
+
#end
|
34
|
+
#
|
35
|
+
#def haploid
|
36
|
+
# unless @sp_ploidy
|
37
|
+
#
|
38
|
+
# end
|
39
|
+
#end
|
40
|
+
|
30
41
|
end
|
31
42
|
|
32
43
|
def self.karyotype(kary_str)
|
33
44
|
return Karyotype.new(kary_str)
|
34
45
|
end
|
35
46
|
|
47
|
+
|
48
|
+
class StructureError < StandardError
|
49
|
+
end
|
50
|
+
|
51
|
+
class KaryotypeError < StandardError
|
52
|
+
end
|
53
|
+
|
36
54
|
end
|
@@ -60,7 +60,7 @@ module Cytogenetics
|
|
60
60
|
|
61
61
|
#regex = Aberration.regex[@type.to_sym]
|
62
62
|
# make sure it really is an inversion first
|
63
|
-
#raise
|
63
|
+
#raise StructureError, "#{str} does not appear to be a #{self.class}" unless str.match(self.regex)
|
64
64
|
get_breakpoints() #(@abr)
|
65
65
|
@breakpoints.flatten!
|
66
66
|
end
|
@@ -102,7 +102,7 @@ module Cytogenetics
|
|
102
102
|
chrs = str[chr_s+1..chr_e-1].split(/;|:/)
|
103
103
|
chrs.each do |chr|
|
104
104
|
unless chr.match(/^\d+|X|Y$/)
|
105
|
-
log.warn("No chromosome defined from #{str}, skipped.")
|
105
|
+
@log.warn("No chromosome defined from #{str}, skipped.")
|
106
106
|
return
|
107
107
|
end
|
108
108
|
end
|
@@ -111,9 +111,9 @@ module Cytogenetics
|
|
111
111
|
|
112
112
|
def find_bands(str, index)
|
113
113
|
band_info = nil
|
114
|
-
#raise
|
114
|
+
#raise StructureError, "No bands defined in #{str}" if str.length.eql?(index+1)
|
115
115
|
if str.length.eql?(index+1)
|
116
|
-
log.warn("No bands defined in #{str}, skipped.")
|
116
|
+
@log.warn("No bands defined in #{str}, skipped.")
|
117
117
|
return
|
118
118
|
end
|
119
119
|
|
@@ -125,13 +125,13 @@ module Cytogenetics
|
|
125
125
|
bands = str[band_s+1..band_e-1].split(/;|:/)
|
126
126
|
|
127
127
|
if str[band_s+1..band_e-1].match(/::/)
|
128
|
-
log.warn("Aberration defined using different language, not currently parsed skipping: #{@abr}")
|
128
|
+
@log.warn("Aberration defined using different language, not currently parsed skipping: #{@abr}")
|
129
129
|
return band_info
|
130
130
|
else
|
131
131
|
bands.map! { |b| b.sub(/-[q|p]\d+$/, "") } # sometimes bands are given a range, for our purposes we'll take the first one (CyDas appears to do this as well)
|
132
132
|
bands.each do |b|
|
133
133
|
unless b.match(/^[p|q]\d+(\.\d)?$/)
|
134
|
-
log.warn("Bands incorrectly defined in #{str}")
|
134
|
+
@log.warn("Bands incorrectly defined in #{str}")
|
135
135
|
return band_info
|
136
136
|
end
|
137
137
|
end
|
@@ -11,7 +11,7 @@ module Cytogenetics
|
|
11
11
|
|
12
12
|
unless ((c.is_a? String and c.match(/\d+|X|Y/)) and (b.is_a? String and b.length > 0))
|
13
13
|
@log.error("#{c}#{b} is not a valid breakpoint")
|
14
|
-
raise
|
14
|
+
raise StructureError, "#{c}#{b} is not a valid breakpoint"
|
15
15
|
end
|
16
16
|
@chr = c; @band = b
|
17
17
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'cytogenetics/utils/band_reader'
|
2
2
|
|
3
|
+
File.expand_path '../../resources', File.dirname(__FILE__)
|
4
|
+
|
5
|
+
|
3
6
|
module Cytogenetics
|
4
7
|
|
5
8
|
class Chromosome
|
@@ -19,7 +22,7 @@ module Cytogenetics
|
|
19
22
|
raise ArgumentError, "#{chr} is not a valid chromosome identifier." unless (chr.is_a? String and chr.match(/^\d+|X|Y$/))
|
20
23
|
@name = chr
|
21
24
|
@aberrations = []
|
22
|
-
|
25
|
+
#@normal_bands = bands(@name, File.open("HsBands.txt", 'r')) if (args.length > 1 and args[1].eql? true) ## TODO quit hardcoding
|
23
26
|
end
|
24
27
|
|
25
28
|
def to_s
|
@@ -91,7 +91,7 @@ module Cytogenetics
|
|
91
91
|
abrclass = Aberration.classify_aberration(abn)
|
92
92
|
|
93
93
|
if abrclass.to_s.eql? 'unk' # not dealing with unknowns
|
94
|
-
log.warn("Cannot handle #{abn}, incorrect format.")
|
94
|
+
@log.warn("Cannot handle #{abn}, incorrect format.")
|
95
95
|
next
|
96
96
|
end
|
97
97
|
|
@@ -145,7 +145,7 @@ module Cytogenetics
|
|
145
145
|
chr_i = find_chr(@abr)
|
146
146
|
band_i = find_bands(@abr, chr_i[:end_index])
|
147
147
|
unless band_i
|
148
|
-
log.warn("No bands defined in #{@abr}")
|
148
|
+
@log.warn("No bands defined in #{@abr}")
|
149
149
|
else
|
150
150
|
chr_i[:chr].each_with_index do |c, i|
|
151
151
|
@breakpoints << Breakpoint.new(c, band_i[:bands][i], 'trans')
|
@@ -16,7 +16,7 @@ module Cytogenetics
|
|
16
16
|
@chr = @start.chr
|
17
17
|
|
18
18
|
unless @start.chr.eql? @end.chr
|
19
|
-
raise
|
19
|
+
raise StructureError, "Fragments must be within the same chromosome: #{args}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -8,7 +8,7 @@ module Cytogenetics
|
|
8
8
|
|
9
9
|
@@haploid = 23
|
10
10
|
|
11
|
-
attr_reader :aberrations, :karyotype, :ploidy, :sex, :abnormal_chr, :normal_chr
|
11
|
+
attr_reader :aberrations, :karyotype, :ploidy, :sex, :abnormal_chr, :normal_chr, :original_karyotype
|
12
12
|
|
13
13
|
class<<self
|
14
14
|
attr_accessor :aberration_objs, :unclear_aberrations, :log
|
@@ -20,6 +20,7 @@ module Cytogenetics
|
|
20
20
|
@log.info("Reading karyotype #{karyotype_str}")
|
21
21
|
|
22
22
|
@karyotype = karyotype_str.gsub(/\s/, "")
|
23
|
+
@original_karyotype = @karyotype # just to keep it around before it gets cleaned up
|
23
24
|
@normal_chr = {}; @abnormal_chr = {}; @aberrations = {}; @unclear_aberrations = [];
|
24
25
|
setup_abberation_objs()
|
25
26
|
prep_karyotype()
|
@@ -117,10 +118,10 @@ module Cytogenetics
|
|
117
118
|
# determine ploidy & gender, clean up each aberration and drop any "unknown"
|
118
119
|
def prep_karyotype
|
119
120
|
@karyotype.gsub!(/\s/, "")
|
120
|
-
clones = @karyotype.scan(/(\[\
|
121
|
+
clones = @karyotype.scan(/(\[\w+\])/).collect { |a| a[0] }
|
121
122
|
@log.warn("Karyotype is a collection of clones, analysis may be inaccurate.") if clones.length > 3
|
122
123
|
|
123
|
-
@karyotype.gsub!(/\[\
|
124
|
+
@karyotype.gsub!(/\[\w+\]/, "") # don't care about numbers of cells: [5] or [cp10], there are some other problematic things in [] but they are just being ignored currently
|
124
125
|
|
125
126
|
(pl, sc) = @karyotype.split(",")[0..1]
|
126
127
|
if (pl and sc)
|
data/lib/cytogenetics/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cytogenetics
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
2
|
+
VERSION = '0.0.2'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cytogenetics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -25,7 +25,6 @@ files:
|
|
25
25
|
- lib/cytogenetics/chromosome_aberrations.rb
|
26
26
|
- lib/cytogenetics/fragment.rb
|
27
27
|
- lib/cytogenetics/karyotype.rb
|
28
|
-
- lib/cytogenetics/karyotype_error.rb
|
29
28
|
- lib/cytogenetics/utils/band_reader.rb
|
30
29
|
- lib/cytogenetics/utils/karyotype_reader.rb
|
31
30
|
- lib/cytogenetics/version.rb
|