Merge pull request #5205 from solgenomics/topic/generic_trial_upload
[sgn.git] / cgi-bin / search / unigene_build.pl
blobb9f403a579d91b5074b05235d7643d8dc1803e77
1 #!/usr/bin/perl
3 =head1 NAME
5 unigene_build.pl
6 Controller to show the web_page for unigene build using MASON.
8 =cut
10 =head1 SYNOPSIS
13 =head1 DESCRIPTION
15 This is the script to show the web_page using MASON
17 =cut
19 =head1 AUTHORS
21 Aureliano Bombarely Gomez
22 (ab782@cornell.edu)
24 =cut
27 use strict;
28 use warnings;
31 use CXGN::MasonFactory;
32 use CXGN::Page;
35 use CXGN::DB::Connection;
36 use CXGN::DB::DBICFactory;
38 use SGN::Schema;
39 use CXGN::Transcript::Unigene;
41 ## Create mason object
43 my $m = CXGN::MasonFactory->new();
45 ## Use of CXGN::Page to take the arguments from the URL
47 my $page = CXGN::Page->new();
49 my %args = $page->get_all_encoded_arguments();
51 ## It create a MASON path and transmite it to let the dependient MASON
52 ## code access to the MASON components (using the only mason dir give
53 ## problems)
55 ## Create the gem schema object (used to get data from expression to samples)
59 ## There are one way to access to the page using id as integer. If use
60 ## other combinations give an error message
62 my $psqlv = `psql --version`;
63 chomp($psqlv);
65 my @schema_list = ('sgn');
66 if ($psqlv =~ /8\.1/) {
67 push @schema_list, 'tsearch2';
70 my $schema = CXGN::DB::DBICFactory->open_schema( 'SGN::Schema', search_path => \@schema_list, );
72 my @schema_list2 = ('public');
73 if ($psqlv =~ /8\.1/) {
74 push @schema_list2, 'tsearch2';
77 my $bcs = CXGN::DB::DBICFactory->open_schema( 'Bio::Chado::Schema', search_path => \@schema_list2, );
79 my $dbh = CXGN::DB::Connection->new();
81 ## Get unigene build object
83 my $unigene_build = CXGN::Transcript::UnigeneBuild->new($dbh);
84 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
85 $unigene_build = CXGN::Transcript::UnigeneBuild->new($dbh, $args{'id'});
89 ## There are one way to access to the page using id as integer. If use other combinations give an error message
91 if (defined $unigene_build) {
92 $m->exec('/transcript/unigene_build_detail.mas',
93 bcs => $bcs,
94 schema => $schema,
95 unigene_build => $unigene_build );
97 else {
98 $m->exec('/transcript/transcript_page_error.mas',
99 object => $unigene_build );