You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Add support for streaming .vcf.gz / .vcf.bgz inputs via gunzip/unpigz (no new dependencies)
-Ensure proper filehandle cleanup (close on input/output)
-Initialize $max to avoid undefined comparison warnings
-Minor robustness improvements to input handling and stability
print"Inferring ancestry using SNVs (single nucleotide variants)...\n\n";
79
92
80
-
while(<IN>){
93
+
while(<$IN>){
81
94
chomp;
82
95
my@a=split(/\t/);
83
-
my$max;
96
+
my$max = -1;###never previously initialized
84
97
my$maxpop;
85
98
86
99
if(/_AF/){
@@ -113,23 +126,25 @@ sub usage_page {
113
126
$z->{$a[0]}{$wn}{$pop}{'sum'}+=$afallele;
114
127
$y->{$a[0]}{$wn}{'ct'}++;
115
128
116
-
117
129
if($afallele){
118
130
$s->{$d[0]}{'ct'}++;
119
131
$z->{$a[0]}{$wn}{$pop}{'nzct'}++;
120
132
if($a[1]>$max){
121
133
$max=$a[1];
122
134
$maxpop=$pop;
123
135
}
124
-
} else{
125
-
$afallele=1;
136
+
#} else{### Remove dead $afallele=1 line (not used)
137
+
# $afallele=1;
126
138
}
127
139
}
128
140
}
129
141
}
130
142
}
131
143
}
132
144
}
145
+
146
+
close$IN;
147
+
133
148
###calculate metric per tile
134
149
my$top;
135
150
my$total;
@@ -149,11 +164,13 @@ sub usage_page {
149
164
my$wnl=$z->{$el};
150
165
foreachmy$wnum(sort {$a<=>$b} keys%$wnl){
151
166
my$pl = $wnl->{$wnum};
152
-
my$winmax;
167
+
my$winmax = -1;###was never initialized
153
168
my$winpop;
154
169
my$window_population_metric;
155
170
print"WARNING: chr$el tile$wnum has $y->{$el}{$wnum}{'ct'} only total SNVs -- you may need to increase the tile size (currently set at $dw)\n"if($y->{$el}{$wnum}{'ct'}<100);
156
171
foreachmy$pp(keys%$pl){
172
+
my$ct = $y->{$el}{$wnum}{'ct'} || 0;###guards div by zero
0 commit comments