Merge pull request #1897 from solgenomics/topic/encode_passwords3
[sgn.git] / mason / transcript / unigene / deprecated_content.mas
blobbe05e54b03f5bf11fdac669ac38b90fce5e8fd76
1 <%doc>
3 =head1 NAME 
4  
5  deprecated_contet.mas
6  Mason component to show a deprecated message for deprecated unigenes
8 =cut
10 =head1 VERSION 
12 0.1
14 =cut 
16 =head1 SYNOPSIS
18 <& '/transcript/unigene/deprecated_content.mas',unigene => $unigene &>
20 where: $unigene, an CXGN::Transcript::Unigene object
21       
22 =cut
24 =head1 DESCRIPTION
26  Mason component to show a deprecated message for deprecated unigenes
28 =cut
30 =head 1 AUTHOR
32  Aureliano Bombarely (ab782@cornell.edu)
34 =cut  
36 </%doc>
39 <%args>
40 $unigene
41 </%args>
44 <%perl>
46 use strict;
47 use warnings;
49 use SGN::Schema;
50 use CXGN::Transcript::Unigene;
51 use CXGN::Transcript::UnigeneBuild;
52 use CXGN::Page::FormattingHelpers  qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
54 my $deprecate_content;
56 ## This code only will return something if exists the unigene
58 if (defined $unigene->get_unigene_id() ) {
60    ## First get the unigene build and check its status
62    my $unigene_build = $unigene->get_unigene_build();
63    my $unigene_build_status = $unigene_build->get_status();
64    my $org_group_name = $unigene_build->get_organism_group_name();
65    my $build_nr = $unigene_build->get_build_nr();
67    ## If the status is not current, get the current unigenes
69    if ($unigene_build_status ne 'C') { 
70        my @updated_unigene = $unigene->get_current_unigene_ids( $unigene->get_unigene_id() );
71        
72        if (@updated_unigene) { 
73     
74            $deprecate_content .= "<br><div style='text-align:center; padding:3px; margin-left:5px;
75                                   margin-bottom:10px; font-size:14px; border:1px dashed #772222; 
76                                   background-color:#e5e5e5;'>";
77            $deprecate_content .= "<span style=color:#660000'>This unigene is from an out-of-date build, 
78                                   <em>$org_group_name #$build_nr</em></span>";       
79         
80            my ($new_build_organism, $new_build_nr) = $unigene_build->get_superseding_build_info();
81            
82            if(@updated_unigene == 0){ 
83            
84                $deprecate_content .= "<br>It does not exist"; 
85            } 
86            elsif(@updated_unigene == 1){
87                
88                $deprecate_content .= "<br />It has been superseded by <a href='unigene.pl?unigene_id=";
89                $deprecate_content .= $updated_unigene[0] . "'>SGN-U" . $updated_unigene[0] . "</a>";
90            } 
91            elsif(@updated_unigene > 1){
92                
93                $deprecate_content .= "<br />It has been split into ";
94                my $i = 0;
95                
96                while($i < @updated_unigene) {
97                 
98                    if ($i > 0 && @updated_unigene!=2) { 
99                        $deprecate_content .= ", "
100                    } 
101                    elsif($i > 0) { 
102                        $deprecate_content .= " " 
103                    }
104                    if ($i == @updated_unigene - 1) { 
105                        $deprecate_content .= "and " 
106                    }
107                    
108                    $deprecate_content .= "<a href='unigene.pl?unigene_id=" . $updated_unigene[$i] . "'>SGN-U"; 
109                    $deprecate_content .= $updated_unigene[$i] . "</a>"; 
110                    $i++;
111                }
112            }
113            $deprecate_content .= " in the current build, <em style='white-space:nowrap'>$new_build_organism #$new_build_nr</em>";
114            $deprecate_content .= "</div>";
115        } 
116        else {
117         
118            my ($new_build_organism_b, $new_build_nr_b) = $unigene_build->get_superseding_build_info();
119            
120            $deprecate_content .= "<br><div style='text-align:center; padding:3px; margin-left:5px;
121                                   margin-bottom:10px; font-size:14px; border:1px dashed #772222; 
122                                   background-color:#e5e5e5;'>";
123            $deprecate_content .= "<span style=color:#660000'>This unigene is from an out-of-date build, 
124                                   <em>$org_group_name #$build_nr</em></span>"; 
125            $deprecate_content .= "<br> The current build is, <em style='white-space:nowrap'>$new_build_organism_b #$new_build_nr_b</em>";
126            $deprecate_content .= "</div>";
127        }
128    }
131 </%perl>
133 <% $deprecate_content %>