Sha256: c02726e1e9553b66aa185889c14eed0c2f90af7aea3a718c0f5a7ac981d2b69b

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

module BioVcf

  module VcfHeaderParser
    def VcfHeaderParser.get_column_names(lines)
      lines.each do | line |
        if line =~ /^#[^#]/
          # the first line that starts with a single hash 
          names = line.split
          names[0].sub!(/^#/,'')
          return names
        end
      end
      nil
    end
  end

  class VcfHeader

    attr_reader :lines

    def initialize
      @lines = []
    end

    def add line
      @lines << line.strip
    end

    def version
      @version ||= lines[0].scan(/##fileformat=VCFv(\d+\.\d+)/)[0][0]
    end

    def column_names
      @column_names ||= VcfHeaderParser::get_column_names(@lines)
    end

    def columns
      @column ||= column_names.size
    end

    def samples
      @samples ||= column_names[9..-1]
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-vcf-0.0.2 lib/bio-vcf/vcfheader.rb