Class: Bioinform::StringFantomParser
Instance Attribute Summary
Attributes inherited from StringParser
#row_acgt_markers, #scanner
Attributes inherited from Parser
#input
Instance Method Summary
collapse
#initialize, #number_pat, #parse_acgt_header, #parse_name, #scan_any_spaces, #scan_row, #scanner_reset, #split_row
Methods inherited from Parser
array_from_acgt_hash, choose, #initialize, need_tranpose?, normalize_hash_keys, parse, #parse, parse!, transform_input, try_convert_to_array, valid_matrix?
#each, included
Instance Method Details
6
7
8
|
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 6
def
/NA (?<name>[\w.+:-]+)\n[\w\d]+ A C G T.*\n/
end
|
26
27
28
29
30
31
32
|
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 26
def parse!
scan_any_spaces
scan_splitter
name = parse_name
matrix = parse_matrix
Parser.parse!(matrix).tap{|result| result.name = name}
end
|
#parse_matrix ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 18
def parse_matrix
matrix = []
while row_string = scan_row
matrix << split_row(row_string)[0,4]
end
matrix.transpose
end
|
10
11
12
|
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 10
def row_pat
/[\w\d]+ (?<row>(#{number_pat} )*#{number_pat})\n?/
end
|
#scan_splitter ⇒ Object
14
15
16
|
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 14
def scan_splitter
scanner.scan(/(\/\/\n)+/)
end
|