6 mason component to take basic sample data from the database and return it as html
10 A mason component to take basic sample data from the database and return it as html
23 use CXGN::People::Person;
25 my $default_message = '<span class="ghosted">not recorded</span>';
27 my $sample_name = $sample->get_sample_name();
28 my $alt_name = $sample->get_alternative_name() || $default_message;
29 my $type_id = $sample->get_type_id();
30 my $description = $sample->get_description() || $default_message;
31 my $contact_id = $sample->get_contact_id();
32 my $organism_id = $sample->get_organism_id();
33 my $stock_id = $sample->get_stock_id();
34 my $protocol_id = $sample->get_protocol_id();
36 ## Now it will take the data for each id
40 my $type_name_html = $default_message;
41 if (defined $type_id) {
43 my ($type_cvterm_row) = $schema->resultset('Cv::Cvterm')
44 ->search({ cvterm_id => $type_id });
46 if (defined $type_cvterm_row) {
48 $type_name_html = $type_cvterm_row->get_column('name');
54 my $organism_html = $default_message;
55 my ($organism_row) = $schema->resultset('Organism::Organism')
56 ->search( { organism_id => $organism_id } );
58 if (defined $organism_row) {
59 my $genus = $organism_row->get_column('genus');
60 my $species = $organism_row->get_column('species');
61 my $organism_link = '/chado/organism.pl?organism_id='.$organism_id;
62 $organism_html = "<a href=$organism_link>$species</a><br>";
66 ## Same thing with protocol (it haven't any web yet)
68 my $protocol_html = $default_message;
69 my ($protocol_row) = $schema->resultset('BsProtocol')
70 ->search( { protocol_id => $protocol_id } );
72 if (defined $protocol_row) {
73 my $protocol_name = $protocol_row->get_column('protocol_name');
74 ## my $protocol_link = '/biosource/protocol.pl?protocol_id='.$protocol_id;
75 ## $protocol_html = "<a href=$protocol_link>$protocol_name</a><br>";
76 $protocol_html = $protocol_name;
81 my $contact_html = $default_message;
83 my $contact = CXGN::People::Person->new($schema->storage()->dbh(), $contact_id);
85 if (defined $contact) {
87 my $saludation = $contact->get_salutation();
88 my $first_name = $contact->get_first_name();
89 my $last_name = $contact->get_last_name();
91 my $contact_link = '/solpeople/personal-info.pl?sp_person_id=' . $contact_id;
92 $contact_html = "<a href=$contact_link>$saludation $first_name $last_name</a><br>";
95 ## For now, there are not any stock information to show. It should be complete with
96 ## Nat. div. module in some point
100 my (@external_links_html);
101 my %dbxref_related = $sample->get_dbxref_related();
103 foreach my $dbxref_id (sort keys %dbxref_related) {
105 ## Get the sample_element_dbxref (GO and PO terms) (with cvterm.name)
106 ## Get external accessions (without cvterm.name)
108 if (defined $dbxref_related{$dbxref_id} ) {
110 my %dbxref_rel_data = %{ $dbxref_related{$dbxref_id} };
112 if (defined $dbxref_rel_data{'cvterm.name'}) {
114 my $onto_accession = $dbxref_rel_data{'db.name'} . ":" . $dbxref_rel_data{'dbxref.accession'};
115 my $onto_descr = $dbxref_rel_data{'cvterm.name'};
116 my $onto_link = '/cvterm/'.$dbxref_rel_data{'cvterm.cvterm_id'}.'/view';
117 my $onto_line = "<a href=$onto_link>$onto_accession</a> ($onto_descr)<br>";
118 push @onto_html, $onto_line;
121 my $external_accession = $dbxref_rel_data{'db.name'} . ": " . $dbxref_rel_data{'dbxref.accession'};
122 if( $dbxref_rel_data{'db.urlprefix'} && $dbxref_rel_data{'db.url'} ) {
123 my $external_link = $dbxref_rel_data{'db.urlprefix'} . $dbxref_rel_data{'db.url'} . $dbxref_rel_data{'dbxref.accession'};
124 my $external_line = "<a href=$external_link>$external_accession</a><br>";
125 push @external_links_html, $external_line;
127 push @external_links_html, $external_accession;
133 my $ontologies_list = join(' ', @onto_html) || $default_message;
134 my $external_links_list = join(' ', @external_links_html) || $default_message;
138 <&| /page/info_section.mas, title => 'Data source' &>
140 <& /page/info_table.mas, multicol => 4, data => [
141 'Name' => $sample_name,
142 'Alternative name' => $alt_name,
143 'Type' => $type_name_html,
144 'Protocol' => $protocol_html,
145 'Organism' => $organism_html,
146 'Contact' => $contact_html,
149 <& /page/info_table.mas, data => [
150 'Description' => $description,
152 <& /page/info_table.mas, data => [
153 'Ontology terms' => $ontologies_list,
154 'External links' => $external_links_list,