3 SGN::Controller::Biosource - controller for working with Biosource data, which is metadata about datasets
7 package SGN
::Controller
::Biosource
;
10 BEGIN { extends
'Catalyst::Controller' }
12 use CXGN
::Biosource
::Sample
;
13 use CXGN
::GEM
::Target
;
19 Public path: /data_source/<ident>/view
21 View a biosource sample detail page.
25 sub view_sample
: Chained
('get_sample') PathPart
('view') Args
(0) {
26 my ( $self, $c ) = @_;
28 $c->forward('get_sample_targets');
29 $c->forward('get_sample_files');
32 sample_relations_href
=> { $c->stash->{sample
}->get_relationship },
33 pub_list
=> [ $c->stash->{sample
}->get_publication_list ],
35 template
=> '/biosource/sample_detail.mas',
40 ### helper actions ###
42 # chain root for retrieving a biosource sample, URL beginning with
43 # /data_source/<ident>. supports either an ID number or a sample name as
45 sub get_sample
: Chained
('/') CaptureArgs
(1) PathPart
('data_source') {
46 my ( $self, $c, $ident ) = @_;
48 $ident or $c->throw_client_error('invalid arguments');
50 my $schema = $c->stash->{schema
} = $c->dbic_schema('CXGN::Biosource::Schema','sgn_chado');
53 my $method_name = $ident =~ /\D/ ?
'new_by_name' : 'new';
54 $c->stash->{sample
} = CXGN
::Biosource
::Sample
->$method_name( $schema, $ident )
58 sub get_sample_files
: Private
{
59 my ( $self, $c ) = @_;
61 $c->stash->{files
} = [
62 $c->stash->{sample
}->get_bssample_row
63 ->search_related('bs_sample_files')
64 ->search_related('file')
69 # The sample can be associated expression data (search sample_id in
70 # gem.ge_target_element table)
71 sub get_sample_targets
: Private
{
72 my ( $self, $c ) = @_;
74 my $sample = $c->stash->{sample
};
76 return unless $sample->get_sample_id;
78 my $gemschema = $c->dbic_schema('CXGN::GEM::Schema','sgn_chado');
80 $c->stash->{target_list
} = [
81 map { CXGN
::GEM
::Target
->new( $gemschema, $_ ) }
82 $gemschema->resultset('GeTargetElement')
83 ->search({ sample_id
=> $sample->get_sample_id })
84 ->get_column('target_id')