Merge branch 'master' of https://github.com/solgenomics/sgn
[sgn.git] / cgi-bin / tools / sixframe_translate.pl
blobec7893c2494810f99b4cd9d8afa07b9618c74be1
1 use CatalystX::GlobalContext qw( $c );
2 # instead of linking to this, consider just embedding the translations
3 # directly into the relevant detail page
5 use strict;
6 use warnings;
8 use CGI;
9 use Bio::PrimarySeq;
11 my $cgi = CGI->new;
12 my $seq = get_legacy_est( $cgi ) || get_legacy_unigene( $cgi ) || get_direct_seq( $cgi )
13 or $c->throw( message => 'No sequence found.', is_error => 0 );
15 $c->forward_to_mason_view( '/tools/sixframe_translate_standalone.mas',
16 seq => $seq,
17 blast_url => '/tools/blast'
21 # ========= helper functions =======
23 sub get_legacy_est {
24 my ($cgi) = @_;
26 my $est_id = $cgi->param('est_id')
27 or return;
29 my $est = $c->dbic_schema('SGN::Schema')
30 ->resultset('Est')
31 ->find( $est_id )
32 or return;
34 return Bio::PrimarySeq->new( -id => "SGN-E".($est_id+0),
35 -seq => $est->hqi_seq,
39 sub get_legacy_unigene {
40 my ($cgi) = @_;
42 my $unigene_id = $cgi->param('unigene_id')
43 or return;
45 my $unigene = $c->dbic_schema('SGN::Schema')
46 ->resultset('Unigene')
47 ->find( $unigene_id )
48 or return;
50 return Bio::PrimarySeq->new( -id => 'SGN-U'.( $unigene_id+0 ),
51 -seq => $unigene->seq,
55 sub get_direct_seq {
56 my ($cgi) = @_;
58 my $seq = $cgi->param('seq')
59 or return;
61 my ( $seqid, $sequence ) = split '#', $seq;
62 return Bio::PrimarySeq->new( -id => $seqid, -seq => $seq );