-
Notifications
You must be signed in to change notification settings - Fork 0
/
fextractmarkersinexome
executable file
·151 lines (120 loc) · 3 KB
/
fextractmarkersinexome
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
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
use Getopt::Long;
use Pod::Usage;
use POSIX qw(ceil floor);
=head1 NAME
fextractmarkersinexome
=head1 SYNOPSIS
fextractmarkersinexome [options] <vcf-file>
-h help
-w window size (0 default) [0,1M]
-k UCSC known genes
vcf-file VCF file
example: fextractmarkersinexome pscalare.vcf --ref refGenes.txt.gz -w 10000
=head1 DESCRIPTION
=cut
#option variables
my $help;
my $refGenesFile;
my $vcfFile;
my $windowSize = 0;
my $colNo;
my $headerProcessed;
my %SNP;
my %CHROM;
my @GENES;
my %label2Column;
#initialize options
Getopt::Long::Configure ('bundling');
if(!GetOptions('h'=>\$help, 'w=i'=>\$windowSize, 'ref=s'=>\$refGenesFile)
|| $windowSize < 0
|| $windowSize > 1000000
|| scalar(@ARGV)!=1)
{
if ($help)
{
pod2usage(-verbose => 2);
}
else
{
pod2usage(1);
}
}
$vcfFile = $ARGV[0];
if(`gzip -t $refGenesFile` eq "")
{
open(REF, "gunzip -c $refGenesFile |") || die "can't open pipe to $refGenesFile";
}
else
{
open(REF, $refGenesFile) || die "can't open $refGenesFile";
}
$headerProcessed = 0;
#read in exonic regions
while(<REF>)
{
s/\r?\n?$//;
#585 NR_024540 chr1 - 14361 29370 29370 29370 11 14361,14969,15795,16606,16857,17232,17605,17914,18267,24737,29320, 14829,15038,15947,16765,17055,17368,17742,18061,18366,24891,29370, 0 WASH7P unk unk -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
my @fields = split('\t', $_);
my $chromosome = $fields[2];
my $gene = $fields[1];
if (!exists($CHROM{$chromosome}))
{
@{$CHROM{$chromosome}} = ();
}
else
{
#print "$_\n";
my %GENE = ();
$GENE{TXSTART} = $fields[4];
$GENE{TXEND} = $fields[5];
$GENE{EXONSTART} = $fields[9];
$GENE{EXONEND} = $fields[10];
push(@{$CHROM{$chromosome}}, \%GENE);
}
}
close(REF);
for my $chromosome (keys(%CHROM))
{
my @GENES = @{$CHROM{$chromosome}};
for my $i (0 .. $#GENES)
{
my $start = $GENES[$i]{TXSTART};
print "this $start\n";
}
}
if(`gzip -t $vcfFile` eq "")
{
open(REF, "gunzip -c $vcfFile |") || die "can't open pipe to $vcfFile";
}
else
{
open(REF, $vcfFile) || die "can't open $vcfFile";
}
#read in markers
while(<REF>)
{
s/\r?\n?$//;
#585 NR_024540 chr1 - 14361 29370 29370 29370 11 14361,14969,15795,16606,16857,17232,17605,17914,18267,24737,29320, 14829,15038,15947,16765,17055,17368,17742,18061,18366,24891,29370, 0 WASH7P unk unk -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
my @fields = split('\t', $_);
my $chromosome = $fields[2];
my $gene = $fields[1];
if (!exists($CHROM{$chromosome}))
{
@{$CHROM{$chromosome}} = ();
}
else
{
#print "$_\n";
my %GENE = ();
$GENE{TXSTART} = $fields[4];
$GENE{TXEND} = $fields[5];
$GENE{EXONSTART} = $fields[9];
$GENE{EXONEND} = $fields[10];
push(@{$CHROM{$chromosome}}, \%GENE);
}
}
close(REF);