| 1 |
Given(/^the VCF line$/) do |string| |
| 2 |
@header = VcfHeader.new |
| 3 |
@header.add("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSample") |
| 4 |
@vcfline = string |
| 5 |
end |
| 6 |
|
| 7 |
When(/^I evaluate '([^']+)'$/) do |arg1| |
| 8 |
# concat VCF line with sample (arg1) |
| 9 |
@fields = VcfLine.parse((@vcfline.split(/\s+/)+[arg1]).join("\t")) |
| 10 |
@rec = VcfRecord.new(@fields,@header) |
| 11 |
p @rec |
| 12 |
@g = @rec.sample['Sample'] |
| 13 |
p @g |
| 14 |
expect(@g).not_to be nil |
| 15 |
@s = VcfSample::Sample.new(@rec,@g) |
| 16 |
@ignore_missing = false |
| 17 |
end |
| 18 |
|
| 19 |
Then(/^I expect s\.empty\? to be false$/) do |
| 20 |
expect(@s.empty?).to be false |
| 21 |
expect(@s.sfilter("s.empty?",do_cache: false)).to be false |
| 22 |
end |
| 23 |
|
| 24 |
Then(/^I expect s\.dp\? to be true$/) do |
| 25 |
p ['eval s.dp?',@s.eval("s.dp?",do_cache: false)] |
| 26 |
p ['eval s.dp',@s.eval("s.dp",do_cache: false)] |
| 27 |
p @g.dp |
| 28 |
p @s.dp |
| 29 |
p @s.sfilter("s.dp?",do_cache: false) |
| 30 |
expect(@s.eval("s.dp?",do_cache: false)).to be true |
| 31 |
end |
| 32 |
|
| 33 |
Then(/^I expect s\.dp to be (\d+)$/) do |arg1| |
| 34 |
# p @s.eval("s.dp") |
| 35 |
p :now |
| 36 |
p ['eval s.dp?',@s.eval("s.dp?",do_cache: false)] |
| 37 |
p ['eval s.dp',@s.eval("s.dp",do_cache: false)] |
| 38 |
expect(@s.eval("s.dp",do_cache: false)).to equal arg1.to_i |
| 39 |
end |
| 40 |
|
| 41 |
Then(/^sfilter 's\.dp>(\d+)' to be true$/) do |arg1| |
| 42 |
expect(@s.sfilter("dp>#{arg1}",do_cache: false)).to be true |
| 43 |
end |
| 44 |
|
| 45 |
When(/^I evaluate missing '([^']+)'$/) do |arg1| |
| 46 |
# concat VCF line with sample (arg1) |
| 47 |
@fields = VcfLine.parse((@vcfline.split(/\s+/)+[arg1]).join("\t")) |
| 48 |
@rec = VcfRecord.new(@fields,@header) |
| 49 |
p @rec |
| 50 |
@g = @rec.sample['Sample'] |
| 51 |
@s = VcfSample::Sample.new(@rec,@g) |
| 52 |
p @s |
| 53 |
expect(@s).not_to be nil |
| 54 |
@ignore_missing = false |
| 55 |
end |
| 56 |
|
| 57 |
Then(/^I expect s\.dp\? to be false$/) do |
| 58 |
expect(@s.eval("s.dp?",do_cache: false)).to be false |
| 59 |
end |
| 60 |
|
| 61 |
Then(/^I expect s\.dp to be nil$/) do |
| 62 |
expect(@s.eval("s.dp",ignore_missing_data: @ignore_missing, do_cache: false)).to be nil |
| 63 |
end |
| 64 |
|
| 65 |
Then(/^sfilter 's\.dp>(\d+)' to throw an error$/) do |arg1| |
| 66 |
expect { @s.eval("s.dp>#{arg1}",do_cache: false) }.to raise_error NoMethodError |
| 67 |
end |
| 68 |
|
| 69 |
Then(/^sfilter 's\.dp>(\d+)' to be false$/) do |arg1| |
| 70 |
expect(@s.sfilter("s.dp>#{arg1}",ignore_missing_data: @ignore_missing, do_cache: false)).to be false |
| 71 |
end |
| 72 |
|
| 73 |
When(/^I evaluate empty '\.\/\.'$/) do |
| 74 |
# concat VCF line with sample (arg1) |
| 75 |
@fields = VcfLine.parse((@vcfline.split(/\s+/)+['./.']).join("\t")) |
| 76 |
@rec = VcfRecord.new(@fields,@header) |
| 77 |
p @rec |
| 78 |
@g = @rec.sample['Sample'] |
| 79 |
@s = VcfSample::Sample.new(@rec,@g) |
| 80 |
p @s |
| 81 |
expect(@s).not_to be nil |
| 82 |
@ignore_missing = false |
| 83 |
end |
| 84 |
|
| 85 |
When(/^I evaluate missing '([^']+)' with ignore missing$/) do |arg1| |
| 86 |
# concat VCF line with sample (arg1) |
| 87 |
@fields = VcfLine.parse((@vcfline.split(/\s+/)+[arg1]).join("\t")) |
| 88 |
@rec = VcfRecord.new(@fields,@header) |
| 89 |
p @rec |
| 90 |
@g = @rec.sample['Sample'] |
| 91 |
@s = VcfSample::Sample.new(@rec,@g) |
| 92 |
p @s |
| 93 |
expect(@s).not_to be nil |
| 94 |
@ignore_missing = true |
| 95 |
end |
| 96 |
|
| 97 |
Then(/^I expect s\.empty\? to be true$/) do |
| 98 |
expect(@s.sfilter("s.empty?",do_cache: false)).to be true |
| 99 |
end |
| 100 |
|
| 101 |
Then(/^I expect s\.dp to throw an error$/) do |
| 102 |
# @s.instance_eval { undef :dp } |
| 103 |
p @s.eval("s.dp",do_cache: false) |
| 104 |
expect { @s.eval("s.dp",do_cache: false) }.to raise_error NoMethodError |
| 105 |
end |
| 106 |
|
| 107 |
When(/^I evaluate empty '\.\/\.' with ignore missing$/) do |
| 108 |
# concat VCF line with sample (arg1) |
| 109 |
@fields = VcfLine.parse((@vcfline.split(/\s+/)+['./.']).join("\t")) |
| 110 |
@rec = VcfRecord.new(@fields,@header) |
| 111 |
p @rec |
| 112 |
@g = @rec.sample['Sample'] |
| 113 |
@s = VcfSample::Sample.new(@rec,@g) |
| 114 |
p @s |
| 115 |
expect(@s).not_to be nil |
| 116 |
@ignore_missing = true |
| 117 |
end |
| 118 |
|
| 119 |
Then(/^I expect s\.what\? to throw an error$/) do |
| 120 |
expect { @s.eval("s.what?",do_cache: false) }.to raise_error NoMethodError |
| 121 |
end |
| 122 |
|
| 123 |
Then(/^I expect s\.what to throw an error$/) do |
| 124 |
expect { @s.eval("s.what",do_cache: false) }.to raise_error NoMethodError |
| 125 |
end |
| 126 |
|
| 127 |
Then(/^I expect r\.chrom to be "(.*?)"$/) do |arg1| |
| 128 |
expect(@s.eval("r.chrom",do_cache: false)).to eq "1" |
| 129 |
end |
| 130 |
|
| 131 |
Then(/^I expect r\.alt to be \["(.*?)"\]$/) do |arg1| |
| 132 |
expect(@s.eval("r.alt",do_cache: false)).to eq ["G"] |
| 133 |
end |
| 134 |
|
| 135 |
Then(/^I expect r\.info\.af to be (\d+)\.(\d+)$/) do |arg1, arg2| |
| 136 |
expect(@s.eval("r.info.af",do_cache: false)).to eq 0.667 |
| 137 |
end |
| 138 |
|
| 139 |
|