7 /phenome/associated_accessions.mas - a component for printing accessions (aka stocks) associated with your favorite object (locus etc.)
11 Requires the following javascript classes:
12 <& /util/import_javascript.mas, classes => ["jquery", "thickbox", "CXGN.Page.FormattingHelpers"] &>
24 =item user_type (default undef)
34 Naama Menda <nm249@cornell.edu>
50 use CXGN::Page::FormattingHelpers qw / html_optional_show /;
51 use Bio::Chado::Schema;
58 my $more; #count the number of accessions in the optional_show box
59 my $count; # a scalar for checking if there are accessions with images in the optional box
61 my $schema = Bio::Chado::Schema->connect( sub { $dbh->clone }, );
65 $more_html .= "<table>";
67 # hash of image arrays. Keys are stock ids values are arrays of image ids
70 foreach my $stock_id (@$accessions) {
71 my $stock = CXGN::Chado::Stock->new($schema, $stock_id );
72 my $stock_name = $stock->get_name();
73 $stockHash{$stock_id} = $stock_name;
76 $stock->get_image_ids(); #list of all associated image ids
77 foreach my $image_id (@image_ids) {
78 $imageHash{$image_id} = SGN::Image->new( undef, $image_id, $c );
79 push @{ $imageHoA{$stock_id} }, $image_id;
82 #if there are no associated images with this stock:
83 if ( !@image_ids ) { push @no_image, $stock_id; }
87 # Print the whole thing sorted by number of members and name.
89 my $stock_id ( sort { @{ $imageHoA{$b} } <=> @{ $imageHoA{$a} } }
93 my $stock_name = $stockHash{$stock_id};
94 #my $individual_obsolete_link =
95 # get_individual_obsolete_link($locus,$individual_id, $user_type);
97 qq|<a href="/stock/$stock_id/view">$stock_name </a> |;
99 { #print the first 3 stocks by default. The rest will be hidden
101 qq|<tr valign="top"><td>$link</td> <td> </td>|;###$individual_obsolete_link </td>|;
107 qq|<tr><td>$link </td><td> </td>|;###$individual_obsolete_link</td> |;
109 #print only 5 images, if there are more write the number of total images
110 my $image_count = ( $#{ $imageHoA{$stock_id} } );
111 if ( $image_count > 4 ) { $image_count = 4; }
112 for my $i ( 0 .. $image_count ) {
113 my $image_id = $imageHoA{$stock_id}[$i];
114 my $image = SGN::Image->new( $dbh, $image_id, $c );
115 my $small_image = $image->get_image_url("thumbnail");
116 my $medium_image = $image->get_image_url("medium");
117 my $image_page = "/image/index.pl?image_id=$image_id";
119 qq|<a href="$medium_image" title="<a href=$image_page>Go to image page </a>" class="thickbox" rel="gallery-images"><img src="$small_image" alt="" /></a> |;
120 if ( $ind_count < 4 ) { $html .= qq|<td>$thickbox</td>|; }
121 else { $more_html .= qq|<td>$thickbox</td>|; }
124 if ( $#{ $imageHoA{$stock_id} } > 4 ) {
125 my $image_count = ( $#{ $imageHoA{$stock_id} } ) + 1;
126 $html .= qq|<td>... (Total $image_count images)</td>|;
128 if ( $ind_count < 4 ) { $html .= "</tr>"; }
129 else { $more_html .= "</tr>"; }
131 $html .= "</table><br />";
132 $more_html .= "</table><br />";
135 my $no_image_count = 0;
136 foreach my $stock_id (@no_image) {
138 #my $individual_obsolete_link =
139 # get_individual_obsolete_link($locus, $individual_id, $user_type);
140 $stock_name = $stockHash{$stock_id};
141 my $link = qq|<a href="/stock/$stock_id/view">$stock_name</a> |;###$individual_obsolete_link |;
142 if ( $no_image_count < 26 ) {
152 foreach my $stock_id (@no_image) {
154 #my $individual_obsolete_link =
155 #get_individual_obsolete_link($locus, $individual_id, $user_type);
156 my $stock_name = $stockHash{$stock_id};
158 qq|<a href="/stock/$stock_id/view">$stock_name</a> |;###$individual_obsolete_link |;
164 $html .= html_optional_show(
166 "<b>See $more more accessions</b>",
168 0, #< do not show by default
169 'abstract_optional_show', #< don't use the default button-like style