-
Notifications
You must be signed in to change notification settings - Fork 2
/
fannotatesnpswithgenes
executable file
·572 lines (505 loc) · 21.2 KB
/
fannotatesnpswithgenes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#!/usr/bin/perl
use warnings;
use DBI;
use DBD::mysql;
use strict;
use fralib;
use File::Basename;
use Getopt::Long;
use Pod::Usage;
use POSIX qw(ceil floor);
=head1 NAME
fannotatesnpswithgenes
=head1 SYNOPSIS
fannotatesnpswithgenes [options] <mk-file>
-h help
-b build version (hg17|hg18)
-w window size (10000 default) [0,1M]
--mask mask unannotated SNPs (default off)
mk-file marker file
a)snp-id
b)chromosome
c)position
example: fannotatesnpswithgenes pscalare.mk -b hg17 -w 10000
Annotations are based on UCSC tables and GO database.
Returns a marker file - gene-annotated-<mk-file>
a)snp-id : SNP name
b)chromosome : chromosome where SNP is located
c)position : position of SNP
d)known-gene-id : gene ID in the known/UCSC gene table (UCSC)
e)entrez-id : entrez gene id (UCSC)
f)gene-strand : strand of gene (UCSC)
g)tx-start : transcription start position (UCSC)
h)tx-end : transcription end position (UCSC)
i)consequence : location of SNP wrt Gene
j)gene-symbol : gene symbol (UCSC)
k)gene-description : gene description (UCSC)
l)pathway : KEGG pathway description (UCSC)
m)biological-process : GO category
n)molecular-function : GO category
o)cellular-component : GO category
=head1 DESCRIPTION
=cut
#option variables
my $help;
my $build = 'hg18';
my $mkFile;
my $windowSize = 10000;
my $maskUnannotatedSNPs = 0;
my $colNo;
my $headerProcessed;
my %SNP;
my %CHROM;
my %GENE;
my %label2Column;
my $annotationCount = 0;
#initialize options
Getopt::Long::Configure ('bundling');
if(!GetOptions ('h'=>\$help, 'b=s'=>\$build, 'w=i'=>\$windowSize, 'mask'=>\$maskUnannotatedSNPs)
|| $build !~ /(hg17|hg18)/
|| $windowSize < 0
|| $windowSize > 1000000
|| scalar(@ARGV)!=1)
{
if ($help)
{
pod2usage(-verbose => 2);
}
else
{
pod2usage(1);
}
}
$mkFile = $ARGV[0];
print STDERR <<SUMMARY;
=======
Options
=======
Build: $build
Window Size: $windowSize
Mask: $maskUnannotatedSNPs
=======
SUMMARY
print STDERR "Reading $mkFile\n";
open(MK, $mkFile) || die "Cannot open $mkFile";
$headerProcessed = 0;
while(<MK>)
{
s/\r?\n?$//;
if(!$headerProcessed)
{
$colNo = s/\t/\t/g + 1;
my @fields = split('\t', $_, $colNo);
SEARCH_LABEL: for my $label('snp-id', 'chromosome', 'position')
{
for my $col (0 .. $#fields)
{
if ($fields[$col] eq $label)
{
$label2Column{$label}=$col;
next SEARCH_LABEL;
}
}
die "Cannot find '$label' in $mkFile";
}
$headerProcessed = 1;
}
else
{
my @fields = split('\t', $_, $colNo);
my $snpID = $fields[$label2Column{'snp-id'}];
my $chromosome = $fields[$label2Column{'chromosome'}];
$chromosome = $chromosome eq 'XY' ? 'X' : $chromosome;
my $position = $fields[$label2Column{'position'}];
if ($chromosome ne 'n/a' && $position ne 'n/a')
{
$SNP{$snpID}{CHROM} = $chromosome;
$SNP{$snpID}{POS} = $position;
$SNP{$snpID}{ANNOTATED} = 0;
$CHROM{$chromosome}{$snpID} = $position;
}
else
{
warn "$snpID has no location";
}
}
}
close(MK);
my $dbh = DBI->connect(getDBConnectionString(), getDBUser(), getDBUserPassword()) || die "Couldn't connect to database: " . DBI->errstr;
open(GENE_ANNOTATED_MK, ">gene-annotated-$mkFile") || die "Cannot open gene-annotated-$mkFile";
print GENE_ANNOTATED_MK "snp-id\tchromosome\tposition\tknown-gene-id\tentrez-id\tgene-strand\ttx-start\ttx-end\tconsequence\tgene-symbol\tgene-description\tpathway\tbiological-process\tmolecular-function\tcellular-component\n";
if ($build eq 'hg17')
{
#populate gene annotation
print STDERR "retrieving gene annotation ... ";
print STDERR "kegg ... ";
$dbh->do(qq{
drop table if exists temp_kgid2keggpathway;
}) || die;
$dbh->do(qq{
create table temp_kgid2keggpathway
select kgID, description as pathway
from hg17_keggPathway as a left join hg17_keggMapDesc as b
on a.mapID = b.mapID;
}) || die;
$dbh->do(qq{
alter table temp_kgid2keggpathway add index(kgID);
});
$dbh->do(qq{
drop table if exists temp_gene_pathway;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway
select a.kgID, geneSymbol, description, pathway
from hg17_kgXref as a left join temp_kgid2keggpathway as b
on a.kgID = b.kgID;
}) || die;
print STDERR "GO ... ";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go
select a.*, b.biological_process, b.molecular_function, b.cellular_component
from temp_gene_pathway as a left join hg17_kgXgo as b
on a.geneSymbol = b.geneSymbol;
}) || die;
print STDERR "Entrez ID ... ";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go_entrez
select a.*, b.value as entrezID
from temp_gene_pathway_go as a left join hg17_knownToLocusLink as b
on a.kgID = b.name;
}) || die;
print STDERR "aggregating\n";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez_aggregate;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go_entrez_aggregate
select kgID as gene_id,
group_concat(distinct entrezID) as entrez_id,
group_concat(distinct geneSymbol) as gene_symbol,
group_concat(distinct description) as gene_description,
group_concat(distinct pathway) as pathway,
group_concat(distinct biological_process) as biological_process,
group_concat(distinct molecular_function) as molecular_function,
group_concat(distinct cellular_component) as cellular_component
from temp_gene_pathway_go_entrez group by kgID;
}) || die;
my $queryHandle = $dbh->prepare(qq{
select * from temp_gene_pathway_go_entrez_aggregate
}) || die;
$queryHandle->execute();
my ($geneID, $entrezID, $geneSymbol, $geneDescription, $pathway, $biologicalProcess, $molecularFunction, $cellularComponent);
$queryHandle->bind_columns(\($geneID, $entrezID, $geneSymbol, $geneDescription, $pathway, $biologicalProcess, $molecularFunction, $cellularComponent));
while (my @row = $queryHandle->fetchrow_array())
{
$GENE{$geneID}{GS} = !defined($geneSymbol) ? 'n/a' : $geneSymbol;
$GENE{$geneID}{ENTREZ_ID} = !defined($entrezID) ? 'n/a' : $entrezID;
$GENE{$geneID}{GD} = !defined($geneDescription) ? 'n/a' : $geneDescription;
$GENE{$geneID}{PW} = !defined($pathway) ? 'n/a' : $pathway;
$GENE{$geneID}{BP} = !defined($biologicalProcess) ? 'n/a' : $biologicalProcess;
$GENE{$geneID}{MF} = !defined($molecularFunction) ? 'n/a' : $molecularFunction;
$GENE{$geneID}{CC} = !defined($cellularComponent) ? 'n/a' : $cellularComponent;
#print "$geneID\t$GENE{$geneID}{GS}\t$GENE{$geneID}{GD}\t$GENE{$geneID}{PW}\t$GENE{$geneID}{BP}\t$GENE{$geneID}{MF}\t$GENE{$geneID}{CC}\n";
}
$dbh->do(qq{
drop table if exists temp_kgid2keggpathway;
});
$dbh->do(qq{
drop table if exists temp_gene_pathway;
});
$dbh->do(qq{
drop table if exists temp_gene_pathway_go;
});
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez;
});
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez_aggregate;
});
$queryHandle->finish();
for my $chromosome (sort {if("$a$b"=~/^\d+$/){$a <=> $b}else{$a cmp $b}} keys(%CHROM))
{
print STDERR "Processing chromosome $chromosome ... ";
print STDERR "sorting snps ... ";
my @sortedSNPs = sort {$SNP{$a}{POS} <=> $SNP{$b}{POS}} keys(%{$CHROM{$chromosome}});
print STDERR "annotating snps with genes ... ";
$queryHandle = $dbh->prepare(qq{
select name, txstart, txend, strand from hg17_knownGene where chrom = 'chr$chromosome'
});
$queryHandle->execute();
my ($name, $txstart, $txend, $strand);
$queryHandle->bind_columns(\$name, \$txstart, \$txend, \$strand);
my $chromosomeAnnotationCount = 0;
while (my @row = $queryHandle->fetchrow_array())
{
#search for starting point
my $left = 0;
my $right = $#sortedSNPs;
my $middle;
my $leftConsequence = $strand eq '+'?'upstream':'downstream';
my $rightConsequence = $strand eq '+'?'downstream':'upstream';
++$txstart;
my $leftWindowStart = $txstart - $windowSize; #it's ok to be negative
my $rightWindowEnd = $txend + $windowSize;
#binary search
#search for the leftmost SNP after leftWindowStart
while ($left!=$right)
{
my $middle = floor(($left+$right)/2);
if ($SNP{$sortedSNPs[$middle]}{POS}<$leftWindowStart)
{
$left = $middle+1;
}
else
{
$right = $middle;
}
}
my $i;
#traverse back in case of multiple SNPs mapping to the same position
for ($i=$left; $i>0; --$i)
{
if ($SNP{$sortedSNPs[$i]}{POS}<$leftWindowStart)
{
last;
}
else
{
$left = $i;
}
}
$i = $left;
#!(in the event where the gene is located after ALL the SNPs)
if ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS} >= $leftWindowStart)
{
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<$txstart)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\t$leftConsequence";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<=$txend)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\twithin-transcript";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<=$rightWindowEnd)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\t$rightConsequence";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
}
}
$queryHandle->finish();
$annotationCount += $chromosomeAnnotationCount;
print STDERR "$chromosomeAnnotationCount annotations for " . scalar(@sortedSNPs) . " SNPs\n";
}
}
elsif ($build eq 'hg18')
{
#populate gene annotation
print STDERR "retrieving gene annotation ... ";
print STDERR "kegg ... ";
$dbh->do(qq{
drop table if exists temp_kgid2keggpathway;
}) || die;
$dbh->do(qq{
create table temp_kgid2keggpathway
select kgID, description as pathway
from hg18_keggPathway as a left join hg18_keggMapDesc as b
on a.mapID = b.mapID;
}) || die;
$dbh->do(qq{
alter table temp_kgid2keggpathway add index(kgID);
}) || die;
$dbh->do(qq{
drop table if exists temp_gene_pathway;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway
select a.kgID, geneSymbol, description, pathway
from hg18_kgXref as a left join temp_kgid2keggpathway as b
on a.kgID = b.kgID;
}) || die;
print STDERR "GO ... ";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go
select a.*, b.biological_process, b.molecular_function, b.cellular_component
from temp_gene_pathway as a left join hg17_kgXgo as b
on a.geneSymbol = b.geneSymbol;
}) || die;
print STDERR "Entrez ID ... ";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go_entrez
select a.*, b.value as entrezID
from temp_gene_pathway_go as a left join hg18_knownToLocusLink as b
on a.kgID = b.name;
}) || die;
print STDERR "aggregating\n";
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez_aggregate;
}) || die;
$dbh->do(qq{
create table temp_gene_pathway_go_entrez_aggregate
select kgID as gene_id,
group_concat(distinct entrezID) as entrez_id,
group_concat(distinct geneSymbol) as gene_symbol,
group_concat(distinct description) as gene_description,
group_concat(distinct pathway) as pathway,
group_concat(distinct biological_process) as biological_process,
group_concat(distinct molecular_function) as molecular_function,
group_concat(distinct cellular_component) as cellular_component
from temp_gene_pathway_go_entrez group by kgID;
}) || die;
my $queryHandle = $dbh->prepare(qq{
select * from temp_gene_pathway_go_entrez_aggregate
}) || die;
$queryHandle->execute();
my ($geneID, $entrezID, $geneSymbol, $geneDescription, $pathway, $biologicalProcess, $molecularFunction, $cellularComponent);
$queryHandle->bind_columns(\($geneID, $entrezID, $geneSymbol, $geneDescription, $pathway, $biologicalProcess, $molecularFunction, $cellularComponent));
while (my @row = $queryHandle->fetchrow_array())
{
$GENE{$geneID}{GS} = !defined($geneSymbol) ? 'n/a' : $geneSymbol;
$GENE{$geneID}{ENTREZ_ID} = !defined($entrezID) ? 'n/a' : $entrezID;
$GENE{$geneID}{GD} = !defined($geneDescription) ? 'n/a' : $geneDescription;
$GENE{$geneID}{PW} = !defined($pathway) ? 'n/a' : $pathway;
$GENE{$geneID}{BP} = !defined($biologicalProcess) ? 'n/a' : $biologicalProcess;
$GENE{$geneID}{MF} = !defined($molecularFunction) ? 'n/a' : $molecularFunction;
$GENE{$geneID}{CC} = !defined($cellularComponent) ? 'n/a' : $cellularComponent;
#print "$geneID\t$GENE{$geneID}{GS}\t$GENE{$geneID}{GD}\t$GENE{$geneID}{PW}\t$GENE{$geneID}{BP}\t$GENE{$geneID}{MF}\t$GENE{$geneID}{CC}\n";
}
$dbh->do(qq{
drop table if exists temp_kgid2keggpathway;
}) || die;
$dbh->do(qq{
drop table if exists temp_gene_pathway;
}) || die;
$dbh->do(qq{
drop table if exists temp_gene_pathway_go;
}) || die;
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez;
});
$dbh->do(qq{
drop table if exists temp_gene_pathway_go_entrez_aggregate;
});
$queryHandle->finish();
for my $chromosome (sort {if("$a$b"=~/^\d+$/){$a <=> $b}else{$a cmp $b}} keys(%CHROM))
{
print STDERR "Processing chromosome $chromosome ... ";
print STDERR "sorting snps ... ";
my @sortedSNPs = sort {$SNP{$a}{POS} <=> $SNP{$b}{POS}} keys(%{$CHROM{$chromosome}});
print STDERR "annotating snps with genes ... ";
$queryHandle = $dbh->prepare(qq{
select name, txstart, txend, strand from hg18_knownGene where chrom = 'chr$chromosome'
});
$queryHandle->execute();
my ($name, $txstart, $txend, $strand);
$queryHandle->bind_columns(\$name, \$txstart, \$txend, \$strand);
my $chromosomeAnnotationCount = 0;
while (my @row = $queryHandle->fetchrow_array())
{
#search for starting point
my $left = 0;
my $right = $#sortedSNPs;
my $middle;
my $leftConsequence = $strand eq '+'?'upstream':'downstream';
my $rightConsequence = $strand eq '+'?'downstream':'upstream';
++$txstart;
my $leftWindowStart = $txstart - $windowSize; #it's ok to be negative
my $rightWindowEnd = $txend + $windowSize;
#binary search
#search for the leftmost SNP after leftWindowStart
while ($left!=$right)
{
my $middle = floor(($left+$right)/2);
if ($SNP{$sortedSNPs[$middle]}{POS}<$leftWindowStart)
{
$left = $middle+1;
}
else
{
$right = $middle;
}
}
my $i;
#traverse back in case of multiple SNPs mapping to the same position
for ($i=$left; $i>0; --$i)
{
if ($SNP{$sortedSNPs[$i]}{POS}<$leftWindowStart)
{
last;
}
else
{
$left = $i;
}
}
$i = $left;
#print "$name txstart: $txstart\ttxend: $txend\tleft: $left\t i: $i\t\t$leftWindowStart\t leftmostsnp: $SNP{$sortedSNPs[$i]}{POS} \t(" . ($SNP{$sortedSNPs[max($i-1, 0)]}{POS}-$leftWindowStart) .")" . ($SNP{$sortedSNPs[$i]}{POS}-$leftWindowStart). " \tleftwindowstart: $leftWindowStart\trightwindowend: $rightWindowEnd\n";
#!(in the event where the gene is located after ALL the SNPs)
if ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS} >= $leftWindowStart)
{
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<$txstart)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\t$leftConsequence";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<=$txend)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\twithin-transcript";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
while ($i<=$#sortedSNPs && $SNP{$sortedSNPs[$i]}{POS}<=$rightWindowEnd)
{
print GENE_ANNOTATED_MK "$sortedSNPs[$i]\t$SNP{$sortedSNPs[$i]}{CHROM}\t$SNP{$sortedSNPs[$i]}{POS}\t$name\t$GENE{$name}{ENTREZ_ID}\t$strand\t$txstart\t$txend\t$rightConsequence";
print GENE_ANNOTATED_MK "\t$GENE{$name}{GS}\t$GENE{$name}{GD}\t$GENE{$name}{PW}\t$GENE{$name}{BP}\t$GENE{$name}{MF}\t$GENE{$name}{CC}\n";
$SNP{$sortedSNPs[$i]}{ANNOTATED} = 1;
++$chromosomeAnnotationCount;
++$i;
}
}
}
$queryHandle->finish();
$annotationCount += $chromosomeAnnotationCount;
print STDERR "$chromosomeAnnotationCount annotations for " . scalar(@sortedSNPs) . " SNPs\n";
}
}
if(!$maskUnannotatedSNPs)
{
for my $snpID (keys(%SNP))
{
if (!$SNP{$snpID}{ANNOTATED})
{
print GENE_ANNOTATED_MK "$snpID\t$SNP{$snpID}{CHROM}\t$SNP{$snpID}{POS}" . "\tn/a" x 12 . "\n";
}
}
}
close(GENE_ANNOTATED_MK);
$dbh->disconnect();