Sha256: 1247e0d4796c0189b083d3323246055f33682e466379819453a920936cdacd77

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

require_relative '../support'
require_relative '../parsers/string_parser'

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

    def row_pat
      /[\w\d]+ (?<row>(#{number_pat} )*#{number_pat})\n?/
    end

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

    def parse_matrix
      matrix = []
      while row_string = scan_row
        matrix << split_row(row_string)[0,4]
      end
      matrix.transpose
    end

    def parse!
      scan_any_spaces
      scan_splitter
      name = parse_name
      matrix = parse_matrix
      Parser.parse!(matrix).tap{|result| result.name = name}
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bioinform-0.1.17 lib/bioinform/parsers/string_fantom_parser.rb
bioinform-0.1.16 lib/bioinform/parsers/string_fantom_parser.rb
bioinform-0.1.15 lib/bioinform/parsers/string_fantom_parser.rb
bioinform-0.1.14 lib/bioinform/parsers/string_fantom_parser.rb
bioinform-0.1.13 lib/bioinform/parsers/string_fantom_parser.rb