seedlot upload with accession synonyms. seedlot upload works to update existing seedlots
[sgn.git] / lib / SGN / Controller / Biosource.pm
blob9d9bcd23ad4a3cedb0466f9f359c2a928dbcaf31
1 =head1 NAME
3 SGN::Controller::Biosource - controller for working with Biosource data, which is metadata about datasets
5 =cut
7 package SGN::Controller::Biosource;
8 use Moose;
10 BEGIN { extends 'Catalyst::Controller' }
12 use CXGN::Biosource::Sample;
13 use CXGN::GEM::Target;
15 =head1 PUBLIC ACTIONS
17 =head2 view_sample
19 Public path: /data_source/<ident>/view
21 View a biosource sample detail page.
23 =cut
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');
31 $c->stash(
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
44 # the identifier
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');
52 no strict 'refs';
53 my $method_name = $ident =~ /\D/ ? 'new_by_name' : 'new';
54 $c->stash->{sample} = CXGN::Biosource::Sample->$method_name( $schema, $ident )
55 or $c->throw_404;
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')
65 ->all
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')
85 ->all