-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenericMapping.cgi
74 lines (58 loc) · 1.57 KB
/
genericMapping.cgi
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
#!/usr/bin/perl -w
# map_panther.pl - Generic mapping program
my %FORM;
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$FORM{$name} = $value;
}
my $org = $FORM{'organism'};
my $fileContents = $FORM{'fileContents'};
$fileContents =~ s/%([A-Fa-f\d]{2})/chr hex $1/eg;
print "Content-Type: text/html\n\n";
# Note there is a newline between
# this header and Data
# Simple HTML code follows
#print "<html> <head>\n";
#print "<title>PANTHER generic mapping</title>";
#print "</head>\n";
#print "<body>\n";
#print "<h1>Hello, world!</h1>\n";
#print "org $org \n";
#print "fileContents $fileContents \n";
my %pthr;
my $orgFile = "panther_classification/$org";
open (FH, $orgFile);
while (my $line=<FH>){
chomp $line;
#print "processing an organism line $line\n";
my ($id, $pthr)=split(/\t/, $line);
$pthr{$id}=$pthr;
}
close (FH);
#print "finished reading org file\n";
my $count1;
my $count2;
my @linesArray = split /\n/, $fileContents;
foreach $line (@linesArray) {
#print "processing a line $line\n";
$line=~s/\r//g;
#chomp $line;
my ($id, @rest)=split(/\t/, $line);
my $foo = join("\t", @rest);
if (defined $pthr{$id}){
$count1++;
my $pthr=$pthr{$id};
print "$id\t$pthr\t$foo\n";
}else{
$count2++;
print "$id\tNOHIT\t$foo\n";
}
}
#print "</body> </html>\n";