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 $schema = $c->dbic_schema( 'CXGN::GEM::Schema', 'sgn_chado' );
45 my $sgn_schema = $c->dbic_schema( 'SGN::Schema' );
47 my $dbh = CXGN
::DB
::Connection
->new();
49 ## To do more flexible how the unigene can be called
51 if (defined $args{'unigene_id'}) {
52 $args{'id'} = $args{'unigene_id'} ;
53 $args{'id'} =~ s/^SGN-U//;
55 # convert CGN-U to SGN-U
56 if( $args{unigene_id
} =~ s/^CGN-?U//i ) {
57 my ($sgnid) = $dbh->selectrow_array(<<EOS,undef, $args{unigene_id}, 'CGN');
58 SELECT unigene_id FROM unigene WHERE sequence_name = ? AND database_name=?
68 ## Random function will get at random unigene from the latest unigene build
70 if (defined $args{'random'}) {
71 if ($args{'random'} =~ m/^yes$/i) {
72 my $last_unigene_build_id = $sgn_schema->resultset('UnigeneBuild')
76 order_by
=> 'unigene_build_id DESC',
81 ->get_column('unigene_build_id');
83 ## Now get all the unigene_id for this unigene_build_id
85 my $random_unigene_id = $sgn_schema->resultset('Unigene')
88 unigene_build_id
=> $last_unigene_build_id
91 order_by
=> 'random()',
96 ->get_column('unigene_id');
98 ## It will replace $args{'id'}
100 $args{'id'} = $random_unigene_id;
104 ## Now it will take the unigene object based in the unigene_id (it will create an empty object by default)
106 my $unigene = CXGN
::Transcript
::Unigene
->new($dbh);
108 if (defined $args{'id'} && $args{'id'} =~ m/^\d+$/) {
110 $unigene = CXGN
::Transcript
::Unigene
->new($dbh, $args{'id'});
114 ## Now depending if there are enought condition, it will call a mason unigen page ($unigene object has an id)
117 if (defined $unigene && defined $unigene->get_unigene_id() ) {
119 $c->forward_to_mason_view(
120 '/transcript/unigene_detail.mas',
123 sgn_schema
=> $sgn_schema,
125 highlight
=> $args{'highlight'},
126 force_image
=> $args{'force_image'},
127 basepath
=> $c->config->{basepath
},
128 temp_dir
=> $c->tempfiles_subdir('unigene_images'),
131 $c->forward_to_mason_view(
132 '/transcript/transcript_page_error.mas',
133 object
=> $unigene );