6 Controller to show the web_page for sample information using MASON.
15 This is the script to show the web_page using MASON
21 Aureliano Bombarely Gomez
30 use CXGN
::MasonFactory
;
31 use CXGN
::DB
::DBICFactory
;
32 use CXGN
::DB
::Connection
;
33 use CXGN
::Biosource
::Schema
;
34 use CXGN
::Biosource
::Sample
;
35 use CXGN
::GEM
::Schema
;
36 use CXGN
::GEM
::Target
;
37 use CXGN
::DB
::Connection
;
40 use CXGN
::Page
::FormattingHelpers qw
/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
43 ## Create the mason object
45 my $m = CXGN
::MasonFactory
->new();
47 ## Use of CXGN::Page to take the arguments from the URL
49 my %args = CXGN
::Page
->new()
50 ->get_all_encoded_arguments();
52 ## Create the schema used for the mason components
54 my $psqlv = `psql --version`;
57 my $schema_list = 'biosource,metadata,public';
58 if ($psqlv =~ /8\.1/) {
59 $schema_list .= ',tsearch2';
62 my @schema_list = split(/,/, $schema_list);
63 my $schema = CXGN
::DB
::DBICFactory
->open_schema( 'CXGN::Biosource::Schema', search_path
=> \
@schema_list, );
66 ## Get the sample data for sample specific mason components
69 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
70 $sample = CXGN
::Biosource
::Sample
->new($schema, $args{'id'});
71 } elsif (exists $args{'name'}) {
72 $sample = CXGN
::Biosource
::Sample
->new_by_name($schema, $args{'name'});
74 $sample = CXGN
::Biosource
::Sample
->new($schema);
77 ## Get a publication list for common mason components
80 if (defined $sample) {
81 @pubs = $sample->get_publication_list();
84 ## The sample can be associated expression data (search sample_id in gem.ge_target_element table)
87 if ($sample->get_sample_id() ) {
89 ## First create an schema that contains gem schema
90 my @gem_schema_list = ('gem', @schema_list);
92 my $gemschema = CXGN
::DB
::DBICFactory
->open_schema( 'CXGN::GEM::Schema', search_path
=> \
@gem_schema_list, );
94 my @sample_el_rows = $gemschema->resultset('GeTargetElement')
95 ->search({ sample_id
=> $sample->get_sample_id() });
97 foreach my $sample_el_row (@sample_el_rows) {
98 my $target_id = $sample_el_row->get_column('target_id');
99 my $target = CXGN
::GEM
::Target
->new($gemschema, $target_id);
100 push @targets, $target;
104 ## Get the sample relationship
106 my %sample_relations = $sample->get_relationship();
108 ## Depending if the $sample has or not id, it call a mason page (error when does not exists sample in the database)
110 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
112 if (defined $sample->get_sample_id() ) {
113 $m->exec('/biosource/sample_detail.mas', schema
=> $schema, sample
=> $sample, sample_relations_href
=> \
%sample_relations, pub_list
=> \
@pubs, target_list
=> \
@targets );
115 $m->exec('/biosource/biosource_page_error.mas', schema
=> $schema, object
=> $sample );