5 experiment_composition.mas
6 Mason component to show experiment composition for experimental design web page.
18 Mason component to show experiment composition for experimental design web page.
20 - Mason root page = experimental_design_detail.mas
21 - Perl controller = experimental_design.pl
27 Aureliano Bombarely (ab782@cornell.edu)
43 use CXGN::GEM::Schema;
44 use CXGN::Page::FormattingHelpers qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
49 ## If there aren't any experiment that comes from experimental design it will do nothing.
50 ## The error message will returned by basic information
53 my $exp_composition_html;
55 my $default_message = '<span class="ghosted">data not available</span>';
57 my @exp_list = @{ $exp_list };
59 if (scalar(@exp_list) > 0) {
62 my $schema = $exp_list[0]->get_schema();
64 foreach my $exp (@exp_list) {
65 my $exp_id = $exp->get_experiment_id();
66 my $exp_name = $exp->get_experiment_name();
67 my $exp_link = '/gem/experiment.pl?id='.$exp_id;
68 my $exp_html = "<a href=$exp_link>$exp_name</a>";
70 my (%ontologies, %cvterm_id);
71 my @target_list = $exp->get_target_list();
74 foreach my $target (@target_list) {
75 my $target_id = $target->get_target_id();
76 my $target_name = $target->get_target_name();
77 my $target_link = '/gem/target.pl?id='.$target_id;
78 my $target_html = "<a href=$target_link>$target_name</a>";
79 push @target_html_list, $target_html;
81 my %target_elements = $target->get_target_elements();
84 foreach my $target_el_name (sort keys %target_elements) {
85 my %target_el_data = %{ $target_elements{$target_el_name} };
86 my $sample_id = $target_el_data{'sample_id'};
87 my $sample = CXGN::Biosource::Sample->new($schema, $sample_id);
88 my $sample_name = $sample->get_sample_name();
90 my @dbxref_ids_list = $sample->get_dbxref_list();
92 foreach my $dbxref_id (@dbxref_ids_list) {
93 my ($dbxref_row) = $schema->resultset('General::Dbxref')
94 ->search( { dbxref_id => $dbxref_id } );
96 my %dbxref_data = $dbxref_row->get_columns();
98 my ($cvterm_row) = $schema->resultset('Cv::Cvterm')
99 ->search( { dbxref_id => $dbxref_id } );
101 if (defined $cvterm_row) {
102 my %cvterm_data = $cvterm_row->get_columns();
104 my ($db_row) = $schema->resultset('General::Db')
105 ->search( { db_id => $dbxref_data{'db_id'} } );
107 my $ontology_id = $db_row->get_column('name') . ":" . $dbxref_data{'accession'};
108 my $ontology_name = $cvterm_data{'name'};
109 unless (defined $ontologies{$ontology_id}) {
110 $ontologies{$ontology_id} = $ontology_name;
111 $cvterm_id{$ontology_id} = $cvterm_data{'cvterm_id'};
118 foreach my $onto (sort keys %ontologies) {
119 my $onto_link = '/cvterm/'.$cvterm_id{$onto}.'/view';
120 my $onto_line = "<a href=$onto_link>$onto</a> ($ontologies{$onto})";
121 push @onto_html, $onto_line;
123 my $onto_list = join('<br>', @onto_html) || $default_message;
124 my $target_html_list = join('<br>', @target_html_list);
126 push @data, [$exp_html, $target_html_list, $onto_list];
129 ## Use columnar table to give the html format. If don't exists any data, print message.
131 $exp_composition_html = columnar_table_html( headings => [ 'Experiment', 'Target', 'Ontologies'],
134 __align => ['l', 'l', 'l'],
136 my $exp_n = scalar(@data);
137 $exp_comp_content = info_section_html( title => "Experiments (".$exp_n.")",
138 contents => $exp_composition_html,
147 <% $exp_comp_content %>
150 /util/import_javascript.mas,
151 classes => 'CXGN.Effects'