6 Mason component to show the basic information for target web page.
18 Mason component to show the basic information for target web page.
20 - Mason root page = target_detail.mas
21 - Perl controller = target.pl
27 Aureliano Bombarely (ab782@cornell.edu)
43 use CXGN::GEM::Schema;
44 use CXGN::Chado::Dbxref;
45 use CXGN::Biosource::Sample;
46 use CXGN::Biosource::Protocol;
48 use CXGN::Page::FormattingHelpers qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
50 my $basic_info_content;
51 my $element_info_content;
54 my $default_message = '<i><font color="gray">data not available</font></i>';
56 ## If there aren't any experiment_row that comes from experimental_design_detail.mas, it will return a message.
58 if ($target->get_target_id() ) {
60 ## Get the target object
62 my $target_name = $target->get_target_name();
63 $target_accession = $target_name;
66 ## Get the schema object
68 my $schema = $target->get_schema();
70 ## Get the experiment link:
72 my $experiment = $target->get_experiment();
74 my $exp_id = $experiment->get_experiment_id();
75 my $exp_name = $experiment->get_experiment_name();
76 my $exp_link = '/gem/experiment.pl?id='.$exp_id;
77 my $exp_html = "<a href=$exp_link>$exp_name</a><br>";
79 ## Get the experimental design link
81 my $expdesign = $target->get_experimental_design();
83 my $expdesign_id = $expdesign->get_experimental_design_id();
84 my $expdesign_name = $expdesign->get_experimental_design_name();
85 my $expdesign_link = '/gem/experimental_design.pl?id='.$expdesign_id;
86 my $expdesign_html = "<a href=$expdesign_link>$expdesign_name</a>";
88 ## Get the external links
90 my @dbxref_list_id = $target->get_dbxref_list();
91 my @dbxref_html_list = ();
93 foreach my $dbxref_id (@dbxref_list_id) {
94 my ($dbxref_row) = $schema->resultset('General::Dbxref')
95 ->search({ dbxref_id => $dbxref_id });
97 if (defined $dbxref_row) {
98 my ($db_row) = $schema->resultset('General::Db')
99 ->search({ db_id => $dbxref_row->get_column('db_id') });
101 my $dbxref_link = $db_row->get_column('urlprefix') . $db_row->get_column('url') . $dbxref_row->get_column('accession');
102 my $dbxref_html = $db_row->get_column('name') . ": <a href=$dbxref_link>".$dbxref_row->get_column('accession')."</a>";
103 push @dbxref_html_list, $dbxref_html;
107 my $dbxref_html_list = join('<br>', @dbxref_html_list) || $default_message;
109 ## Get the target elements
111 my %target_elements = $target->get_target_elements();
113 ## It will create a table with target_elements as target_element_name, dye, sample_name (with links), protocol_name (with
116 my @target_el_html_list = ();
118 foreach my $target_el_name (sort keys %target_elements) {
119 my %target_el_data = %{ $target_elements{$target_el_name} };
121 my $dye = $target_el_data{'dye'};
124 my $sample_id = $target_el_data{'sample_id'};
125 my $sample = CXGN::Biosource::Sample->new($schema, $sample_id);
126 my $sample_name = $sample->get_sample_name();
127 unless (defined $sample_name) {
128 $sample_html = $default_message;
131 my $sample_link = '/biosource/sample.pl?id=' . $sample_id;
132 $sample_html = "<a href=$sample_link>$sample_name</a>";
136 my $protocol_id = $target_el_data{'protocol_id'};
137 my $protocol = CXGN::Biosource::Protocol->new($schema, $protocol_id);
138 my $protocol_name = $protocol->get_protocol_name();
139 unless (defined $protocol_name) {
140 $protocol_html = $default_message;
143 my $protocol_link = '/biosource/protocol.pl?id=' . $protocol_id;
144 $protocol_html = $protocol_name;
145 ## protocol.pl page doesn't exists for now (2010-09-23), dissable option" <a href=$protocol_link>$protocol_name</a>";
148 ## Get the sample_element_dbxref (GO and PO terms)
150 my %dbxref_related = $sample->get_dbxref_related();
152 ## It remove the redundancy using a hash
155 foreach my $dbxref_id (keys %dbxref_related) {
157 if (defined $dbxref_related{$dbxref_id} ) {
159 my %dbxref_rel_data = %{ $dbxref_related{$dbxref_id} };
161 if (defined $dbxref_rel_data{'cvterm.name'}) {
163 my $onto_accession = $dbxref_rel_data{'db.name'} . ":" . $dbxref_rel_data{'dbxref.accession'};
164 my $onto_descr = $dbxref_rel_data{'cvterm.name'};
165 my $onto_link = '/cvterm/'.$dbxref_rel_data{'cvterm.cvterm_id'}.'/view';
166 my $onto_line = "<a href=$onto_link>$onto_accession</a> ($onto_descr)<br>";
168 unless (defined $onto_html{$onto_line}) {
169 $onto_html{$onto_line} = 1;
174 my $onto_list = join(' ', sort keys %onto_html) || $default_message;
176 push @target_el_html_list, [$target_el_name, $dye, $sample_html, $protocol_html, $onto_list];
179 my $target_el_composition_html = columnar_table_html( headings => [ 'Target element name',
185 data => \@target_el_html_list,
186 __align => ['c', 'c', 'c', 'c', 'l'],
191 ## Create the HTML table
193 $basic_info_content = <<HTML;
196 <tr> <td width="25%"> <b>Target name:</b> </td> <td> $target_name </td></tr>
197 <tr> <td width="25%"> <b>Experiment name:</b> </td> <td> $exp_html </td></tr>
198 <tr> <td width="25%"> <b>Experimental design name:</b> </td> <td> $expdesign_html</td></tr>
199 <tr> <td width="25%"> <b>Target external links:</b> </td> <td> $dbxref_html_list</td></tr>
206 $element_info_content .= $target_el_composition_html;
209 $basic_info_content = "<big>There aren't any target data for the specified parameters.</big>";
212 if (defined $target_accession) {
213 $basic_info_html = "<center><big><b>Expression Target: $target_accession</b></big></center><br>";
215 $basic_info_html .= info_section_html( title => "Target Basic Information", contents => $basic_info_content );
217 if (defined $target_accession) {
218 $basic_info_html .= info_section_html( title => "Target Element Information", contents => $element_info_content );
223 <% $basic_info_html %>
226 /util/import_javascript.mas,
227 classes => 'CXGN.Effects'