lib/bio-vcf/vcfsample.rb in bio-vcf-0.9.0 vs lib/bio-vcf/vcfsample.rb in bio-vcf-0.9.2

- old
+ new

@@ -41,9 +41,22 @@ def gti v = fetch_values("GT") v.split(/[\/\|]/).map{ |v| (v=='.' ? nil : v.to_i) } end + def gtindex + v = fetch_values("GT") + return case v + when nil then nil + when './.' then nil + when '0/0' then 0 + when '0/1' then 1 + when '1/1' then 2 + else + raise "Unknown genotype #{v}" + end + end + # Split GT into into a nucleode sequence def gts gti.map { |i| (i ? @rec.get_gt(i) : nil) } end