5 correlation_analysis.mas
6 Mason component to show the correlation analysis data for template web page.
18 Mason component to show the basic information for template web page.
20 - Mason root page = template_detail.mas
21 - Perl controller = template.pl
27 Aureliano Bombarely (ab782@cornell.edu)
45 use CXGN::Metadata::Dbiref;
46 use CXGN::Metadata::Dbipath;
47 use CXGN::GEM::Template;
48 use CXGN::Page::FormattingHelpers qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
51 my $corr_analysis_content;
54 ## Define the default message
56 my $default_message = '<font color="gray"><i>No available</i></font>';
58 ## Define the internal links associated to the internal accessions
59 ## This should be replace for other system
61 my %internal_prelinks = (
62 unigene => ['<a href=/search/unigene.pl?unigene_id=', '', '>SGN-U', '', '</a>'],
63 est => ['<a href=/search/est/pl?request_from=1&request_id=', '', '&request_type=7>SGN-E', '', '</a>'],
64 clone => ['<a href=/search/est/pl?request_from=1&request_id=', '', '&request_type=8>SGN-C', '', '</a>'],
69 ## If there aren't any template that comes from template it will do nothing. The error message will returned by basic information
71 if (defined $template) {
73 ## Get the data from the template object
75 my $template_id = $template->get_template_id();
77 ## Search correlation analysis member for this template id.
79 my $corr_analysis_html;
81 ## Find correlation analysis id associated with this template
83 my $corr_analysis_rs = $schema->resultset('GeCorrelationMember')
86 { template_a_id => $template_id },
87 { template_b_id => $template_id }
90 select => 'correlation_analysis_id',
91 group_by => 'correlation_analysis_id'
95 my @corr_analysis_ids = $corr_analysis_rs->get_column('correlation_analysis_id')
99 if (scalar(@corr_analysis_ids) > 0) { ### Mean that exists correlation analysis for this template_id.
101 ## It will print a table and a list of templates with correlation values per analysis so:
103 foreach my $corr_id (@corr_analysis_ids) {
105 my ($corr_analysis_row) = $schema->resultset('GeCorrelationAnalysis')
108 correlation_analysis_id => $corr_id
112 my $methodology = $corr_analysis_row->get_column('methodology') ||
115 my $description = $corr_analysis_row->get_column('description') ||
118 ## Construct the table for the data
120 $corr_analysis_html .= '<table width="100%">';
121 $corr_analysis_html .= '<tr> <td width="30%"> <b>Correlation Analisis ID: </b> </td> <td>' . $corr_id . '</td></tr>';
122 $corr_analysis_html .= '<tr> <td width="30%"> <b>Methodology: </b> </td> <td>' . $methodology . '</td></tr>';
123 $corr_analysis_html .= '<tr> <td width="30%"> <b>Description: </b> </td> <td>' . $description . '</td></tr>';
124 $corr_analysis_html .= '</table><br>';
127 ## Now we are going to get all the correlation values using two aprox, (positives and negatives);
129 my @corr_types = ('Possitive correlations', 'Negative correlations');
130 foreach my $corr_type (@corr_types) {
133 if ($corr_type =~ m/negative/i) {
135 $order = 'correlation_value ASC';
137 elsif ($corr_type =~ m/possitive/i) {
139 $order = 'correlation_value DESC';
143 $order = 'correlation_value';
146 ## When the condition is set, it will take the data from the database, searching for template_a_id
147 ## OR template_b_id (Should not be duplicated, but anyway the duplications will be removed later)
149 my @corr_members_rows = $schema->resultset('GeCorrelationMember')
153 template_a_id => $template_id,
154 correlation_analysis_id => $corr_id,
155 correlation_value => {$cond, 0}
158 template_b_id => $template_id,
159 correlation_analysis_id => $corr_id,
160 correlation_value => {$cond, 0}
169 my ($corrtype, $corr_template_type);
171 ## Now it will get the template_id (a or b) and to put in the same order in an array
176 foreach my $corr_member_row (@corr_members_rows) {
178 my %corr_member_data = $corr_member_row->get_columns();
179 $corrtype = $corr_member_data{'correlation_type'};
181 my $templ_a_id = $corr_member_data{'template_a_id'};
182 my $templ_b_id = $corr_member_data{'template_b_id'};
184 ## It will take the data diff
186 if ($templ_a_id == $template_id) {
187 unless (exists $member{$templ_b_id}) {
188 $member{$templ_b_id} = $corr_member_data{'correlation_value'};
189 push @corr_member_ids, $templ_b_id;
192 elsif ($templ_b_id == $template_id) {
193 unless (exists $member{$templ_a_id}) {
194 $member{$templ_a_id} = $corr_member_data{'correlation_value'};
195 push @corr_member_ids, $templ_a_id;
200 ## With the list of template_ids it will take them using CXGN::GEM::Template object
202 if (@corr_members_rows > 0) {
204 my $temp_count = ' (' . scalar(@corr_member_ids) . ' templates correlated)';
205 $corr_analysis_html .= '<table width="100%">';
206 $corr_analysis_html .= '<tr> <td width ="2%"></td><td width="28%"> <b>Correlation Type: </b> </td>';
207 $corr_analysis_html .= ' <td align="left">'.$corr_type . $temp_count .'</td></tr>';
208 $corr_analysis_html .= '</table><br>';
212 foreach my $corr_template_id (@corr_member_ids) {
214 ## Create the link for the new template_id
216 my $corr_template = CXGN::GEM::Template->new($schema, $corr_template_id);
217 my $corr_template_name = $corr_template->get_template_name();
218 my $corr_template_type = $corr_template->get_template_type();
219 my $corr_template_link = '/gem/template.pl?id=' . $corr_template_id;
220 my $corr_template_html = "<a href=$corr_template_link>" . $corr_template_name . '</a>';
223 ## Get the SGN-internal link
225 my @dbiref_list_id = $corr_template->get_dbiref_list();
227 if (scalar(@dbiref_list_id) > 0) {
229 foreach my $dbiref_id (@dbiref_list_id) {
231 my $dbiref = CXGN::Metadata::Dbiref->new($schema, $dbiref_id);
232 my $dbipath = CXGN::Metadata::Dbipath->new($schema, $dbiref->get_dbipath_id() );
234 my $itype = $dbipath->get_table_name();
236 my $prelink_aref = $internal_prelinks{$itype};
237 my @prelink = @{$prelink_aref};
239 ## Define the link with the accession for positions 1 and 3 in the array
241 $prelink[1] = $dbiref->get_accession();
242 $prelink[3] = $dbiref->get_accession();
244 my $internal_link = join('', @prelink);
245 push @corr_data, [$corr_template_html, $member{$corr_template_id}, $internal_link];
249 push @corr_data, [$corr_template_html, $member{$corr_template_id}, $default_message];
253 if (scalar(@corr_data) > 0) {
254 $corr_analysis_html .= columnar_table_html( headings => [ 'Template', $corrtype, 'Internal Mapping' ],
256 __align => ['l', 'c', 'c'],
258 $corr_analysis_html .= '<br>';
264 $corr_analysis_html = 'No correlation analysis was found associated to this template';
266 $corr_analysis_content = info_section_html(
267 title => "Correlation analysis (".$corr_n.")",
268 contents => $corr_analysis_html,
277 <% $corr_analysis_content %>
280 /util/import_javascript.mas,
281 classes => 'CXGN.Effects'