-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.pl
executable file
·98 lines (88 loc) · 3.17 KB
/
index.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
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
#!/usr/bin/env perl
#
# Web server for STSI's Variant Browser
# Based on Mojolicius Perl Web Framework
#
# Last Modified; May/20/2016
#
# Version 0.4.0
#
# Copyright (C) 2016 Manuel Rueda (mrueda@scripps.edu)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# If this program helps you in your research, please cite.
use Mojolicious::Lite;
#use Mojo::Server::Hypnotoad;
use autodie;
use FindBin qw($Bin);
use lib $Bin;
use BROWSER::HTML;
use BROWSER::DB;
# Naming convention: snake_case
# Mojolicius stuff
#app->secret('no-secret-warnings off');
app->mode('development'); # stop debug pages
# Route #1 -> Rendering Home Page HTML
get '/' => sub {
my $self = shift;
my $html = HTML->new();
my $html_str = $html->front_page();
$self->render( data => $html_str );
};
# Route #2 -> Rendering HTML results via GET or POST
# This route avoids proxy redirecting via POST form '/' to genomics.scripps.edu
any [ 'GET', 'POST' ] => '/results' => sub {
my $self = shift;
my $query = $self->param('query');
my $html = HTML->new( { query => $query } );
my $html_str = $html->submission();
$self->render( data => $html_str );
};
# Route #3 -> Web Services results via GET or POST with placeholders
any [ 'GET', 'POST' ] => '/:query/:cohort/:filetype' =>
[ cohort => [qw(cg illumina molau)], filetype => [qw(vcf json)] ] => sub { # /:format 'format' did not work
my $self = shift;
my $query = $self->param('query');
my $cohort = lc( $self->param('cohort') );
my $format = lc( $self->param('filetype') );
my $html =
HTML->new( { query => $query, cohort => $cohort, format => $format } );
my $str = $html->web_services();
$self->render( data => $str );
};
# Route #4 -> Rendering Beacon Page HTML
get '/ga4gh' => sub {
my $self = shift;
my $html = HTML->new();
my $html_str = $html->beacon_page();
$self->render( data => $html_str );
};
# Route #5 -> Rendering HTML-based Beacon results
post '/ga4gh' => sub {
my $self = shift;
my $beacon = uc( $self->param('beacon') );
my $ref = uc( $self->param('ref') );
my $chr = $self->param('chr');
my $pos = $self->param('pos');
$pos++; # From 0-based to 1-based
my $alt = uc( $self->param('alt') ); # Any allele
my $query = $chr . ':' . $pos . '-' . $pos;
my $html = HTML->new( { query => $query, allele => $alt } );
my $html_str = $html->submission();
$self->render( data => $html_str );
};
app->start();
exit;