Sha256: 688d47fb111f8e0b28e73497bf7ac52f66cf990c1a224af172aa7d91a13cbba4

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

module BioVcf

  module VcfRecordParser
    def VcfRecordParser.get_format s
      h = {}
      s.split(/:/).each_with_index { |v,i| h[v] = i }
      h
    end
  end

  class VcfRecord

    def initialize fields, header
      @header = header
      @fields = fields
    end
     
    def chrom
      @fields[0]
    end

    def pos
      @pos ||= @fields[1].to_i
    end

    def ids 
      @ids ||= @fields[2].split(';')
    end

    def id
      ids[0]
    end

    def ref
      @refs ||= @fields[3]
    end

    def alt
      @alt ||= @fields[4]
    end

    def format
      @format ||= VcfRecordParser.get_format(@fields[8])
    end

    def normal
      @normal ||= VcfGenotypeField.new(@fields[9],format,@header)
    end

    def tumor
      @tumor ||= VcfGenotypeField.new(@fields[10],format,@header)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-vcf-0.0.1 lib/bio-vcf/vcfrecord.rb