-
Notifications
You must be signed in to change notification settings - Fork 0
/
getidipr.pl
52 lines (41 loc) · 838 Bytes
/
getidipr.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
50
51
52
#!/usr/bin/perl
use FindBin qw ($Bin);
use Getopt::Long;
GetOptions(\%opt,"list:s","iprscan:s","output:s","help:s");
my $help=<<USAGE;
Get iprscan for ids in a list file
perl $0 -l id -i gene.iprscan -o id.iprscan > log
USAGE
if (exists $opt{help} or keys %opt < 1){
print $help;
exit;
}
my $ref=readtable($opt{list});
open IN, "$opt{iprscan}" or die "$!";
open OUT, ">$opt{output}" or die "$!";
while(<IN>){
chomp $_;
next if ($_=~/^$/);
my @unit=split("\t",$_);
if (exists $ref->{$unit[0]}){
print OUT "$_\n";
}
}
close IN;
close OUT;
#################
sub readtable
{
### store id into hash %id
my %hash;
open IN, "$opt{list}" or die "$!";
while(<IN>){
chomp $_;
next if ($_ eq "");
my @unit=split("\t",$_);
my $id=$unit[0];
$hash{$id}=1;
}
close IN;
return \%hash;
}