typos in gene family controller
[sgn.git] / lib / SGN / Controller / Marker.pm
blob613d61ca05a178cc4d76614d5c0ba13301219222
1 =head1 NAME
3 SGN::Controller::Marker - controller for marker-related stuff
5 =cut
7 package SGN::Controller::Marker;
8 use Moose;
9 use namespace::autoclean;
11 BEGIN { extends 'Catalyst::Controller' }
13 use File::Spec::Functions;
16 =head1 PUBLIC ACTIONS
18 =head2 view_rflp_image
20 Public path: /marker/<marker_id>/rflp_image/view
22 =cut
24 sub view_rflp_image: Chained('get_marker') PathPart('rflp_image/view') :Args(0) {
25 my ( $self, $c, ) = @_;
27 my $image_size = $c->req->query_parameters->{size};
29 my $image_location = $self->rflp_image_link( $c, $c->stash->{marker} )
30 or $c->throw_404( "RFLP image not found for SGN-M".$c->stash->{marker}->marker_id );
32 $c->stash(
33 template => '/markers/view_rflp.mas',
35 image_location => $image_location,
36 image_size => $image_size
41 =head2 marker_details
43 Public path: /marker/SGN-M23545/details
45 Show the HTML detail page for this marker.
47 =cut
50 sub marker_details: Chained('get_marker') PathPart('details') :Args(0) {
51 my ( $self, $c ) = @_;
53 $c->stash(
54 template => '/markers/index.mas',
55 dbh => $c->dbc->dbh,
60 =head2 get_marker
62 Public path: /marker/SGN-M23545
64 Chaining base for fetching the marker indicated by the given marker
65 id. The marker ID is an SGN-M identifier.
67 =cut
70 sub get_marker: Chained('/') PathPart('marker') :CaptureArgs(1) {
71 my ( $self, $c, $marker_id ) = @_;
73 ($marker_id) = $marker_id =~ /^SGN-M(\d+)$/i
74 and $c->stash->{marker} = CXGN::Marker->new( $c->dbc->dbh, $marker_id)
75 or $c->throw_404('No marker found with that ID');
77 $c->stash->{marker_id} = $marker_id;
81 ############ helper methods ########
83 # Returns the stuff that goes in the 'href' attribute of the 'a' tag for
84 # an RFLP image, or undef if there is no image.
86 # =cut
88 sub rflp_image_link {
89 my ( $class, $c, $marker ) = @_;
90 my $marker_name = uc $marker->name_that_marker();
91 my ( $dir ) = $marker_name =~ /^(CD|CT|PC|PG|TG|PCD2)/
92 or return;
94 my $source = catfile( $c->get_conf('image_path'), 'rflp', $dir, "$marker_name.jpg" );
96 return unless -f $source;
98 return catfile( $c->get_conf('static_datasets_url'), 'images','rflp', $dir, "$marker_name.jpg" );