Class: Bioinform::StringFantomParser

Inherits:
StringParser show all
Defined in:
lib/bioinform/parsers/string_fantom_parser.rb

Instance Attribute Summary

Attributes inherited from StringParser

#row_acgt_markers, #scanner

Attributes inherited from Parser

#input

Instance Method Summary collapse

Methods inherited from StringParser

#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?

Methods included from Parser::SingleMotifParser

#each, included

Constructor Details

This class inherits a constructor from Bioinform::StringParser

Instance Method Details

#header_patObject



6
7
8
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 6

def header_pat
  /NA (?<name>[\w.+:-]+)\n[\w\d]+ A C G T.*\n/
end

#parse!Object



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_matrixObject



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

#row_patObject



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_splitterObject



14
15
16
# File 'lib/bioinform/parsers/string_fantom_parser.rb', line 14

def scan_splitter
  scanner.scan(/(\/\/\n)+/)
end