-
Notifications
You must be signed in to change notification settings - Fork 1
/
indexBG.pl
executable file
·49 lines (40 loc) · 1.25 KB
/
indexBG.pl
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
#!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
#########################################################################################
## parse input options
use vars qw($bgFile $help);
GetOptions ("i=s" => \$bgFile,
"help" => \$help,
"h" => \$help);
usage() if($help);
#########################################################################################
sub usage {
print STDERR "\nProgram: indexBG.pl (create an index of block group file)\n";
print STDERR "Author: RTH, University of Copenhagen, Denmark\n";
print STDERR "Version: 1.0\n";
print STDERR "Contact: sachin\@rth.dk\n";
print STDERR "Usage: indexBG.pl -i <file> [OPTIONS]\n";
print STDERR " -i <file> [block group file | STDIN]\n";
print STDERR " -h [print this helpful message]\n\n";
exit(-1);
}
#########################################################################################
## open text file
my $INFILE=();
if(defined($bgFile)) {
if($bgFile=~/\.gz$/) { open($INFILE, "gunzip -c $bgFile |") || die $!; }
else { open($INFILE, $bgFile) || die $!; }
}
else { $INFILE = *STDIN; }
my $i=0;
foreach my $l(<$INFILE>) {
my @t=split(/\s+/, $l);
if($l=~/^\>/) {
$t[0]=~s/^\>//g;
print "$t[0]\t$i\t".($i+$t[6])."\n";
}
$i++;
}
exit;