6 Controller to show the web_page for unigene using MASON.
15 This is the script to show the web_page using MASON
21 Aureliano Bombarely Gomez
32 use CXGN
::DB
::Connection
;
34 use CXGN
::Transcript
::Unigene
;
36 use CatalystX
::GlobalContext
'$c';
38 ## Use of CXGN::Page to take the arguments from the URL
44 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
45 my $schema = $c->dbic_schema( 'CXGN::GEM::Schema', 'sgn_chado', $sp_person_id );
46 my $sgn_schema = $c->dbic_schema( 'SGN::Schema', undef, $sp_person_id );
48 my $dbh = CXGN
::DB
::Connection
->new();
50 ## To do more flexible how the unigene can be called
52 if (defined $args{'unigene_id'}) {
53 $args{'id'} = $args{'unigene_id'} ;
54 $args{'id'} =~ s/^SGN-U//;
56 # convert CGN-U to SGN-U
57 if( $args{unigene_id
} =~ s/^CGN-?U//i ) {
58 my ($sgnid) = $dbh->selectrow_array(<<EOS,undef, $args{unigene_id}, 'CGN');
59 SELECT unigene_id FROM unigene WHERE sequence_name = ? AND database_name=?
69 ## Random function will get at random unigene from the latest unigene build
71 if (defined $args{'random'}) {
72 if ($args{'random'} =~ m/^yes$/i) {
73 my $last_unigene_build_id = $sgn_schema->resultset('UnigeneBuild')
77 order_by
=> 'unigene_build_id DESC',
82 ->get_column('unigene_build_id');
84 ## Now get all the unigene_id for this unigene_build_id
86 my $random_unigene_id = $sgn_schema->resultset('Unigene')
89 unigene_build_id
=> $last_unigene_build_id
92 order_by
=> 'random()',
97 ->get_column('unigene_id');
99 ## It will replace $args{'id'}
101 $args{'id'} = $random_unigene_id;
105 ## Now it will take the unigene object based in the unigene_id (it will create an empty object by default)
107 my $unigene = CXGN
::Transcript
::Unigene
->new($dbh);
109 if (defined $args{'id'} && $args{'id'} =~ m/^\d+$/) {
111 $unigene = CXGN
::Transcript
::Unigene
->new($dbh, $args{'id'});
115 ## Now depending if there are enought condition, it will call a mason unigen page ($unigene object has an id)
118 if (defined $unigene && defined $unigene->get_unigene_id() ) {
120 $c->forward_to_mason_view(
121 '/transcript/unigene_detail.mas',
124 sgn_schema
=> $sgn_schema,
126 highlight
=> $args{'highlight'},
127 force_image
=> $args{'force_image'},
128 basepath
=> $c->config->{basepath
},
129 temp_dir
=> $c->tempfiles_subdir('unigene_images'),
132 $c->forward_to_mason_view(
133 '/transcript/transcript_page_error.mas',
134 object
=> $unigene );