Class: WigfixParser
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FileParser
get_descendants, load, select, #write_compressed_data
Constructor Details
#initialize(folder, chunk_size) ⇒ WigfixParser
Returns a new instance of WigfixParser.
2
3
4
5
6
|
# File 'lib/anncrsnp/file_parsers/wigfix_parser.rb', line 2
def initialize(folder, chunk_size)
super
@start = 1
@step = 1
end
|
Class Method Details
.available? ⇒ Boolean
8
9
10
|
# File 'lib/anncrsnp/file_parsers/wigfix_parser.rb', line 8
def self.available?
return TRUE
end
|
12
13
14
|
# File 'lib/anncrsnp/file_parsers/wigfix_parser.rb', line 12
def self.format
return 'wigfix'
end
|
Instance Method Details
#get_data ⇒ Object
62
63
64
|
# File 'lib/anncrsnp/file_parsers/wigfix_parser.rb', line 62
def get_data
return @coords
end
|
#parse(line) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/anncrsnp/file_parsers/wigfix_parser.rb', line 16
def parse(line)
if line.include?('fixedStep')
line =~ /fixedStep chrom=(\S+) start=(\d+) step=(\d+)/
if !@chrom.nil? && @chrom != $1 write_compressed_data
@coords = []
end
@chrom = $1
last_start = @start
@start = $2.to_i
diff = @start - last_start if diff >= @chunk_size
(diff/@chunk_size).times do
write_compressed_data
@coords = []
end
else
if @start/@chunk_size != last_start/@chunk_size write_compressed_data
@coords = []
end
end
@step = $3.to_i
else
if @start % @chunk_size == 0 write_compressed_data
@coords = []
end
@coords << [@start, line.to_f]
@start += @step
end
end
|