-
Notifications
You must be signed in to change notification settings - Fork 37
/
gbgff
74 lines (58 loc) · 1.96 KB
/
gbgff
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
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
# $Id: gbgff,v 1.2 2009-08-27 19:13:18 idavies Exp $
# just redirect to gbrowse in same directory
use strict;
use warnings;
use File::Basename 'dirname';
use CGI 'url','path_info','redirect','header','param';
use Bio::Graphics::Browser2::Render;
umask 022;
my $fcgi = Bio::Graphics::Browser2::Render->fcgi_request;
if ($fcgi) {
my $FCGI_DONE = 0;
$SIG{USR1} = $SIG{PIPE} = $SIG{TERM} = sub {
my $sig = shift;
my $time = localtime;
print STDERR "[$time] [notice] GBrowse FastCGI process caught sig$sig. Exiting... (pid $$)\n";
$FCGI_DONE = 1;
};
while (!$FCGI_DONE && ($fcgi->Accept >= 0)) {
CGI->initialize_globals();
process_transaction();
}
} else {
process_transaction();
}
exit 0;;
sub process_transaction {
my $base = url();
my $path_info = path_info();
$path_info =~ s!^/!!;
my $source = param('source');
my $segment = param('q') || param('segment');
my $ref = param('ref') || param('seqid');
my $start = param('start');
my $end = param('end') || param('stop');
my $dump = param('d');
my $type = param('t') || param('type');
my $id = param('id');
my $stylesheet= param('s');
my $url = dirname($base);
$url .= '/gbrowse';
$url .= "/".($source || $path_info);
$url .= "/?";
$url .= "gbgff=1";
$url .= ";q=".($segment || "$ref:$start..$end");
$url .= ";d=$dump" if defined $dump;
$url .= ";t=$type" if defined $type;
$url .= ";id=$id" if defined $id;
$url .= ";s=$stylesheet" if defined $stylesheet;
print redirect($url);
}
1;