Merge pull request #1897 from solgenomics/topic/encode_passwords3
[sgn.git] / mason / transcript / unigene / markers_info.mas
blobb60fa09df637d46adb803321a4ebbc97d2bdfa86
1 <%doc>
3 =head1 NAME 
4  
5  marker_info.mas
6  Mason component to create html with marker data
8 =cut
10 =head1 VERSION 
12 0.1
14 =cut 
16 =head1 SYNOPSIS
18 <& '/transcript/unigene/marker_info.mas', dbh => $dbh, unigene => $unigene  &>
21 where: $dbh, a dbi connection object
22        $unigene, an CXGN::Transcript::Unigene object
23        
24        
25 =cut
28 =head1 DESCRIPTION
30  Mason component to create html with markers data.
32 =cut
34 =head 1 AUTHOR
36  Aureliano Bombarely (ab782@cornell.edu)
38 =cut  
40 </%doc>
43 <%args>
44 $dbh
45 $unigene
46 </%args>
48 <%perl>
50 use strict;
51 use warnings;
53 use CXGN::Marker;
55 use CXGN::Page::FormattingHelpers  qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
57 my $markers_content;
59 ## Get the object
60 my $id =  $unigene->get_unigene_id();
62 ## The markers section are divided into two sections: 
63 ##   1- General markers information
64 ##   2- COSII (Conserved Ortholog Set II) marker information 
67 if (defined $id) {
69    ## First get the map information using the unigene object
71    my @mapped;
72    my @mapped_member_ids = $unigene->get_mapped_members();
73    
74    ## Define a count variable
75    my $markers_count = 0;
76     
77    foreach my $map (@mapped_member_ids) { 
78        my $marker = CXGN::Marker->new($dbh, $map->{marker_id});
79        my $marker_name = 'Unknown';   ## Use unknown by default
80        if($marker) {
81           $marker_name = $marker->name_that_marker();
82        }
83     
84        my $est_link = qq |<a href="/search/est.pl?request_id=$map->{clone_id}&request_from=1&request_type=8">SGN-C$map->{clone_id}</a>|;
85        my $marker_link = qq|<a href="/search/markers/markerinfo.pl?marker_id=$map->{marker_id}">$marker_name</a>|;
86        push @mapped, [ $est_link, $marker_link];
87        $markers_count++;
88    }
90    ## Second, put the data into a table to show in the web
92    my $mapped_html;
93    if (defined $mapped[0]) {
94        $mapped_html = columnar_table_html( headings => [ 'EST', 'Marker' ], data     => \@mapped );
95    } else {
96        $mapped_html = qq|<span class="ghosted">No member sequence or clone is mapped.</span>|;
97    }
99    my $map_content = info_table_html( 'Unigene Mapped Marker Information'   => $mapped_html,
100                                        __border               => 0,
101                                        );
103    
105    ## Third, take the COSII marker data
106    
107    my $cosii_data_html;
109    my @cosii_data = $unigene->get_cosii_info();
110    foreach my $cosii_marker (@cosii_data) { 
111        my ($marker_id, $marker_name)= @{$cosii_marker};
112        my $cosii_link = '<a href=/search/markers/markerinfo.pl?marker_id=' . $marker_id . '>' . $marker_name . '</a>';
113        $cosii_data_html .= "COSII marker $cosii_link was created with this unigene.<br />\n";
114        $markers_count++;
115    }
116    unless (defined $cosii_data[0]) {
117        $cosii_data_html .= qq|<span class="ghosted">None cosii markers associated to this unigene.</span>|;
118    }
120    my $cosii_info_link = '<a href="/markers/cosii_markers.pl">COSII Markers</a>';
121    my $cosii_content = info_table_html( "$cosii_info_link Information" => $cosii_data_html,
122                                         __border                       => 0,
123                                       );
124    
125    $map_content .= $cosii_content;
126   
127    $markers_content = info_section_html( title        => "Markers Information (".$markers_count.")", 
128                                          contents     => $map_content,
129                                          collapsible  => 1,
130                                          collapsed    => 1 
131                                        );
136 </%perl>
138 <% $markers_content %>