6 mason component to take sample relations associated to a sample from the database and return it as html
18 A mason component to take sample relations associated to a sample from the database and return it as html.
25 Aureliano Bombarely (ab782@cornell.edu)
35 $sample_relations_href
42 use CXGN::Page::FormattingHelpers qw/ info_section_html info_table_html columnar_table_html page_title_html html_break_string /;
45 my @relation_types = ('parents', 'brothers', 'children');
47 my $default_message = '<i><font color="gray">Data not available</basefont></i>';
49 ## Now it will take each sample relationship and it will take sample_id,
50 ## relation_type and sample_name
52 my %sample_relations = %{$sample_relations_href};
56 foreach my $relation (@relation_types) {
58 if (defined $sample_relations{$relation} ) {
60 my @samples_rel = @{$sample_relations{$relation}};
62 foreach my $sample_rel (@samples_rel) {
64 my $sample_id = $sample_rel->get_sample_id();
65 my $sample_name = $sample_rel->get_sample_name();
66 my $sample_link = '/biosource/sample.pl?id=' . $sample_id;
67 my $sample_html = "<a href=$sample_link>$sample_name</a><br>";
69 my $type_id = $sample_rel->get_type_id();
70 my $type_name_html = $default_message;
71 if (defined $type_id) {
73 my ($type_cvterm_row) = $schema->resultset('Cv::Cvterm')
74 ->search({ cvterm_id => $type_id });
76 if (defined $type_cvterm_row) {
78 $type_name_html = $type_cvterm_row->get_column('name');
83 push @sample_rel_list, [uc($relation), $sample_html, $type_name_html];
88 ## Use columnar table to give the html format. If don't exists any data, print message.
90 my $rel_composition_html = columnar_table_html( headings => [ 'Relation', 'Sample', 'Type'],
91 data => \@sample_rel_list,
93 __align => ['c', 'c', 'c'], );
96 my $rel_n = scalar(@sample_rel_list);
98 $rel_composition_html = 'No relation was found associated to this sample';
101 $rel_content = info_section_html( title => "Sample Relations (".$rel_n.")",
102 contents => $rel_composition_html,
113 /util/import_javascript.mas,
114 classes => 'CXGN.Effects'